如何获得音乐曲目播放Android设备上的信息? [英] How to get the Information of the Music track playing on a android device?
问题描述
我想要得到的音乐曲目播放Android设备上的信息? 有没有搭载Android API可用于此?
I want to get the Information of the Music track playing on a android device? Is there any android powered api available for this?
还是我必须写一个插件各自的Android媒体播放器?
Or do I have to write a plugin for respective android media players?
推荐答案
这在技术上是一个黑客。只有用音乐应用程序,它捆绑了Android的工作。
This is technically a hack. And works only with the Music App that comes bundled with Android.
复制此<一个href="http://www.netmite.com/android/mydroid/packages/apps/Music/src/com/android/music/IMediaPlaybackService.aidl"相对=nofollow> 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设备上的信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!