Change youtube video ID without page reloading

回眸只為那壹抹淺笑 提交于 2019-12-06 04:08:58

Despite the videoId being YgGzAKP_HuMif you inspect the <video> you will see something like that:

<video class="video-stream html5-main-video" src="blob:https://www.youtube.com/8e1ef216-1901-ec44-9b76-ea8276e368c6"></video>

You need to find how youtube create their Blob from a videoId and change the src of the player if you want to avoid reloading the page.

But maybe for your project you should think about using the IFrame Player API. It does exactly what you want. And if you want to stay on youtube.com you can replace the youtube original player by an iframe in the DOM.

Good Luck!

it appears that there is no (public) api for the player on youtube :/ but there is one for the iframe youtube player - there you can just call

player.loadVideoById("Vw4KVoEVcr0", 0, "default");

for details see https://developers.google.com/youtube/iframe_api_reference#loadVideoById

That is a quick example I found where you see it in action: http://jsfiddle.net/QtBlueWaffle/8bpQ8/1/

If you really want to directly modify youtube you probably have to dig around in the obfuscated code :/ I tried to find it... but it's obfuscated so you can't easily find it. And even if you find it it will be something like _yt_player.h.xx.xy.h(). Also whenever it will be generated new (and maybe even it is even different for countries... ) your code may break.

Also, it appears to have nothing to do with polymer as there is a player element but it does not have a function to change the video. Apparently, it is only to place the player... control still resides within the js function.

I'm sorry to not have any better news - maybe someone else knows more.

Trying to find a hidden YouTube API is incredibly difficult and it's likely that the next tweak Google makes to YouTube will break your bookmarklet and you'd be back where you started. I think you should take another route altogether. Google provides an API to create, delete, and otherwise manipulate YouTube playlists here: https://developers.google.com/youtube/v3/docs/playlists.

If you’ve never used YouTube API before, see here: https://developers.google.com/youtube/v3/getting-started

Then, (finally!) you can write some JavaScript that creates YouTube playlists from reddit at your command.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!