1
0
mirror of https://github.com/videojs/video.js.git synced 2024-12-02 09:11:54 +02:00

Merge pull request #98 from ZenJosh/master

Refactored fullscreen logic
This commit is contained in:
Heff 2011-12-01 16:47:55 -08:00
commit 2f99215f8d
2 changed files with 12 additions and 30 deletions

View File

@ -437,8 +437,10 @@ _V_.Player.prototype.extend({
// Turn on fullscreen (or window) mode
enterFullScreen: function(){
if (this.supportsFullScreen()) {
this.videoIsFullScreen = true;
this.videoIsFullScreen = true;
if (typeof this.el.webkitRequestFullScreen == 'function') {
this.el.webkitRequestFullScreen();
} else if (this.supportsFullScreen()) {
this.apiCall("enterFullScreen");
} else {
this.enterFullWindow();
@ -448,9 +450,11 @@ _V_.Player.prototype.extend({
},
exitFullScreen: function(){
if (this.supportsFullScreen()) {
this.videoIsFullScreen = false;
this.apiCall("exitFullScreen");
this.videoIsFullScreen = false;
if (typeof this.el.webkitRequestFullScreen == 'function') {
document.webkitCancelFullScreen();
} else if (this.supportsFullScreen()) {
document.webkitExitFullScreen();
} else {
this.exitFullWindow();
}

View File

@ -16,7 +16,7 @@ _V_.PlaybackTech = _V_.Component.extend({
// Create placeholder methods for each that warn when a method
// isn't supported by the current playback technology
_V_.apiMethods = "play,pause,paused,currentTime,setCurrentTime,duration,buffered,volume,setVolume,muted,setMuted,width,height,supportsFullScreen,enterFullScreen,exitFullScreen,src,load,currentSrc,preload,setPreload,autoplay,setAutoplay,loop,setLoop,error,networkState,readyState,seeking,initialTime,startOffsetTime,played,seekable,ended,videoTracks,audioTracks,videoWidth,videoHeight,textTracks,defaultPlaybackRate,playbackRate,mediaGroup,controller,controls,defaultMuted".split(",");
_V_.apiMethods = "play,pause,paused,currentTime,setCurrentTime,duration,buffered,volume,setVolume,muted,setMuted,width,height,supportsFullScreen,enterFullScreen,src,load,currentSrc,preload,setPreload,autoplay,setAutoplay,loop,setLoop,error,networkState,readyState,seeking,initialTime,startOffsetTime,played,seekable,ended,videoTracks,audioTracks,videoWidth,videoHeight,textTracks,defaultPlaybackRate,playbackRate,mediaGroup,controller,controls,defaultMuted".split(",");
_V_.each(_V_.apiMethods, function(methodName){
_V_.PlaybackTech.prototype[methodName] = function(){
throw new Error("The '"+method+"' method is not available on the playback technology's API");
@ -128,29 +128,16 @@ _V_.HTML5 = _V_.PlaybackTech.extend({
height: function(){ return this.el.offsetHeight; },
supportsFullScreen: function(){
if (typeof this.el.webkitRequestFullScreen == 'function') {
return true;
} else if (typeof this.el.webkitEnterFullScreen == 'function') {
if (typeof this.el.webkitEnterFullScreen == 'function') {
// Seems to be broken in Chromium/Chrome && Safari in Leopard
if (!navigator.userAgent.match("Chrome") && !navigator.userAgent.match("Mac OS X 10.5")) {
return true;
}
} else {
}
return false;
}
},
enterFullScreen: function(){
if (typeof this.el.webkitRequestFullScreen == 'function') {
try {
this.player.el.webkitRequestFullScreen();
} catch (e) {
if (e.code == 11) {
// this.warning(VideoJS.warnings.videoNotReady);
_V_.log("VideoJS: Video not ready.")
}
}
} else {
try {
this.el.webkitEnterFullScreen();
} catch (e) {
@ -159,15 +146,6 @@ _V_.HTML5 = _V_.PlaybackTech.extend({
_V_.log("VideoJS: Video not ready.")
}
}
}
},
exitFullScreen: function(){
if (typeof this.el.webkitRequestFullScreen == 'function') {
document.webkitCancelFullScreen();
} else {
document.webkitExitFullScreen();
}
},
src: function(src){ this.el.src = src; },
load: function(){ this.el.load(); },