diff --git a/dev/src/behaviors.js b/dev/src/behaviors.js index c5539684b..c73cd1766 100644 --- a/dev/src/behaviors.js +++ b/dev/src/behaviors.js @@ -429,53 +429,19 @@ VideoJS.player.newBehavior("fullscreenToggle", function(element){ // When the user clicks on the fullscreen button, update fullscreen setting onFullscreenToggleClick: function(event){ if (!this.videoIsFullScreen) { - this.fullscreenOn(); + this.enterFullScreen(); } else { - this.fullscreenOff(); + this.exitFullScreen(); } }, - // Turn on fullscreen (window) mode - // Real fullscreen isn't available in browsers quite yet. - fullscreenOn: function(){ - if (!this.nativeFullscreenOn()) { - this.videoIsFullScreen = true; - // Storing original doc overflow value to return to when fullscreen is off - this.docOrigOverflow = document.documentElement.style.overflow; - // Add listener for esc key to exit fullscreen - _V_.addListener(document, "keydown", this.fullscreenOnEscKey.rEvtContext(this)); - // Add listener for a window resize - _V_.addListener(window, "resize", this.fullscreenOnWindowResize.rEvtContext(this)); - // Hide any scroll bars - document.documentElement.style.overflow = 'hidden'; - // Apply fullscreen styles - _V_.addClass(this.box, "vjs-fullscreen"); - // Resize the box, controller, and poster - this.positionAll(); - } - }, - // If available use the native fullscreen - nativeFullscreenOn: function(){ - return (this.supportsFullScreen()) ? this.enterFullScreen() : false; - }, - // Turn off fullscreen (window) mode - fullscreenOff: function(){ - this.videoIsFullScreen = false; - document.removeEventListener("keydown", this.fullscreenOnEscKey, false); - window.removeEventListener("resize", this.fullscreenOnWindowResize, false); - // Unhide scroll bars. - document.documentElement.style.overflow = this.docOrigOverflow; - // Remove fullscreen styles - _V_.removeClass(this.box, "vjs-fullscreen"); - // Resize the box, controller, and poster to original sizes - this.positionAll(); - }, + fullscreenOnWindowResize: function(event){ // Removeable this.positionControlBars(); }, // Create listener for esc key while in full screen mode fullscreenOnEscKey: function(event){ // Removeable if (event.keyCode == 27) { - this.fullscreenOff(); + this.exitFullScreen(); } } } diff --git a/dev/src/html5.js b/dev/src/html5.js index b04adb28c..7e35c7a13 100644 --- a/dev/src/html5.js +++ b/dev/src/html5.js @@ -443,7 +443,8 @@ VideoJS.player.extend({ volume: function(percentAsDecimal){ if (percentAsDecimal !== undefined) { - this.values.volume = parseFloat(percentAsDecimal); + // Force value to between 0 and 1 + this.values.volume = Math.max(0, Math.min(1, parseFloat(percentAsDecimal))); this.video.volume = this.values.volume; this.setLocalStorage("volume", this.values.volume); return this; @@ -481,7 +482,8 @@ VideoJS.player.extend({ } return false; }, - enterFullScreen: function(){ + + html5EnterNativeFullScreen: function(){ try { this.video.webkitEnterFullScreen(); } catch (e) { @@ -489,6 +491,53 @@ VideoJS.player.extend({ } return this; }, + + // Turn on fullscreen (window) mode + // Real fullscreen isn't available in browsers quite yet. + enterFullScreen: function(){ + if (this.supportsFullScreen()) { + this.html5EnterNativeFullScreen(); + } else { + this.enterFullWindow(); + } + }, + + exitFullScreen: function(){ + if (this.supportsFullScreen()) { + // Shouldn't be called + } else { + this.exitFullWindow(); + } + }, + + enterFullWindow: function(){ + this.videoIsFullScreen = true; + // Storing original doc overflow value to return to when fullscreen is off + this.docOrigOverflow = document.documentElement.style.overflow; + // Add listener for esc key to exit fullscreen + _V_.addListener(document, "keydown", this.fullscreenOnEscKey.rEvtContext(this)); + // Add listener for a window resize + _V_.addListener(window, "resize", this.fullscreenOnWindowResize.rEvtContext(this)); + // Hide any scroll bars + document.documentElement.style.overflow = 'hidden'; + // Apply fullscreen styles + _V_.addClass(this.box, "vjs-fullscreen"); + // Resize the box, controller, and poster + this.positionAll(); + }, + + // Turn off fullscreen (window) mode + exitFullWindow: function(){ + this.videoIsFullScreen = false; + document.removeEventListener("keydown", this.fullscreenOnEscKey, false); + window.removeEventListener("resize", this.fullscreenOnWindowResize, false); + // Unhide scroll bars. + document.documentElement.style.overflow = this.docOrigOverflow; + // Remove fullscreen styles + _V_.removeClass(this.box, "vjs-fullscreen"); + // Resize the box, controller, and poster to original sizes + this.positionAll(); + }, onError: function(fn){ this.addVideoListener("error", fn); return this; }, onEnded: function(fn){ diff --git a/dev/src/video.js b/dev/src/video.js index 852644c23..0ee5dfccb 100644 --- a/dev/src/video.js +++ b/dev/src/video.js @@ -94,8 +94,10 @@ var VideoJS = JRClass.extend({ /* Local Storage ================================================================================ */ setLocalStorage: function(key, value){ - try { localStorage[key] = value; } - catch(e) { + if (!localStorage) return; + try { + localStorage[key] = value; + } catch(e) { if (e.code == 22 || e.code == 1014) { // Webkit == 22 / Firefox == 1014 this.warning(VideoJS.warnings.localStorageFull); } diff --git a/dev/test.html b/dev/test.html index c18962e2c..4dad673d1 100644 --- a/dev/test.html +++ b/dev/test.html @@ -106,7 +106,7 @@
- +