简体   繁体   中英

Android: AudioManager for audio, is there a equivalent for Video

For android, I've researched for controlling Audio using AudioManager. Will there be one for video which I can control the video player to play/stop/pause.

There is no such API like VideoManager

You can handle videos through Primary API MediaPlayer and also see this useful article of multiple ways to handle videos

The purpose of AudioManager isn't really to control audio playback, but to control such properties as volume, audio mode, and so on. If there is a media player in the background, that doesn't really mean that you control it, you can only send certain requests to the AudioManager which cause the system either to take some actions regarding the audio, or to send some events, which the audio player may respond to. So you don't have direct control over the other application.

Likewise, there is no system service which will make the video pause. The best equivalent of AudioManager you have which controls what is shown on the screen is WindowManager , but I think it's obvious that it can't be used to make a video player pause.

Your best bet for controlling an external video player would be to look up its intents, it may have some ways to control the playback from outside. This, of course, will be application specific.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM