Compare commits

...

5 Commits

Author SHA1 Message Date
Sam Potts e89e87de62 Prevent poster being downloaded twice 2015-02-17 23:40:57 +11:00
Sam Potts b7ea8c3875 Merge 2015-02-17 23:18:03 +11:00
Sam Potts a67e495910 Merge branch 'master' of github.com:selz/plyr
Conflicts:
	dist/js/plyr.js
2015-02-17 23:17:39 +11:00
Sam Potts 97d6216409 Removed XHR for IE8 2015-02-17 23:17:15 +11:00
Sam Potts c55faa3505 Added OGG to <audio> example, Fixed IE11 Fullscreen 2015-02-17 22:57:00 +11:00
3 changed files with 25 additions and 23 deletions
+22 -19
View File
@@ -247,9 +247,14 @@
for (var i = 0, il = browserPrefixes.length; i < il; i++ ) { for (var i = 0, il = browserPrefixes.length; i < il; i++ ) {
fullscreen.prefix = browserPrefixes[i]; fullscreen.prefix = browserPrefixes[i];
if (typeof document[fullscreen.prefix + "CancelFullScreen" ] != "undefined" ) { if (typeof document[fullscreen.prefix + "CancelFullScreen"] != "undefined") {
fullscreen.supportsFullScreen = true;
break;
}
// Special case for MS (when isn't it?)
else if (typeof document.msExitFullscreen != "undefined" && document.msFullscreenEnabled) {
fullscreen.prefix = "ms";
fullscreen.supportsFullScreen = true; fullscreen.supportsFullScreen = true;
break; break;
} }
} }
@@ -271,15 +276,20 @@
return document.fullScreen; return document.fullScreen;
case "webkit": case "webkit":
return document.webkitIsFullScreen; return document.webkitIsFullScreen;
case "ms":
// Docs say document.msFullScreenElement returns undefined
// if no element is full screem but it returns null, cheers
// https://msdn.microsoft.com/en-us/library/ie/dn265028%28v=vs.85%29.aspx
return (document.msFullscreenElement !== null);
default: default:
return document[this.prefix + "FullScreen"]; return document[this.prefix + "FullScreen"];
} }
}; };
fullscreen.requestFullScreen = function(element) { fullscreen.requestFullScreen = function(element) {
return (this.prefix === "") ? element.requestFullScreen() : element[this.prefix + "RequestFullScreen"](this.prefix === "webkit" ? element.ALLOW_KEYBOARD_INPUT : null); return (this.prefix === "") ? element.requestFullScreen() : element[this.prefix + (this.prefix == "ms" ? "RequestFullscreen" : "RequestFullScreen")](this.prefix === "webkit" ? element.ALLOW_KEYBOARD_INPUT : null);
}; };
fullscreen.cancelFullScreen = function() { fullscreen.cancelFullScreen = function() {
return (this.prefix === "") ? document.cancelFullScreen() : document[this.prefix + "CancelFullScreen"](); return (this.prefix === "") ? document.cancelFullScreen() : document[this.prefix + (this.prefix == "ms" ? "ExitFullscreen" : "CancelFullScreen")]();
}; };
fullscreen.element = function() { fullscreen.element = function() {
return (this.prefix === "") ? document.fullscreenElement : document[this.prefix + "FullscreenElement"]; return (this.prefix === "") ? document.fullscreenElement : document[this.prefix + "FullscreenElement"];
@@ -561,30 +571,23 @@
if (captionSrc !== "") { if (captionSrc !== "") {
// Create XMLHttpRequest Object // Create XMLHttpRequest Object
var xhr; var xhr = new XMLHttpRequest();
if (window.XMLHttpRequest) {
xhr = new XMLHttpRequest();
}
else if (window.ActiveXObject) { // IE8
xhr = new ActiveXObject("Microsoft.XMLHTTP");
}
xhr.onreadystatechange = function() { xhr.onreadystatechange = function() {
if (xhr.readyState === 4) { if (xhr.readyState === 4) {
if (xhr.status === 200) { if (xhr.status === 200) {
if (config.debug) {
console.log("xhr = 200");
}
player.captions = []; player.captions = [];
var records = [], var records = [],
record, record,
req = xhr.responseText; req = xhr.responseText;
records = req.split("\n\n"); records = req.split("\n\n");
for (var r=0; r < records.length; r++) { for (var r=0; r < records.length; r++) {
record = records[r]; record = records[r];
player.captions[r] = []; player.captions[r] = [];
player.captions[r] = record.split("\n"); player.captions[r] = record.split("\n");
} }
// Remove first element ("VTT") // Remove first element ("VTT")
player.captions.shift(); player.captions.shift();
@@ -592,14 +595,14 @@
console.log("Successfully loaded the caption file via ajax."); console.log("Successfully loaded the caption file via ajax.");
} }
} }
else { else if (config.debug) {
if (config.debug) { console.error("There was a problem loading the caption file via ajax.");
console.log("There was a problem loading the caption file via ajax.");
}
} }
} }
} }
xhr.open("get", captionSrc, true); xhr.open("get", captionSrc, true);
xhr.send(); xhr.send();
} }
} }
+1 -1
View File
File diff suppressed because one or more lines are too long
+2 -3
View File
@@ -30,9 +30,7 @@
<!-- Fallback for browsers that don't support the <video> element --> <!-- Fallback for browsers that don't support the <video> element -->
<div> <div>
<a href="//cdn.sampotts.me/plyr/movie.mp4"> <a href="//cdn.sampotts.me/plyr/movie.mp4">Download</a>
<img src="//cdn.sampotts.me/plyr/poster.jpg" alt="Download">
</a>
</div> </div>
</video> </video>
</div> </div>
@@ -44,6 +42,7 @@
<audio controls> <audio controls>
<!-- Audio files --> <!-- Audio files -->
<source src="//cdn.sampotts.me/plyr/logistics-96-sample.mp3" type="audio/mp3"> <source src="//cdn.sampotts.me/plyr/logistics-96-sample.mp3" type="audio/mp3">
<source src="//cdn.sampotts.me/plyr/logistics-96-sample.ogg" type="application/ogg">
<!-- Fallback for browsers that don't support the <audio> element --> <!-- Fallback for browsers that don't support the <audio> element -->
<div> <div>