How to get information about a music track being played on an Android device?

I want to get information about the music track being played on an Android device. Is there an Android version available for Android?

Or do I need to write a plugin for the appropriate media players for Android?

+3
source share
2 answers

It is technically hacked. And it works only with the music application that comes bundled with Android.

Copy IMediaPlaybackService.aidl to your project ... Contact this Publish to access the MediaPlayer service. Then you can access all of these features.

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();
}

, .

+3

Android, , . ! , Android last.fm , - "scrobbles" ( , Android- Android ). , . : https://github.com/c99koder/lastfm-android/

, , , .

+1

Source: https://habr.com/ru/post/1766384/


All Articles