How do I prevent youtube stop playback using Android API?
Asked Answered
C

1

0

As far as I know, with the YouTube API for Android, the player automatically stops when it's out of view. For example, when the app is closed or when another view is positioned on top of the player.

But I've seen this application: https://play.google.com/store/apps/details?id=com.mixerbox.mixerbox that seems to have found a workaround for this. In this app, when you close it, the video doesn't stops and continues playing in the background.

Anyone know how this can be achieved?

Char answered 10/10, 2013 at 11:46 Comment(0)
P
2

To play only the audio of a YouTube video violates the YouTube API Terms of Service:

Your API Client will not, and You will not encourage or create functionality for Your users or other third parties to:

9. promote separately the audio or video components of any YouTube audiovisual content made available through the YouTube API;


For educational purposes take a look at the Services developer guide.

A Service is an application component that can perform long-running operations in the background and does not provide a user interface. Another application component can start a service and it will continue to run in the background even if the user switches to another application. Additionally, a component can bind to a service to interact with it and even perform interprocess communication (IPC). For example, a service might handle network transactions, play music, perform file I/O, or interact with a content provider, all from the background

The MixerBox app you mention most likely has a Service that it delegates the play back of the video's audio to when its' Activity's onPause() callback is executed by the system. That is how MixerBox allows you to navigate away from the application and you can still here the audio playing from the video.

Protectionism answered 10/10, 2013 at 12:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.