简体   繁体   中英

Stop Media Player After starting new intent

Here's my problem: I start a media player, and if I start a new intent, or leave the app and go back to it..

mp.stop;

..wont work (mp is my media player variable).

is there anyway to fix this?

Bonus to whoever can tell me how to link it up to a widget.

You always must call mp.release() in your Activity's onDestroy() . It is also recommended to at least call mp.pause() in on onPause() Activity's method.

If you want playback to continue outside of Activity lifecycle (after onPause() / onStop() / onDestroy() ) you have to create Service and play audio content from there.

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