Android Media Player Threading

会有一股神秘感。 提交于 2019-12-04 23:45:00

问题


I have written a Music player app and it works great but when a flip action happens or when I return the the player view I have to stop the player and restart it at the postion that it was at when the action happened. That all works but it means a breif stop and start.

How can I run the media player in a different thread and still update my seekbar?

Thanks


回答1:


Try running the media player within a foreground service. It's a little bit of work, but it's how it should be done anyways.

The service will handle running everything in a background thread and can be set up to post updates to your UI through messages or callbacks.

In addition, a Foreground service does not need to be tied to an activity, so it can continue to run even if you leave your player screen. The service must provide an Ongoing notification to the user that will probably display the current song, artist, click to pause, etc.



来源:https://stackoverflow.com/questions/3188170/android-media-player-threading

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!