安卓浏览音频播放列表,并从一个应用程序打开一个m3u文件 [英] Android: Browse audio playlist and open a M3U file from an app

查看:1299
本文介绍了安卓浏览音频播放列表,并从一个应用程序打开一个m3u文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找到一种方式来浏览音频播放列表,返回并保存乌里
播放列表后进行播放。

I am trying to find a way to browse audio playlist and return and save the Uri of the playlist to play it later.

就像一个闹钟,你可以选择播放列表以后发青它时,报警器
开始。

Like an alarm clock which you can select the playlist to paly it later when alarm starts.

有可能得到一首歌曲的URI,意图,但它不能在播放列表中工作。

It is possible to get one song's URI, with intent but it doesn't work on playlist.

我都试过的意图,

Intent i = new Intent(Intent.ACTION_PICK);
i.setType(MediaStore.Audio.Playlists.CONTENT_TYPE);
startActivity(i);

,但它不返回的URI,它直接运行的MediaPlayback活性。

but it doesn't return URI, it runs MediaPlayback activity directly.

对此有何想法?

先谢谢了。

推荐答案

这是code应为播放列表工作:

This is the code that should work for playlists:

Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setComponent(new ComponentName
("com.android.music","com.android.music.PlaylistBrowserActivity"));
intent.setType(MediaStore.Audio.Playlists.CONTENT_TYPE);
intent.setFlags(0x10000000);
intent.putExtra("oneshot", false);
intent.putExtra("playlist", playlistid);
startActivity(intent);

和检索playlistid:

and to retrieve the playlistid:

Cursor cursor = getContentResolver().query
(MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI, null, null, null,
null);
if (cursor != null) {
 if (cursor.moveToFirst()) {
  do {
     playlistid = cursor.getString(cursor.getColumnIndex
(MediaStore.Audio.Playlists._ID));
     playList.add(playlist);
     } while (cursor.moveToNext());
     cursor.close();
 }
}

(从 http://www.androiddiscuss.com/1-android复制 - 讨论/ 29092.html

这篇关于安卓浏览音频播放列表,并从一个应用程序打开一个m3u文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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