音频原生播放器

时间:2010-08-21 07:04:33

标签: android

调用设备原生播放器播放音频文件,它会在应用程序顶部打开Android原生播放器,但在选择退出或返回应用程序时,设备会自动停止播放当前媒体。

示例代码:

Intent intent = new Intent();
intent.setAction(android.content.Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(file),"audio/*");
startActivity(intent);

如何实施以便Device在选择退出或返回应用程序时应继续在后台播放音频

先谢谢。

2 个答案:

答案 0 :(得分:1)

您无需启动原生应用即可启动播放器。见这里的例子: MediaPlayer.setDataSource() and prepare() not working - android

答案 1 :(得分:0)

当离开屏幕时,原生播放器无法播放视频,而是播放原生播放器的行为。但是,您可以实施MediaPlayer Api来完成您的要求。