gpt4 book ai didi

youtube - 单个页面上的多个 Youtube Chromeless 播放器

转载 作者:行者123 更新时间:2023-12-03 05:21:42 26 4
gpt4 key购买 nike

我正在尝试使用 chromeless 播放器在单个网页中嵌入多个 youtube 视频。这不是同一播放器中的多个视频,而是单个页面上的多个播放器。

这是一个例子。 (只显示最后一个视频):

<div>
<div id="ytapiplayer">
You need Flash player 9+ and JavaScript enabled to view this video.
</div>

<script type="text/javascript">
var params = { allowScriptAccess: "always" };
var atts = { id: "myytplayer" };
swfobject.embedSWF("http://www.youtube.com/apiplayer?enablejsapi=1&version=3&playerapiid=1234","ytapiplayer", "499", "281", "9", null, null, params, atts);
function onYouTubePlayerReady(playerId) {
ytplayer = document.getElementById("myytplayer");
ytplayer.cueVideoById("Zhawgd0REhA");
}

</script>
</div>
<div>
<div id="ytapiplayer2">
You need Flash player 9+ and JavaScript enabled to view this video.
</div>

<script type="text/javascript">
var params = { allowScriptAccess: "always" };
var atts = { id: "myytplayer2" };
swfobject.embedSWF("http://www.youtube.com/apiplayer?enablejsapi=1&version=3&playerapiid=4321","ytapiplayer2", "499", "281", "9", null, null, params, atts);
function onYouTubePlayerReady(playerId) {
ytplayer2 = document.getElementById("myytplayer2");
ytplayer2.cueVideoById("qkAn_qJdgBs");
}

</script>
</div>

任何帮助将不胜感激。

最佳答案

    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script>
<div>
<div id="ytapiplayer">
You need Flash player 9+ and JavaScript enabled to view this video.
</div>

<script type="text/javascript">
var params = { allowScriptAccess: "always" };
var atts = { id: "myytplayer" };
swfobject.embedSWF("http://www.youtube.com/apiplayer?enablejsapi=1&version=3&playerapiid=player1","ytapiplayer", "499", "281", "9", null, null, params, atts);
function onYouTubePlayerReady(playerId) {
if(playerId == "player1"){
ytplayer = document.getElementById("myytplayer");
ytplayer.cueVideoById("H9v3eky91no");
}else{
if(playerId == "player2"){
ytplayer2 = document.getElementById("myytplayer2");
ytplayer2.cueVideoById("EGnwL0ganu0");
}
}
}

</script>
</div>
<div>
<div id="ytapiplayer2">
You need Flash player 9+ and JavaScript enabled to view this video.
</div>

<script type="text/javascript">
var params = { allowScriptAccess: "always" };
var atts = { id: "myytplayer2" };
swfobject.embedSWF("http://www.youtube.com/apiplayer?enablejsapi=1&version=3&playerapiid=player2","ytapiplayer2", "499", "281", "9", null, null, params, atts);
</script>
</div>

关于youtube - 单个页面上的多个 Youtube Chromeless 播放器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2208248/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com