使用 Android 意图播放多首歌曲 [英] Play multiple songs with Android intent

查看:36
本文介绍了使用 Android 意图播放多首歌曲的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,我需要启动 Android 音乐播放器.而且,就目前而言,它完美运行:

In my application, I need to launch the Android Music Player. And, for now, it works perfectly :

Intent  intent = new Intent(android.content.Intent.ACTION_VIEW); 
File    file = new File(file_path);

intent.setDataAndType(Uri.fromFile(file), "audio/*");  
startActivity(Intent.createChooser(intent, "..."));

但是用户不能使用next"和prev"按钮来切换音乐.这就是为什么我尝试一次启动多首歌曲(播放列表).我真的不知道该怎么做!给意图一个数组?

But the user can't use the "next" and "prev" buttons to switch music. That's why I try to launch multiple songs at once (a playlist). And I don't really know how to do this! Give an array to the intent ?

推荐答案

据我所知,没有办法启动多个轨道.但是您可以使用 MediaPlayer 类来实现您的播放器.这也不支持多轨.所以你还必须做一个服务,使用 OnCompletionListener 监听曲目结束时,开始下一曲目.

As far I know there is no way to launch multiple tracks. But you can implement your player, using the MediaPlayer class. Which also doesn't supports multiple tracks. So you also have to make a service, use OnCompletionListener to listen when tracks finish, to start the next track.

此线程将帮助:当应用程序处于关闭状态时,Android 媒体播放器如何继续播放歌曲关闭了吗?

还有这个:启动默认音乐播放器,默认播放音乐

这篇关于使用 Android 意图播放多首歌曲的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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