3

I am curently working on a HTML5 video Plugin and below is my code and trying to work with custom controls.

The problem is I am having a fullscreen button when I click it the video needs to change it to Fullscreen mode.I am able to get it worked in chrome but not in IE and Firefox.

 function addvideo() {
            var addvideo = $('<canvas id="canvas" height="468" width="560"></canvas><div class="videocontainer"><video id="video1"><source src="http://clips.vorwaerts-gmbh.de/big_buck_bunny.ogv" type="video/ogg; codecs="theora, vorbis""><source src="http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4" type="video/mp4; codecs="avc1.42E01E, mp4a.40.2""><source src="http://clips.vorwaerts-gmbh.de/big_buck_bunny.ogv" type="video/ogg; codecs="theora, vorbis""><source src="http://clips.vorwaerts-gmbh.de/big_buck_bunny.webm type="video/WebM; codecs="vp8, vorbis""></video></div>');
            $(addvideo).appendTo('#video');
        }

 function addcontrols() {
            var controls = $('<table><tr class="controls"><td id="playbtn" class="playbtn" title="Play/Pause"><td id="elapsedtimer" class="elapsedtimer">00:00</td><td id="videoslider" class="videoslider"></td><td id="totaltimer" class="totaltimer">00:00</td><td class="HD"></td><td class="fullscreen"></td><td><td id="volumeslider" class="volumeslider"></td><td class="volumeon" title="Mute/Unmute"></td></tr></table>');
            $(controls).appendTo('#controlspane');
        }

This is the function for Fullscreen Mode:

$('.fullscreen').on('click', function() {
$('#video1').get(0).webkitEnterFullscreen();
$('#video1').get(0).mozRequestFullScreen();
return false;
});

Can anyone suggest me how do I modify this in order to achieve my goal?

4

1 回答 1

3

ie9 不支持全屏API

对于 FF 和 Chrome,只需改进您的功能...首先,将“get(0)”删除为较短的“[0]”。然后添加一个 var 来缓存指向视频的指针,最后添加 w3c 版本的命令

$('.fullscreen').on('click', function() {
var a = $('#video1')[0],
    fsReturn = a.requestFullscreen ? a.requestFullscreen() : // W3C
    a.webkitRequestFullScreen ? a.webkitRequestFullScreen() : // Chrome
    a.mozRequestFullScreen ? a.mozRequestFullScreen() : false; // Firefox
};
于 2012-04-06T09:25:40.657 回答