Videojs使SWF后备响应

时间:2014-04-19 16:56:06

标签: javascript html5 video html5-video flash

我目前正在使用 videojs 插件,而且我已设法让它响应以下代码:

JSFIDDLE DEMO

JS:

videojs.options.flash.swf = "../../js/video-js.swf";

// Once the video is ready
videojs("#video").ready(function(){

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

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

    resizeVideoJS(); // Initialize the function
    jQuery(window).on('resize', function () {
        resizeVideoJS(); // Call the function on resize
    })
});

HTML:

<div class="feature-video">
        <video id="video" class="video-js vjs-default-skin" controls preload="none"
               poster="http://video-js.zencoder.com/oceans-clip.png"
               data-setup="{}">
            <source src="http://video-js.zencoder.com/oceans-clip.mp4" type='video/mp4' />
            <source src="http://video-js.zencoder.com/oceans-clip.webm" type='video/webm' />
            <source src="http://video-js.zencoder.com/oceans-clip.ogv" type='video/ogg' />
    </video>
</div>

1 个答案:

答案 0 :(得分:1)

检查出来

fiddle link

<div class="feature-video">
            <video id="video" class="video-js vjs-default-skin vjs-fullscreen" controls preload="none" width="auto" height="auto" poster="http://video-js.zencoder.com/oceans-clip.png"
                   data-setup="{}">
                <source src="http://video-js.zencoder.com/oceans-clip.mp4" type='video/mp4' />
                <source src="http://video-js.zencoder.com/oceans-clip.webm" type='video/webm' />
                <source src="http://video-js.zencoder.com/oceans-clip.ogv" type='video/ogg' />
        </video>
    </div>