I have an Ionic app that I want to deploy to the Android games store, my app just has a list of videos in tab 1, and then when you click on 1 from the video, it plays the video in another tab using an iframe like this
<div class="video-container"> <iframe id="VideoPlayer" ng-src="{{getIframeSrc(videoid)}}" frameborder="0" width="560" height="315" allowfullscreen></iframe> </div>
It all works great. The problem is related to the YoutubeAPI policy on the Google Play Store, which you do not allow your application to play video or audio on YouTube, for example, when you minimize your application or switch to another tab.
What is the best way to achieve this? I need to make sure that when you minimize or switch to another tab, this will stop the YouTube video from playing with the iframe if the user has not stopped it on their own.
******* UPDATE ********
Now I can stop the video by calling this function with the button
$scope.stopVideo = function() { var iframe = document.getElementsByTagName("iframe")[0].contentWindow; iframe.postMessage('{"event":"command","func":"' + 'stopVideo' + '","args":""}', '*'); }
However, this only works when I test it with Ionic Serve, if I run the same code on an Android phone, I get Reference Error: Div Not Defined. Not sure why this will work in the browser, but not in the application when it runs on Android.
I also need to understand in Ionic how to call this function for each scenario where you cannot watch the application, so to close the application in the background, by going to a new tab, press the return button ... Is there any way to add this function to call all these scenarios?
angularjs youtube-api ionic-framework ionic
musician2000 Jun 02 '15 at 11:20 2015-06-02 11:20
source share