From eb5cda3ce03b35c3335b91c34ead0cdf290b243e Mon Sep 17 00:00:00 2001
From: Stuart Knightley
Date: Mon, 19 Mar 2012 09:46:38 -0700
Subject: Update Youtube player to HTML5
---
.../ui/youtube-player.reel/youtube-player.html | 10 ++----
.../ui/youtube-player.reel/youtube-player.js | 38 ++++++++++++----------
2 files changed, 24 insertions(+), 24 deletions(-)
(limited to 'node_modules/montage')
diff --git a/node_modules/montage/ui/youtube-player.reel/youtube-player.html b/node_modules/montage/ui/youtube-player.reel/youtube-player.html
index ae757626..ec61493c 100644
--- a/node_modules/montage/ui/youtube-player.reel/youtube-player.html
+++ b/node_modules/montage/ui/youtube-player.reel/youtube-player.html
@@ -7,23 +7,19 @@
+
-
+
diff --git a/node_modules/montage/ui/youtube-player.reel/youtube-player.js b/node_modules/montage/ui/youtube-player.reel/youtube-player.js
index 2f7709d7..462dca58 100644
--- a/node_modules/montage/ui/youtube-player.reel/youtube-player.js
+++ b/node_modules/montage/ui/youtube-player.reel/youtube-player.js
@@ -1,10 +1,9 @@
-//data="https://www.youtube.com/v/u1zgFlCw8Aw?version=3&enablejsapi=1&playerapiid=ytplayer"
/*
This file contains proprietary software owned by Motorola Mobility, Inc.
No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
*/
-/*global require,exports*/
+/*global require,exports,YT */
var Montage = require("montage").Montage,
Component = require("ui/component").Component;
@@ -31,7 +30,6 @@ var YoutubePlayer = exports.YoutubePlayer = Montage.create(Component, {
return this._player;
},
set: function(value) {
- // TODO don't allow this to be changed
if (this._player !== value) {
this._player = value;
}
@@ -127,30 +125,36 @@ var YoutubePlayer = exports.YoutubePlayer = Montage.create(Component, {
value: function() {
// Create the callback if it doesn't exist, and make it dispatch
// an event on the document instead
- if (!window.onYouTubePlayerReady) {
- window.onYouTubePlayerReady = function(playerId) {
+ if (!window.onYouTubePlayerAPIReady) {
+ window.onYouTubePlayerAPIReady = function() {
var event = document.createEvent("CustomEvent");
- event.initEvent("youtubePlayerReady", true, true);
- event.playerId = playerId;
+ event.initEvent("youtubePlayerApiReady", true, true);
document.dispatchEvent(event);
};
}
- document.addEventListener("youtubePlayerReady", this, false);
+ this._element.src += (this._videoId ? "/" + this._videoId : "") + "?enablejsapi=1";
- // If there's no videoId set one the doesn't exist
- this._player.data = "https://www.youtube.com/v/" + (this._videoId || "xxxxxxxxxxx") + "?version=3&enablejsapi=1&playerapiid=" + this.uuid;
+ if (typeof YT !== "undefined" && YT.Player) {
+ this.handleYoutubePlayerApiReady();
+ } else {
+ document.addEventListener("youtubePlayerApiReady", this, false);
+ }
}
},
- handleYoutubePlayerReady: {
+ handleYoutubePlayerApiReady: {
value: function(event) {
- if (event.playerId !== this.uuid) {
- return;
- }
-
- this._ready = true;
- this.needsDraw = true;
+ console.log("handleYoutubePlayerApiReady");
+ document.removeEventListener("youtubePlayerApiReady", this);
+
+ var self = this;
+ this.player = new YT.Player(this._element, { events: {
+ onReady: function(event) {
+ self._ready = true;
+ self.needsDraw = true;
+ }
+ }});
}
},
--
cgit v1.2.3