假设我有一个YouTube视频列表
https://www.youtube.com/watch?v=stYNW4ub5mk https://www.youtube.com/watch?v=Zvjmt4pwtdg ..... .....
我怎样才能一一播放他们,然后重复,例如
for j= 1 to 999999999 for i = 0 to n '(where n is number of videos) 'play video i 'how can I tell the ith one ended and to play the next one? next i next j我在自己的网页上使用什么控制语法播放视频(全尺寸)?
谢谢
Say I have a list of youtube videos
https://www.youtube.com/watch?v=stYNW4ub5mk https://www.youtube.com/watch?v=Zvjmt4pwtdg ..... .....
How can I play them one by one and then repeat, eg
for j= 1 to 999999999 for i = 0 to n '(where n is number of videos) 'play video i 'how can I tell the ith one ended and to play the next one? next i next jWhat control, syntax do I use to play the video in my own web page (full size)?
thanks
最满意答案
使用YouTube播放器API。 (youtube.com/player_api)它处理与嵌入的YouTube视频的交互。 要检测视频何时结束,请检查onPlayerStateChange事件。 你可以添加一个脚本部分到你的html并包含这个:
编辑 :event.data === 1是播放器启动时,无论是单击还是自动启动event.data === 0是视频完成时。
function onPlayerStateChange(event) { if(event.data === 1) { #doSomething } if(event.data === 0) { #callMethodToIncrementVideo } }Use the YouTube player API. (youtube.com/player_api) It handles interactions with embedded YouTube videos. To detect when a video ends, check for the onPlayerStateChange event. You can add a script section to your html and include this:
edit: event.data === 1 is when the player starts, either when it is clicked or if it automatically starts event.data === 0 is when the video is done.
function onPlayerStateChange(event) { if(event.data === 1) { #doSomething } if(event.data === 0) { #callMethodToIncrementVideo } }更多推荐
发布评论