Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Cleaner handling of player init params and added a new ytcontrols par…

…am to use the native YouTube player controls
  • Loading branch information...
commit ca916fb89c2e9eaf94b994d3c8dcaba45ec7912d 1 parent 03efd3d
John Hurliman authored
Showing with 14 additions and 8 deletions.
  1. +1 −1  build/release-files/youtube.html
  2. +13 −7 src/tech.js
2  build/release-files/youtube.html
View
@@ -12,7 +12,7 @@
<body>
<video id="example_video_1" class="video-js vjs-default-skin" controls preload="none" width="640" height="360"
- data-setup='{"techOrder":["youtube","html5"]}'>
+ data-setup='{"techOrder":["youtube","html5"],"ytcontrols":false}'>
<source src="http://www.youtube.com/watch?v=qWjzVHG9T1I" type='video/youtube' />
</video>
20 src/tech.js
View
@@ -728,12 +728,11 @@ _V_.youtube = _V_.PlaybackTech.extend({
_V_.youtube.loadingEls = _V_.youtube.loadingEls || [];
_V_.youtube.loadingEls.push(parentEl);
- // Store player options in local var for optimization
var playerOptions = player.options;
+ var optionsParams = options.params || {};
// Merge default player parameters with init params
- var params = _V_.merge({
- controls: 0,
+ var params = {
disablekb: 1,
enablejsapi: 1,
iv_load_policy: 3,
@@ -743,10 +742,13 @@ _V_.youtube = _V_.PlaybackTech.extend({
rel: 0,
showinfo: 0,
showsearch: 0,
- autoplay: playerOptions.autoplay ? 1 : 0,
- loop: playerOptions.loop ? 1 : 0,
- hd: 0,
- }, options.params);
+ };
+
+ // Make sure the configurable params are 1 or 0
+ params.controls = this.toBoolInt(optionsParams.ytcontrols || playerOptions.ytcontrols);
+ params.autoplay = this.toBoolInt(optionsParams.autoplay || playerOptions.autoplay);
+ params.loop = this.toBoolInt(optionsParams.loop || playerOptions.loop);
+ params.hd = this.toBoolInt(optionsParams.hd || playerOptions.hd);
var p = (document.location.protocol == 'https:') ? 'https:' : 'http:';
@@ -876,6 +878,10 @@ _V_.youtube = _V_.PlaybackTech.extend({
return url.match(/v=([^&]+)/)[1];
},
+ toBoolInt: function(val) {
+ return val ? 1 : 0;
+ },
+
loadApi: function() {
// Check if the YouTube JS API has already been loaded
var js, id = "youtube-jssdk", ref = document.getElementsByTagName("script")[0];
Please sign in to comment.
Something went wrong with that request. Please try again.