3

My app gets rejected by playstore "modify your app to make sure it doesn't enable background play of YouTube videos", I am using phonegap for android and it seems that the youtube videos are still playing even if my app is in background mode.

I have tried to set:

<preference name="KeepRunning" value="false"/>

But still never worked, I even tried to add "pause" listeners for that issue, the listener is never triggered even though the "deviceready" listener is triggered.

Please I need some help here.

2 Answers2

4

Update the plugin to latest version (1.5.0) and use shouldPauseOnSuspend option set to yes

cordova.InAppBrowser.open('http://youtube.com', '_blank', 'shouldPauseOnSuspend=yes');
jcesarmobile
  • 51,328
  • 11
  • 132
  • 176
  • In which file do you suggest adding this line if you may?! – Christopher Nassar Sep 21 '16 at 08:18
  • I assumed you were using InAppBrowser plugin to play the videos, how are you playing them? – jcesarmobile Sep 21 '16 at 09:01
  • well I updated that plugin and tried that option, still the same, the video audio is still playing in background, I was using window.location.href at first, but same result – Christopher Nassar Sep 21 '16 at 09:28
  • @jcesarmobile does it work if i use iframe? I am facing hard time here. Tried almost all the answers from SO. No luck as of now. – Roxx Aug 19 '17 at 19:10
  • You mean iframe in the inappbrowser or iframe in the cordova app? – jcesarmobile Aug 19 '17 at 22:54
  • @jcesarmobile I have a question https://stackoverflow.com/questions/45775517/disable-youtube-background-playing-in-cordova-android basically iframe in cordova app. – Roxx Aug 20 '17 at 04:32
  • @jcesarmobile I think you saved my day, you deserve a cookie :) thx a lot p.s.: https://forum.ionicframework.com/t/solved-violation-of-device-and-network-abuse-policy/145910/3 – David Dal Busco Oct 27 '18 at 14:49
1

I finally figured it out, adding to jcesarmobile approach, we need also to add this flag in the preference "ShouldPauseInAppBrowser" and set it to true.

Thanks all