Android的媒体播放器线程 [英] Android Media Player Threading

查看:257
本文介绍了Android的媒体播放器线程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了一个音乐播放器应用程序,它的伟大工程,但是当一个翻转动作发生,或当我回来的球员认为我必须停止播放器,并在它是在该诉讼发生的事情现在的位置重新启动它。这所有的作品,但它意味着一个breif停止和启动。

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?

感谢

推荐答案

试运行前台服务。这是工作的一点点,但它应该如何,反正做。

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.

这篇关于Android的媒体播放器线程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆