aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSam Potts <me@sampotts.me>2015-07-12 23:41:56 +1000
committerSam Potts <me@sampotts.me>2015-07-12 23:41:56 +1000
commitc202cc1ffb034e2dcf96ed8dc3bd92a2b6a6f021 (patch)
treed0bd020cbde59aea9bff8891f28ec92dc8ddc467 /src
parent093af22942947809b7805f82bb12ca615c13383c (diff)
downloadplyr-c202cc1ffb034e2dcf96ed8dc3bd92a2b6a6f021.tar.lz
plyr-c202cc1ffb034e2dcf96ed8dc3bd92a2b6a6f021.tar.xz
plyr-c202cc1ffb034e2dcf96ed8dc3bd92a2b6a6f021.zip
More work on YouTube
Diffstat (limited to 'src')
-rw-r--r--src/js/plyr.js32
1 files changed, 19 insertions, 13 deletions
diff --git a/src/js/plyr.js b/src/js/plyr.js
index 4e3a7431..665a8782 100644
--- a/src/js/plyr.js
+++ b/src/js/plyr.js
@@ -866,19 +866,16 @@
// Setup YouTube
function _setupYouTube(id) {
- // Create the YouTube iframe
- var iframe = document.createElement("iframe");
- iframe.src = "https://www.youtube.com/embed/"+ id + "?rel=0&vq=hd720&iv_load_policy=3&controls=0&autoplay=0&showinfo=0&wmode=transparent&enablejsapi=1";
- iframe.id = "youtube" + Math.floor(Math.random() * (10000));
+ // Create the YouTube container
+ var div = document.createElement("div");
+ div.setAttribute("id", "youtube" + Math.floor(Math.random() * (10000)));
+ player.media.appendChild(div);
// Add embed class for responsive
_toggleClass(player.media, config.classes.videoWrapper, true);
_toggleClass(player.media, config.classes.embedWrapper, true);
- // Append the iframe
- player.media.appendChild(iframe);
-
- // Add the API
+ // Load the API
_injectScript("https://www.youtube.com/iframe_api");
// Setup callback for the API
@@ -890,9 +887,20 @@
player.timer = {};
// Setup instance
- player.embed = new YT.Player(iframe.id, {
+ // https://developers.google.com/youtube/iframe_api_reference
+ player.embed = new YT.Player(div.id, {
videoId: id,
- iv_load_policy: 3,
+ playerVars: {
+ autoplay: 0,
+ controls: 0,
+ vq: "hd720",
+ rel: 0,
+ showinfo: 0,
+ iv_load_policy: 3,
+ cc_lang_pref: "en",
+ wmode: "transparent",
+ modestbranding: 1
+ },
events: {
onReady: function(event) {
// Get the instance
@@ -919,7 +927,7 @@
if(player.media.buffered === 1) {
window.clearInterval(player.timer.buffering);
}
- }, 100);
+ }, 200);
_setupInterface();
},
@@ -975,8 +983,6 @@
}
}
});
-
- _log(player.embed);
}
}