Does the youtube player api apply on google drive

2019-08-05 06:34发布

I've been working on a project that uses videos embedded from google drive, it has the same format as a youtube embedded video:

<iframe id="player4" src="https://docs.google.com/a/insynchq.com/file/d/{{ videos.folders }}/preview?enablejsapi=1&playerapiid=player4" width="500px" height="400px" frameborder="0" allowfullscreen></iframe>

I imported this as said by the api:

var tag = document.createElement('script');
tag.src = "https://www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);

but I don't know if the youtube player api works on it. I've tried sort of things following the api but didn't get much of a result. I want to pause the videos on slide change that's why I want to know if it works on drive embedded videos. I would want to get the player instance but document.getElementById just results in getting the iframes which does not enable me to pause the video in it, or is there a way that I may have not discovered yet?

Any help will be much appreciated. Thanks!

2条回答
乱世女痞
2楼-- · 2019-08-05 07:15

No, videos on Google Drive are not currently hosted on YouTube, though the player may share a similar source code ancestor. Perhaps you should investigate listing the video on YouTube as "unlisted" instead - you should be able to embed the video and use the official API.

查看更多
Bombasti
3楼-- · 2019-08-05 07:28

You could use as src something like this:

https://youtube.googleapis.com/embed/?partnerid=30&docid=<video file id>

This will make your video playable but won't be listed or uploaded to Youtube

查看更多
登录 后发表回答