brandly / angular-youtube-embed

:tv: Embed a YouTube player with a simple directive

Home Page:http://brandly.github.io/angular-youtube-embed/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Background Playing when app is "paused"

danielpflood opened this issue · comments

Failed submission to Android Store due to:

Your submission has been rejected for enabling background playing of YouTube videos in violation of the YouTube API Terms of Service.

Should this happen automatically using this plugin? If not does anyone have a recommendation for how to achieve this with an Ionic app?

I am able to detect pausing from the controller with this:


document.addEventListener("pause", function() {
    console.log("The application is pausing");
}, false);
 

But I am not sure how to obtain the video-player object in order to call its pause method. Thanks for your help.

I was able to retrieve the player with this:


    var ytplayer_window = document.getElementById("unique-youtube-embed-id-1").contentWindow;
    var myPlayer = ytplayer_window.yt.player.getPlayerByElement(ytplayer_window.player);

hey daniel! instead of digging into the DOM like that, you can also give the <youtube-video> a player reference, which it will assign the player to.

also, all event handlers get handed the relevant player, so you can access it there as well.

good luck with the Android Store!