0
我在想如何替換函數中的變量並用另一個函數調用該函數。我正在製作一個可顯示視頻的YouTube視頻。我想在用戶點擊時加載一個函數。我已經在調用將顯示播放列表的功能,但是我想在點擊導航鏈接時顯示另一個播放列表。我想更改加載特定提要的變量。任何幫助將非常感激。謝謝如何用另一個函數替換局部變量來調用函數
<script type="text/javascript">
var feedUrl = "";
function loadFeedAPI() {
google.load("feeds", "1");
google.setOnLoadCallback(initialize);
}
function playVideo() {
//Examples of how to assign the Colorbox event to elements
$(".youtubeThumb").colorbox({ iframe: true, innerWidth: 640, innerHeight: 390 });
};
function initialize(feedUrl) {
$(".youtubeFeed").empty();
feedUrl = "http://gdata.youtube.com/feeds/api/playlists/PLlVlyGVtvuVlzDWbR0rXf1YnpJ9JL74FV";
new google.feeds.lookupFeed(feedUrl, function (result) {
if (result.error || !result.url) {
$('#videocomm').hide();
return;
}
// get the feed items
var feed = new google.feeds.Feed(result.url);
feed.setNumEntries(25);
feed.load(function (result) {
// write out the feed data
var container = $(".youtubeFeed");
var totalcount = result.feed.entries.length;
for (var i = 0; i < result.feed.entries.length; i++) {
var entry = result.feed.entries[i];
var vidhash = /=(.*)&(.*)$/.exec(entry.link)[1];
var videoParmeters = "?rel=0&autohide=1&showinfo=0&autoplay=1&modestbranding=1&?vq=hd1080;wmode=transparent";
var VidTitleMaxLength = 42;
var countVidTitleLength = entry.title.valueOf().length;
var joinName = entry.title.split(/[ ,]+/).join('');
var joinNameLength = joinName.valueOf().length;
var strtemp = entry.title.substr(0, VidTitleMaxLength) + "...";
console.log(strtemp + joinNameLength);
container.append('<li><div><a class="youtubeThumb" href="http://www.youtube.com/embed/' + vidhash + videoParmeters + '" title="' + entry.title + '"><img src="https://img.youtube.com/vi/' + vidhash + '/2.jpg" /><br />' + '<p class="videoTitle">' + strtemp + '</p>' + '</a></div></li>\n');
}
playVideo();
});
});
}
function loadTest(feedUrl) {
feedUrl.initialize("http://gdata.youtube.com/feeds/api/playlists/PLlVlyGVtvuVnAg43cejh4HGzap_MPRNhV");
alert("hi");
return false;
}
loadFeedAPI();
</script>
<div id="navigation">
<ul id="tsSideNavUL">
<li><a href="javascript:initialize();">The Roots of Our Vine</a></li>
<li><a href="javascript:loadTest();">A Soiree From Start to Finish</a></li>
<li><a href="#">Booking</a></li>
<li><a href="#">Selling</a></li>
<li><a href="#">Enrolling</a></li>
</ul>
</div>
得到一個錯誤...無法讀取未定義的屬性'lookupFeed' – user2512393
nvrmind得到它的工作。只是有問題現在顯示它到容器 – user2512393
我不想有一個關於追加的新部分。但現在我遇到問題的視頻附加到容器。有任何想法嗎? – user2512393