I've just started learning Android Dev. Basically I've got a service and it sends a broadcast to stop any player currently working (video or audio).

I found this in other topic:

    Intent i = new Intent("com.android.music.musicservicecommand");
    i.putExtra("command", "pause");
    sendBroadcast(i);

but it doesn't seem to work on Spotify or Youtube.

For Spotify I found this solution:

    Intent i = new Intent("com.spotify.mobile.android.ui.widget.PLAY");
    i.setPackage("com.spotify.music");
    sendBroadcast(i);

and it gets the job done.

But I can't find similar way to pause YouTube. How would you pause a video playing from a background service? Or the best way to stop any audio/video playing?

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.