Index: main/plugin-inlinemedia/i18n/messages_en.xml
===================================================================
--- main/plugin-inlinemedia/i18n/messages_en.xml (revision 32758)
+++ main/plugin-inlinemedia/i18n/messages_en.xml (working copy)
@@ -91,6 +91,8 @@
Service title
Playlist id
YouTube playlist identifier.<br/><i>eg: PL60F2C71234567895</i>
+ API key
+ YouTube API key which could be find in Google developer console.
Width
Video player width in pixels.<br/>if empty, the default width of 400px will be used.
Height
Index: main/plugin-inlinemedia/i18n/messages_fr.xml
===================================================================
--- main/plugin-inlinemedia/i18n/messages_fr.xml (revision 32758)
+++ main/plugin-inlinemedia/i18n/messages_fr.xml (working copy)
@@ -91,6 +91,8 @@
Titre du service
Identifiant de la playlist
Identifiant de la playlist YouTube<br/><i>ex: PL60F2C71234567895</i>
+ Clé de l'API
+ Clé de l'API YouTube qui se trouve dans la console développeur de Google.
Largeur
Largeur du lecteur en pixels.<br/>Si vide, la largeur par défaut (400px) sera utilisée.
Hauteur
Index: main/plugin-inlinemedia/pages/services/youtubegallery/youtubegallery_1.4.xsl
===================================================================
--- main/plugin-inlinemedia/pages/services/youtubegallery/youtubegallery_1.4.xsl (revision 32758)
+++ main/plugin-inlinemedia/pages/services/youtubegallery/youtubegallery_1.4.xsl (working copy)
@@ -20,13 +20,13 @@
xmlns:resolver="org.ametys.cms.transformation.xslt.ResolveURIComponent"
xmlns:ametys="org.ametys.web.transformation.xslt.AmetysXSLTHelper"
xmlns:math="http://exslt.org/math"
- xmlns:yt="http://gdata.youtube.com/schemas/2007"
exclude-result-prefixes="resolver math">
+
light
color
@@ -92,7 +92,7 @@
function onready_ ()
{
- displayPlayList ('', '');
+ displayPlayList ('', '', '');
}
$j(document).ready(function() {
@@ -120,7 +120,7 @@
//hide iframe
document.getElementById("player_").style.display='none';
- displayPlayList ('_old', '');
+ displayPlayList ('_old', '', '');
}
$j(document).ready(onready__old);
@@ -128,7 +128,7 @@
// HTML5 not supported mode
loadPlayerWithNoHTML5Support__old = function ()
{
- createSWFObjectPlayer ('_old', '', , , '', '');
+ createSWFObjectPlayer ('_old', '', '',, , '', '');
}
google.setOnLoadCallback(loadPlayerWithNoHTML5Support__old);
Index: main/plugin-inlinemedia/plugin.xml
===================================================================
--- main/plugin-inlinemedia/plugin.xml (revision 32758)
+++ main/plugin-inlinemedia/plugin.xml (working copy)
@@ -438,6 +438,13 @@
+
+
+ PLUGINS_INLINEMEDIA_SERVICE_VIDEOYOUTUBEGALLERY_APIKEY_DESC
+
+
+
+
PLUGINS_INLINEMEDIA_SERVICE_VIDEOYOUTUBEGALLERY_WIDTH_DESC
Index: main/plugin-inlinemedia/resources/js/playlist.js
===================================================================
--- main/plugin-inlinemedia/resources/js/playlist.js (revision 32758)
+++ main/plugin-inlinemedia/resources/js/playlist.js (working copy)
@@ -43,7 +43,7 @@
}
}
-function displayPlayList (uniqueId, playlistId)
+function displayPlayList (uniqueId, playlistId, apiKey)
{
var divPlayer = $j('#player_' + uniqueId);
var w = divPlayer.parent().width();
@@ -67,42 +67,27 @@
}
list.show();
- addVideos (uniqueId, playlistId, 1);
+ addVideos (uniqueId, playlistId, apiKey, null);
}
-function addVideos (uniqueId, playlistId, startIndex)
+function addVideos (uniqueId, playlistId, apiKey, pageToken)
{
- var playlistURL = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//gdata.youtube.com/feeds/api/playlists/' + playlistId + '?v=2&alt=json&start-index=' + startIndex + '&max-results=50&callback=?';
+ var playlistURL = 'https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&maxResults=50&playlistId=' + playlistId + '&key=' + apiKey;
+ if (pageToken != null)
+ {
+ playlistURL += "&pageToken=" + pageToken;
+ }
$j.getJSON(playlistURL, function(data)
{
- var datas = false;
- if (data.feed.entry != null)
+ if (data.items != null)
{
- $j.each(data.feed.entry, function(i, item)
+ $j.each(data.items, function(i, item)
{
- datas = true;
- var title = item.title.$t.replace("\'","'").replace("\"",""");
- var duration = item.media$group.yt$duration.seconds;
- var secondes = duration % 60;
- if (secondes < 10)
- {
- secondes = '0' + secondes;
- }
- var minutes = ((duration-secondes)/60) % 60;
- if (minutes < 10)
- {
- minutes = '0' + minutes;
- }
- var heures = (duration-minutes * 60 - secondes) / 3600;
- var temps = minutes + "m" + secondes;
- if (heures > 0)
- {
- temps = heures + "h" + temps;
- }
- var videoID = item.media$group.yt$videoid.$t;
- var thumb = "http://img.youtube.com/vi/"+ videoID +"/default.jpg";
- var position = item.yt$position.$t - 1;
+ var title = item.snippet.title.replace(/'/g,"'").replace(/"/g,""");
+ var videoID = item.snippet.resourceId.videoId;
+ var thumb = item.snippet.thumbnails.default.url;
+ var position = item.snippet.position;
var playlistUniqueId = uniqueId;
if(uniqueId.indexOf('_old') != -1)
@@ -110,13 +95,20 @@
playlistUniqueId = uniqueId.substring(0, uniqueId.indexOf('_old'));
}
+ var videoData = $j.ajax({
+ url: 'https://www.googleapis.com/youtube/v3/videos?id=' + videoID + '&part=contentDetails&key=' + apiKey,
+ dataType : "json",
+ async: false
+ }).always();
+ var temps = $j.parseJSON(videoData.responseText).items[0].contentDetails.duration;
+ temps = temps.substring(2).toLowerCase();
$j('#playlist_' + playlistUniqueId).append("" + title + "" + temps + "");
});
}
- if (datas)
+ if (data.nextPageToken)
{
- addVideos (uniqueId, playlistId, startIndex + 50);
+ addVideos (uniqueId, playlistId, apiKey, data.nextPageToken);
}
});
}
@@ -134,17 +126,17 @@
}
// This function is called instead of onYouTubeIframeAPIReady, if HTML5 postMessage function is not supported
-function createSWFObjectPlayer (uniqueId, playlistID, playerWidth, playerHeight, theme, color)
+function createSWFObjectPlayer (uniqueId, playlistID, apiKey, playerWidth, playerHeight, theme, color)
{
- var playlistURL = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//gdata.youtube.com/feeds/api/playlists/' + playlistID + '?v=2&alt=json&start-index=1&max-results=1&callback=?';
+ var playlistURL = 'https://www.googleapis.com/youtube/v3/playlistItems?part=contentDetails&maxResults=1&playlistId=' + playlistId + '&key=' + apiKey;
$j.getJSON(playlistURL, function(data)
{
var videoID = "";
- if (data.feed.entry != null && data.feed.entry.length > 0)
+ if (data.items != null && data.items.length > 0)
{
- var item = data.feed.entry[0];
+ var item = data.items[0];
- videoID = item.media$group.yt$videoid.$t;
+ videoID = item.videoId;
}
var params = { allowScriptAccess: "always" };