tags:

views:

32

answers:

1

I want to get the Information of the Music track playing on a android device? Is there any android powered api available for this?

Or do I have to write a plugin for respective android media players?

+2  A: 

This is technically a hack. And works only with the Music App that comes bundled with Android.

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.

st0le
Thanks. I think I got the answer!
Arunoda Susiripala
@Arunoda, If it satisfies your query, please mark the answer as accepted.
st0le
I can guarantee you this will break in future versions of the platform. DO NOT COPY PRIVATE INTERFACE DEFINITIONS INTO YOUR APP. You will eventually break, and we won't try to keep your app working.
hackbod
@hackbod, as i stated, it's a hack...it will work for now.
st0le
"for now" isn't going to be too long. If it isn't already broken on some devices -- this is the kind of thing that a manufacturer is more likely to change when they are customizing things for their device.
hackbod