我想获取在Android设备上播放的音乐曲目的信息. 是否有任何Android驱动的API可用?还是我必须为相应的Android媒体播放器编写插件?
I want to get the Information of the Music track playing on an Android device. Is there any Android-powered API available for this? Or do I have to write a plugin for respective Android media players?
推荐答案从技术上讲,这是黑客.并且仅适用于与Android捆绑在一起的Music App.
This is technically a hack. And works only with the Music App that comes bundled with Android.
复制此 IMediaPlaybackService. aidl 进入您的项目...请参考此帖子以访问MediaPlayer服务.然后,您可以访问所有这些功能.
Copy this IMediaPlaybackService.aidl into your Project...Refer this Post to access the MediaPlayer Service. You can then access all these functions.
package com.android.music; import android.graphics.Bitmap; interface IMediaPlaybackService { void openFile(String path, boolean oneShot); void openFileAsync(String path); void open(in long [] list, int position); int getQueuePosition(); boolean isPlaying(); void stop(); void pause(); void play(); void prev(); void next(); long duration(); long position(); long seek(long pos); String getTrackName(); String getAlbumName(); long getAlbumId(); String getArtistName(); long getArtistId(); void enqueue(in long [] list, int action); long [] getQueue(); void moveQueueItem(int from, int to); void setQueuePosition(int index); String getPath(); long getAudioId(); void setShuffleMode(int shufflemode); int getShuffleMode(); int removeTracks(int first, int last); int removeTrack(long id); void setRepeatMode(int repeatmode); int getRepeatMode(); int getMediaMountedCount(); }对于其他播放器,您需要检查他们是否将其服务公开给其他应用程序.
For other players, you'll need to check if they expose their service to other applications.
更多推荐
如何获取在Android设备上播放的音乐曲目的信息?
发布评论