Use RemoteControlClient without MediaPlayer

I want to broadcast music info from my player to the lock screen widget. I now the RemoteControlClient class exists for these purposes. But what if i'm using custom engine for music playback? How can i control widget on lock screen?

Answers


I found simple way to do this.

//init remoteControlClient
    remoteControlClient = new RemoteControlClient(PendingIntent
                    .getBroadcast(this, 0, new Intent(Intent.ACTION_MEDIA_BUTTON).setComponent(componentName), 0));
    audioManager.registerRemoteControlClient(remoteControlClient);
            remoteControlClient.setTransportControlFlags(RemoteControlClient.FLAG_KEY_MEDIA_NEXT |
                    RemoteControlClient.FLAG_KEY_MEDIA_PLAY_PAUSE|RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS|
                    RemoteControlClient.FLAG_KEY_MEDIA_PAUSE|RemoteControlClient.FLAG_KEY_MEDIA_PLAY);
//put info to the lockscreen
    remoteControlClient.editMetadata(true)
                    .putBitmap(MediaMetadataEditor.BITMAP_KEY_ARTWORK, bitmap)
                    .putString(MediaMetadataRetriever.METADATA_KEY_ARTIST,audio.getArtist())
                    .putString(MediaMetadataRetriever.METADATA_KEY_ALBUM,audio.getAlbum())
                    .putString(MediaMetadataRetriever.METADATA_KEY_TITLE,audio.getTitle()).apply();
//destroy remoteCControlClient
    audioManager.unregisterRemoteControlClient(remoteControlClient);

Need Your Help

Json get value from table

php json

I have a small code make this result :

OSX: API for retrieving path to user's ~/temp folder

macos path folder temp

Does OS X have a separate temp folder for each user?