Browse Source

Fix to allow multiple instances of same youtube video in different events. closes #153

pull/162/head
Zach Wise 13 years ago
parent
commit
339c8ed03f
  1. 32
      source/js/Media/VMM.ExternalAPI.js
  2. 6
      source/js/Media/VMM.MediaElement.js

32
source/js/Media/VMM.ExternalAPI.js

@ -967,13 +967,13 @@ if(typeof VMM != 'undefined' && typeof VMM.ExternalAPI == 'undefined') {
youtube: { youtube: {
get: function(id) { get: function(mid, id) {
var url = "http://gdata.youtube.com/feeds/api/videos/" + id + "?v=2&alt=jsonc&callback=?"; var the_url = "http://gdata.youtube.com/feeds/api/videos/" + mid + "?v=2&alt=jsonc&callback=?",
vid = {mid: mid, id: id};
VMM.master_config.youtube.que.push(vid);
if (VMM.master_config.youtube.active) { if (!VMM.master_config.youtube.active) {
VMM.master_config.youtube.que.push(id);
} else {
VMM.master_config.youtube.que.push(id);
if (!VMM.master_config.youtube.api_loaded) { if (!VMM.master_config.youtube.api_loaded) {
VMM.LoadLib.js('http://www.youtube.com/player_api', function() { VMM.LoadLib.js('http://www.youtube.com/player_api', function() {
trace("YouTube API Library Loaded"); trace("YouTube API Library Loaded");
@ -982,19 +982,22 @@ if(typeof VMM != 'undefined' && typeof VMM.ExternalAPI == 'undefined') {
} }
// THUMBNAIL // THUMBNAIL
VMM.getJSON(url, VMM.ExternalAPI.youtube.createThumb); VMM.getJSON(the_url, function(d) {
VMM.ExternalAPI.youtube.createThumb(d, vid)
});
}, },
create: function(id) { create: function(vid) {
var p = { var p = {
active: false, active: false,
player: {}, player: {},
name: 'youtube_'+id, name: 'youtube_'+vid.id,
playing: false playing: false
}; };
p.player['youtube_'+id] = new YT.Player('youtube_'+id, { p.player['youtube_'+vid.id] = new YT.Player('youtube_'+vid.id, {
height: '390', height: '390',
width: '640', width: '640',
playerVars: { playerVars: {
@ -1004,7 +1007,7 @@ if(typeof VMM != 'undefined' && typeof VMM.ExternalAPI == 'undefined') {
theme: 'light', theme: 'light',
rel: 0 rel: 0
}, },
videoId: id, videoId: vid.mid,
events: { events: {
'onReady': VMM.ExternalAPI.youtube.onPlayerReady, 'onReady': VMM.ExternalAPI.youtube.onPlayerReady,
'onStateChange': VMM.ExternalAPI.youtube.onStateChange 'onStateChange': VMM.ExternalAPI.youtube.onStateChange
@ -1014,9 +1017,12 @@ if(typeof VMM != 'undefined' && typeof VMM.ExternalAPI == 'undefined') {
VMM.master_config.youtube.array.push(p); VMM.master_config.youtube.array.push(p);
}, },
createThumb: function(d) { createThumb: function(d, vid) {
trace("CREATE THUMB");
trace(d);
trace(vid);
if (typeof d.data != 'undefined') { if (typeof d.data != 'undefined') {
var thumb_id = "youtube_" + d.data.id + "_thumb"; var thumb_id = "youtube_" + vid.id + "_thumb";
VMM.attachElement("#" + thumb_id, "<img src='" + d.data.thumbnail.sqDefault + "'>"); VMM.attachElement("#" + thumb_id, "<img src='" + d.data.thumbnail.sqDefault + "'>");
} }

6
source/js/Media/VMM.MediaElement.js

@ -33,7 +33,7 @@ if(typeof VMM != 'undefined' && typeof VMM.MediaElement == 'undefined') {
mediaElem = "<div class='thumbnail thumb-instagram' id='instagram_" + m.id + "_thumb'><img src='" + VMM.ExternalAPI.instagram.get(m.id, true) + "'></div>"; mediaElem = "<div class='thumbnail thumb-instagram' id='instagram_" + m.id + "_thumb'><img src='" + VMM.ExternalAPI.instagram.get(m.id, true) + "'></div>";
return mediaElem; return mediaElem;
} else if (m.type == "youtube") { } else if (m.type == "youtube") {
mediaElem = "<div class='thumbnail thumb-youtube' id='youtube_" + m.id + "_thumb'></div>"; mediaElem = "<div class='thumbnail thumb-youtube' id='youtube_" + uid + "_thumb'></div>";
return mediaElem; return mediaElem;
} else if (m.type == "googledoc") { } else if (m.type == "googledoc") {
mediaElem = "<div class='thumbnail thumb-document'></div>"; mediaElem = "<div class='thumbnail thumb-document'></div>";
@ -120,8 +120,8 @@ if(typeof VMM != 'undefined' && typeof VMM.MediaElement == 'undefined') {
VMM.ExternalAPI.googledocs.get(m.id, uid); VMM.ExternalAPI.googledocs.get(m.id, uid);
// YOUTUBE // YOUTUBE
} else if (m.type == "youtube") { } else if (m.type == "youtube") {
mediaElem = "<div class='media-shadow'><div class='media-frame video youtube' id='youtube_" + m.id + "'>" + loading_messege + "</div></div>"; mediaElem = "<div class='media-shadow'><div class='media-frame video youtube' id='youtube_" + uid + "'>" + loading_messege + "</div></div>";
VMM.ExternalAPI.youtube.get(m.id); VMM.ExternalAPI.youtube.get(m.id, uid);
// VIMEO // VIMEO
} else if (m.type == "vimeo") { } else if (m.type == "vimeo") {
mediaElem = "<div class='media-shadow'><iframe class='media-frame video vimeo' autostart='false' frameborder='0' width='100%' height='100%' src='http://player.vimeo.com/video/" + m.id + "?title=0&amp;byline=0&amp;portrait=0&amp;color=ffffff'></iframe></div>"; mediaElem = "<div class='media-shadow'><iframe class='media-frame video vimeo' autostart='false' frameborder='0' width='100%' height='100%' src='http://player.vimeo.com/video/" + m.id + "?title=0&amp;byline=0&amp;portrait=0&amp;color=ffffff'></iframe></div>";

Loading…
Cancel
Save