Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
202 views
in Technique[技术] by (71.8m points)

YouTube embed start at specific time not working

I have the following YouTube embed code, to start a video at a specific time. It used to work a few weeks ago, but it's not working now:

<iframe src="https://www.youtube-nocookie.com/embed/A2_yg19Pu7Y?start=150&version=3&rel=0&modestbranding=1&autoplay=1&loop=1&playlist=A2_yg19Pu7Y" allow="autoplay;accelerometer;clipboard-write;encrypted-media;gyroscope;picture-in-picture" allowfullscreen="" width="1092.8" height="614.7" frameborder="0"></iframe>

The video is supposed to start at 2m 30s, but it starts from the beginning.

Did something change on YouTube side in the past few weeks?

EDIT: It appears, when the embed link contains the playlist parameter (needed for looping the video - https://developers.google.com/youtube/player_parameters#loop), the video does not start from the specified time, it starts from the beginning instead. I need to keep the playlist parameter, but also start the video at the given start time.

question from:https://stackoverflow.com/questions/65932410/youtube-embed-start-at-specific-time-not-working

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

To answer your question, I don't think anything changed on YouTube's side.

I went to your link:

https://www.youtube-nocookie.com/embed/A2_yg19Pu7Y?start=150&version=3&rel=0&modestbranding=1&autoplay=1&loop=1&playlist=A2_yg19Pu7Y" allow="autoplay;accelerometer;clipboard-write;encrypted-media;gyroscope;picture-in-picture

And it started at 2:30, like you wanted. That being said, you have a blank space between ...playlist=A2_yg19Pu7Y" and allow="autoplay..., and it looks like your double quotes may be escaping the string. Try deleting that blank space and your video will hopefully work!

Edit: I just did a little research and found that "allow" is an HTML attribute, so the link should probably work as it is at the moment. That being said, if you haven't tested it already, then you should try the whole link as one string for the src= attribute to make sure its working.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...