小编Pat*_*ick的帖子

多个响应式video.js播放器

我正在使用这个解决方案http://daverupert.com/2012/05/making-video-js-fluid-for-rwd/,以使videojs播放器流畅.我的问题是,当我有多个视频(每个都有一个唯一的ID),我不知道如何使这项工作.

这是我的开发网站,我有3个视频,http://tweedee.e-mediaresources.info/

以下是我为玩家提供的代码(来自Dave Rupert的解决方案):

    <script type="text/javascript">
    // Once the video is ready
    _V_('#my_video_1').ready(function(){

        var myPlayer = this;    // Store the video object
        var aspectRatio = 9/16; // Make up an aspect ratio

        function resizeVideoJS(){
            // Get the parent element's actual width
            var width = document.getElementById(myPlayer.id).parentElement.offsetWidth;
            // Set width to fill parent element, Set height
            myPlayer.width(width).height( width * aspectRatio );
        }

        resizeVideoJS(); // Initialize the function
        window.onresize = resizeVideoJS; // Call the function on resize
    });
    </script>
Run Code Online (Sandbox Code Playgroud)

这段代码适用于一个视频,但我怎么做多个ids …

javascript video video.js

2
推荐指数
1
解决办法
4586
查看次数

标签 统计

javascript ×1

video ×1

video.js ×1