Home >Web Front-end >JS Tutorial >Flowplayer Dynamic Video Size
This tutorial demonstrates how to dynamically adjust Flowplayer video size. This is particularly useful for responsive designs or when handling videos with varying bitrates and resolutions (typically maintaining a 16:9 aspect ratio).
Related Articles:
<code class="language-javascript">// Resize video function $('.change-size-btn').on('click', function(e) { e.preventDefault(); // Get video ID const videoId = $(this).closest('.fms').attr('id'); // Determine display type (fixed, fit, fullscreen) const btnElem = $(this); const vidElem = $('#' + videoId).find('object'); const widgetContainer = $('#' + videoId).closest('.video-container'); const displayType = btnElem.attr('vidDisplayType'); let width, height; // Fixed dimensions if (displayType === 'fixed') { height = btnElem.attr('vidHeight'); width = btnElem.attr('vidWidth'); } // Fit to container else if (displayType === 'fit') { height = widgetContainer.height(); width = widgetContainer.width(); } // Resize video console.log(`Resizing video to ${width} x ${height}...`); vidElem.height(height).width(width).fadeIn("slow", function() { console.log('Resize complete.'); $f(videoId).getScreen().animate({ width: width, height: height }, 500); }); });</code>
<code class="language-html"> <div> Select Video Size: <button class="change-size-btn" viddisplaytype="fixed" vidwidth="240" vidheight="427">240 x 427</button> <button class="change-size-btn" viddisplaytype="fixed" vidwidth="360" vidheight="640">360 x 640</button> <button class="change-size-btn" viddisplaytype="fixed" vidwidth="720" vidheight="1280">720 x 1280</button> <button class="change-size-btn" viddisplaytype="fit">Fit window</button> </div></code>
The above is the detailed content of Flowplayer Dynamic Video Size. For more information, please follow other related articles on the PHP Chinese website!