YouTube 播放列表 - 随机播放/随机功能
有没有办法嵌入一个 YouTube 播放列表,能够在页面重新加载时随机播放或随机播放?因此,它开始在播放列表中显示一个视频并从该点开始播放,然后当刷新浏览器时,它会播放另一个视频,依此类推。
我可以使用 xml 和第三方视频工具很好地完成此操作,该工具允许我使用随机函数播放 XML,但播放列表中的许多视频都具有受版权保护的音乐,因此必须通过 YouTube 嵌入来播放,否则将无法播放。不工作。
有什么想法吗?我已经尝试这样做了好几个月了。
我在下面附加了一些代码,这些代码是我使用 iFrame 嵌入的,但它会导致 IE 不断刷新并填满我的访问日志,直至崩溃。
<html>
<head>
</head>
<body onLoad="load()" style="background-color:white">
<script type="text/javascript">
var playlisturl = "http://gdata.youtube.com/feeds/api/playlists/D4607BD824235A91?v=2";
var playlisturls = ["http://gdata.youtube.com/feeds/api/playlists/D4607BD824235A91?v=2"];
var pause_playlist_text = "Pause playlist (loop current video)";
var embed = true;
var swf = false;
var autoplay = false;
var vwidth = 275;
var vheight = 270;
</script>
<script type="text/javascript" src="http://youtube-playlist-randomizer.valami.info/seedrandom.js.pagespeed.ce.FBW5lks-2H.js"></script>
<script type="text/javascript" src="http://youtube-playlist-randomizer.valami.info/playlist-min.js.pagespeed.ce.mjzbqx3nYo.js"></script>
<object style="width: 275px; height: 270px">
<param name="movie" value="http://www.youtube.com/v/Yo6dgBCsj2Q?version=3">
<param name="allowFullScreen" value="true">
<param name="allowScriptAccess" value="always">
<embed id="myytplayer" src="http://www.youtube.com/v/Yo6dgBCsj2Q?enablejsapi=1&version=3" type="application/x-shockwave-flash" allowfullscreen="true" allowScriptAccess="always" width="275px" height="270px">
</object>
<p><button class="sexybutton sexysimple sexyblue" id="previousbutton" onClick="previous()"><span class="prev">Previous</span></button>
<button class="sexybutton sexysimple sexyblue" id="nextbutton" onClick="next()"><span class="next after">Next</span></button></p>
<script type="text/javascript">
document.getElementById('pauseplaylist').style.display = "none"
</script>
</body>
</html>
预先非常感谢, 理查德
Is there any way to embed a YouTube playlist that has the ability to shuffle or randomise on the page reload? So, it starts showing one video in the playlist and plays from that point and then when the browser is refreshed, it plays another and so forth.
I can do this fairly well with a xml and third party video tool that allows me to play XMLs with a random function, but a lot of the videos in the playlist has copyrighted music so has to be played through the YouTube embed or it won't work.
Any ideas? I've tried to do this for months and months.
I've attached some code below with what sort of works, which I embedded using an iFrame, but it causes IE to constantly refresh and fill up my access logs to the point where it crashes.
<html>
<head>
</head>
<body onLoad="load()" style="background-color:white">
<script type="text/javascript">
var playlisturl = "http://gdata.youtube.com/feeds/api/playlists/D4607BD824235A91?v=2";
var playlisturls = ["http://gdata.youtube.com/feeds/api/playlists/D4607BD824235A91?v=2"];
var pause_playlist_text = "Pause playlist (loop current video)";
var embed = true;
var swf = false;
var autoplay = false;
var vwidth = 275;
var vheight = 270;
</script>
<script type="text/javascript" src="http://youtube-playlist-randomizer.valami.info/seedrandom.js.pagespeed.ce.FBW5lks-2H.js"></script>
<script type="text/javascript" src="http://youtube-playlist-randomizer.valami.info/playlist-min.js.pagespeed.ce.mjzbqx3nYo.js"></script>
<object style="width: 275px; height: 270px">
<param name="movie" value="http://www.youtube.com/v/Yo6dgBCsj2Q?version=3">
<param name="allowFullScreen" value="true">
<param name="allowScriptAccess" value="always">
<embed id="myytplayer" src="http://www.youtube.com/v/Yo6dgBCsj2Q?enablejsapi=1&version=3" type="application/x-shockwave-flash" allowfullscreen="true" allowScriptAccess="always" width="275px" height="270px">
</object>
<p><button class="sexybutton sexysimple sexyblue" id="previousbutton" onClick="previous()"><span class="prev">Previous</span></button>
<button class="sexybutton sexysimple sexyblue" id="nextbutton" onClick="next()"><span class="next after">Next</span></button></p>
<script type="text/javascript">
document.getElementById('pauseplaylist').style.display = "none"
</script>
</body>
</html>
Many thanks in advance,
Richard
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您在播放器上启用 javascript 控制,则可以使用官方的“随机”功能。
您创建一个额外的按钮用于随机化..
或者创建一个函数让它根据日期、时间、IP 地址等随机化。
它有效..我正在使用它,youtube 称之为“SHUFFLE”,检查 Youtube jS-api 页面:
https ://developers.google.com/youtube/js_api_reference
There´s an official "randomize" function available if you enable javascript-control on your player.
You create an extra button for randomizing..
or create a function to let it randomize depending on date,time.iP-adress...etc.
It works..i´m using it, youtube calls it "SHUFFLE" check the Youtube jS-api pages:
https://developers.google.com/youtube/js_api_reference