单击链接时替换gdata播放列表提要中的播放列表id

Replacing the playlist id in gdata playlist feed when a link is clicked

本文关键字:播放列表 id 单击 替换 gdata 链接      更新时间:2023-09-26

我正在使用gdata播放列表提要来获取播放列表中的所有视频,并将其显示在我的网站上。下面是使用gdata播放列表提要的JavaScript函数。我想在点击链接时用另一个播放列表id替换播放列表id,这样视频也会被替换。

$(function() {
$('#ytVideoGallery').ytVideoGallery({
    feedUrl: 'http://gdata.youtube.com/feeds/api/playlists/9EA41FFD2282B969',
       playerOptions: {
        rel: '0',
        wmode: 'opaque'
       },
      playerWidth: 640,
      playerHeight: 360
   }); 
});

您可以将选项保存到变量中

   var options = {
    feedUrl: 'http://gdata.youtube.com/feeds/api/playlists/9EA41FFD2282B969',
       playerOptions: {
        rel: '0',
        wmode: 'opaque'
       },
      playerWidth: 640,
      playerHeight: 360
   };
$(function() {
  $('#ytVideoGallery').ytVideoGallery(options);
});

点击后,你可以将其附加到另一个元素:

$("#some_element").click(function(){
  $(this).ytVideoGallery(options);
  $('#ytVideoGallery').remove(); // You can remove previous element.
});