开发者

Youtube "end=" embed tag not working?

开发者 https://www.devze.com 2023-04-01 03:29 出处:网络
I am trying to embed a Youtube video on my site with specific start and end times. Sites such as snipsnip.it and splicd.com use the start= and end= tags in the iframe src like so:

I am trying to embed a Youtube video on my site with specific start and end times. Sites such as snipsnip.it and splicd.com use the start= and end= tags in the iframe src like so:

<iframe src='http://www.youtube.com/embed/OwjfE2ylbWU?start=5&end=10' width='640' height='360'>
</iframe> 
开发者_如何学Python

However, this does not work on my web page. The video starts at the right time but then just plays till the end of the video. The Youtube API states that there is no "end=" tag, yet these sites all use it successfully.

Any idea on how to get embedded Youtube videos to end at a specific point?


splicd.com doesn't actually depend on the YouTube to stop the video. They poll the player with the following JavaScript and the YouTube Player API:

function checkYouTubePlayHead()
{
  current = player.getCurrentTime();
  if((current >= end) && splice) {
    player.seekTo(start, true);=
    player.pauseVideo();
  }
  if(current > start)
    played = true;
}


It was working before without any js to implement, youtube just changed to googleapis video repository 2 days ago, and that messed up the end tag. It'll be fixed soon hopefully, not you're the only one, who need a solution for this. So far, this worked fine:

http://www.youtube.com/v/81hChAAt3So&start=107&end=115s&autoplay=0&autohide=0&theme=dark&color=white&rel=0&modestbranding=1&showinfo=0

Now most of the parameters are not passed. Be patient :)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号