1
0
mirror of https://github.com/videojs/video.js.git synced 2025-07-17 01:42:41 +02:00

Updated swf code to auto play on new src.

This commit is contained in:
Steve Heffernan
2011-12-01 16:48:06 -08:00
parent b329dfd107
commit 325084c6a1
2 changed files with 29 additions and 57 deletions

View File

@ -75,7 +75,6 @@ _V_.Player = _V_.Component.extend({
this.addEvent("pause", this.onPause); this.addEvent("pause", this.onPause);
this.addEvent("error", this.onError); this.addEvent("error", this.onError);
// When the API is ready, loop through the components and add to the player. // When the API is ready, loop through the components and add to the player.
if (this.options.controls) { if (this.options.controls) {
this.ready(function(){ this.ready(function(){
@ -442,28 +441,24 @@ _V_.Player.prototype.extend({
// Turn on fullscreen (or window) mode // Turn on fullscreen (or window) mode
enterFullScreen: function(){ enterFullScreen: function(){
if (this.supportsFullScreen()) { if (this.supportsFullScreen()) {
this.videoIsFullScreen = true; this.apiCall("enterFullScreen");
this.apiCall("enterFullScreen"); } else {
} else { this.enterFullWindow();
this.enterFullWindow(); }
} this.triggerEvent("enterFullScreen");
this.triggerEvent("enterFullScreen"); return this;
return this; },
},
exitFullScreen: function(){ exitFullScreen: function(){
if (this.supportsFullScreen()) { if (true || !this.supportsFullScreen()) {
this.videoIsFullScreen = false; this.exitFullWindow();
this.apiCall("exitFullScreen"); }
} else { this.triggerEvent("exitFullScreen");
this.exitFullWindow();
}
this.triggerEvent("exitFullScreen");
// Otherwise Shouldn't be called since native fullscreen uses own controls. // Otherwise Shouldn't be called since native fullscreen uses own controls.
return this; return this;
}, },
enterFullWindow: function(){ enterFullWindow: function(){
this.videoIsFullScreen = true; this.videoIsFullScreen = true;
@ -569,7 +564,7 @@ _V_.Player.prototype.extend({
this.load(); this.load();
} }
if (this.options.autoplay) { if (this.options.autoplay) {
// this.play(); this.play();
} }
} }
} }

View File

@ -20,7 +20,7 @@ _V_.PlaybackTech = _V_.Component.extend({
// Create placeholder methods for each that warn when a method // Create placeholder methods for each that warn when a method
// isn't supported by the current playback technology // 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_.each(_V_.apiMethods, function(methodName){
_V_.PlaybackTech.prototype[methodName] = function(){ _V_.PlaybackTech.prototype[methodName] = function(){
throw new Error("The '"+method+"' method is not available on the playback technology's API"); throw new Error("The '"+method+"' method is not available on the playback technology's API");
@ -135,45 +135,22 @@ _V_.HTML5 = _V_.PlaybackTech.extend({
height: function(){ return this.el.offsetHeight; }, height: function(){ return this.el.offsetHeight; },
supportsFullScreen: function(){ supportsFullScreen: function(){
if (typeof this.el.webkitRequestFullScreen == 'function') { if(typeof this.el.webkitEnterFullScreen == 'function') {
return true;
} else if (typeof this.el.webkitEnterFullScreen == 'function') {
// Seems to be broken in Chromium/Chrome && Safari in Leopard // Seems to be broken in Chromium/Chrome && Safari in Leopard
if (!navigator.userAgent.match("Chrome") && !navigator.userAgent.match("Mac OS X 10.5")) { if (!navigator.userAgent.match("Chrome") && !navigator.userAgent.match("Mac OS X 10.5")) {
return true; return true;
} }
} else { }
return false; return false;
}
}, },
enterFullScreen: function(){ enterFullScreen: function(){
if (typeof this.el.webkitRequestFullScreen == 'function') { try {
try { this.el.webkitEnterFullScreen();
this.player.el.webkitRequestFullScreen(); } catch (e) {
} catch (e) { if (e.code == 11) {
if (e.code == 11) { // this.warning(VideoJS.warnings.videoNotReady);
// this.warning(VideoJS.warnings.videoNotReady); _V_.log("VideoJS: Video not ready.")
_V_.log("VideoJS: Video not ready.")
}
} }
} else {
try {
this.el.webkitEnterFullScreen();
} catch (e) {
if (e.code == 11) {
// this.warning(VideoJS.warnings.videoNotReady);
_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; }, src: function(src){ this.el.src = src; },
@ -316,8 +293,8 @@ _V_.H5swf = _V_.PlaybackTech.extend({
// Currently the SWF doesn't autoplay if you load a source later. // Currently the SWF doesn't autoplay if you load a source later.
// e.g. Load player w/ no source, wait 2s, set src. // e.g. Load player w/ no source, wait 2s, set src.
if (this.player.autoplay) { if (this.player.autoplay) {
// var tech = this; var tech = this;
// setTimeout(function(){ tech.play(); }, 0); setTimeout(function(){ tech.play(); }, 0);
} }
}, },
load: function(){ this.el.vjs_load(); }, load: function(){ this.el.vjs_load(); },