我开发了适用于Android的音乐播放器,该应用程序运行完美。当我尝试从文件管理器打开一首歌时,它会打开音乐播放器但不播放该歌曲。
我尝试使用uri
获取getintent().getdata(
,但不知道如何将uri
转换为我所需的格式。
帮我解决问题。
播放歌曲的课程
public static void playAll(final Context context, final long[] list, int position,
final long sourceId, final IdType sourceType,
final boolean forceShuffle) {
if (list == null || list.length == 0 || mService == null) {
return;
}
try {
if (forceShuffle) {
mService.setShuffleMode(MusicService.SHUFFLE_NORMAL);
}
final long currentId = mService.getAudioId();
final int currentQueuePosition = getQueuePosition();
if (position != -1 && currentQueuePosition == position && currentId == list[position]) {
final long[] playlist = getQueue();
if (Arrays.equals(list, playlist)) {
mService.play();
return;
}
}
if (position < 0) {
position = 0;
}
mService.open(list, forceShuffle ? -1 : position, sourceId, sourceType.mId);
mService.play();
} catch (final RemoteException ignored) {
} catch (IllegalStateException e) {
e.printStackTrace();
}
}