Java Code Examples for android.media.RemoteControlClient#MetadataEditor

The following examples show how to use android.media.RemoteControlClient#MetadataEditor . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MusicPlayerService.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@SuppressLint("NewApi")
@Override
public void onDestroy() {
    super.onDestroy();
    if (remoteControlClient != null) {
        RemoteControlClient.MetadataEditor metadataEditor = remoteControlClient.editMetadata(true);
        metadataEditor.clear();
        metadataEditor.apply();
        audioManager.unregisterRemoteControlClient(remoteControlClient);
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        mediaSession.release();
    }
    for (int a = 0; a < UserConfig.MAX_ACCOUNT_COUNT; a++) {
        NotificationCenter.getInstance(a).removeObserver(this, NotificationCenter.messagePlayingDidSeek);
        NotificationCenter.getInstance(a).removeObserver(this, NotificationCenter.messagePlayingPlayStateChanged);
    }
}
 
Example 2
Source File: MusicPlayerService.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@SuppressLint("NewApi")
@Override
public void onDestroy() {
    super.onDestroy();
    if (remoteControlClient != null) {
        RemoteControlClient.MetadataEditor metadataEditor = remoteControlClient.editMetadata(true);
        metadataEditor.clear();
        metadataEditor.apply();
        audioManager.unregisterRemoteControlClient(remoteControlClient);
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        mediaSession.release();
    }
    for (int a = 0; a < UserConfig.MAX_ACCOUNT_COUNT; a++) {
        NotificationCenter.getInstance(a).removeObserver(this, NotificationCenter.messagePlayingDidSeek);
        NotificationCenter.getInstance(a).removeObserver(this, NotificationCenter.messagePlayingPlayStateChanged);
    }
}
 
Example 3
Source File: AudioStreamingService.java    From DMAudioStreamer with Apache License 2.0 6 votes vote down vote up
@Override
public void onDestroy() {
    super.onDestroy();
    if (remoteControlClient != null) {
        RemoteControlClient.MetadataEditor metadataEditor = remoteControlClient.editMetadata(true);
        metadataEditor.clear();
        metadataEditor.apply();
        audioManager.unregisterRemoteControlClient(remoteControlClient);
    }
    try {
        TelephonyManager mgr = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
        if (mgr != null) {
            mgr.listen(phoneStateListener, PhoneStateListener.LISTEN_NONE);
        }
    } catch (Exception e) {
        Log.e("tmessages", e.toString());
    }
    NotificationManager.getInstance().removeObserver(this, NotificationManager.audioProgressDidChanged);
    NotificationManager.getInstance().removeObserver(this, NotificationManager.audioPlayStateChanged);
}
 
Example 4
Source File: RemoteControlClientICS.java    From Popeens-DSub with GNU General Public License v3.0 6 votes vote down vote up
public void updateMetadata(final Context context, final MusicDirectory.Entry currentSong) {
	if(mRemoteControl == null) {
		return;
	}

	if(imageLoader == null) {
		imageLoader = SubsonicActivity.getStaticImageLoader(context);
	}
	
	// Update the remote controls
	RemoteControlClient.MetadataEditor editor = mRemoteControl.editMetadata(true);
	updateMetadata(currentSong, editor);
	editor.apply();
   	if (currentSong == null || imageLoader == null) {
   		updateAlbumArt(currentSong, null);
   	} else {
   		imageLoader.loadImage(context, this, currentSong);
   	}
}
 
Example 5
Source File: MusicPlayerService.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
@SuppressLint("NewApi")
@Override
public void onDestroy() {
    unregisterReceiver(headsetPlugReceiver);
    super.onDestroy();
    if (remoteControlClient != null) {
        RemoteControlClient.MetadataEditor metadataEditor = remoteControlClient.editMetadata(true);
        metadataEditor.clear();
        metadataEditor.apply();
        audioManager.unregisterRemoteControlClient(remoteControlClient);
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        mediaSession.release();
    }
    for (int a = 0; a < UserConfig.MAX_ACCOUNT_COUNT; a++) {
        NotificationCenter.getInstance(a).removeObserver(this, NotificationCenter.messagePlayingDidSeek);
        NotificationCenter.getInstance(a).removeObserver(this, NotificationCenter.messagePlayingPlayStateChanged);
        NotificationCenter.getInstance(a).removeObserver(this, NotificationCenter.httpFileDidLoad);
        NotificationCenter.getInstance(a).removeObserver(this, NotificationCenter.fileDidLoad);
    }
}
 
Example 6
Source File: MusicPlayerService.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
@SuppressLint("NewApi")
@Override
public void onDestroy() {
    unregisterReceiver(headsetPlugReceiver);
    super.onDestroy();
    if (remoteControlClient != null) {
        RemoteControlClient.MetadataEditor metadataEditor = remoteControlClient.editMetadata(true);
        metadataEditor.clear();
        metadataEditor.apply();
        audioManager.unregisterRemoteControlClient(remoteControlClient);
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        mediaSession.release();
    }
    for (int a = 0; a < UserConfig.MAX_ACCOUNT_COUNT; a++) {
        NotificationCenter.getInstance(a).removeObserver(this, NotificationCenter.messagePlayingDidSeek);
        NotificationCenter.getInstance(a).removeObserver(this, NotificationCenter.messagePlayingPlayStateChanged);
        NotificationCenter.getInstance(a).removeObserver(this, NotificationCenter.httpFileDidLoad);
        NotificationCenter.getInstance(a).removeObserver(this, NotificationCenter.fileDidLoad);
    }
}
 
Example 7
Source File: RemoteControlClientICS.java    From Popeens-DSub with GNU General Public License v3.0 5 votes vote down vote up
protected void updateMetadata(final MusicDirectory.Entry currentSong, final RemoteControlClient.MetadataEditor editor) {
	editor.putString(MediaMetadataRetriever.METADATA_KEY_ARTIST, (currentSong == null) ? null : currentSong.getArtist())
		.putString(MediaMetadataRetriever.METADATA_KEY_ALBUM, (currentSong == null) ? null : currentSong.getAlbum())
		.putString(MediaMetadataRetriever.METADATA_KEY_ALBUMARTIST, (currentSong == null) ? null : currentSong.getArtist())
		.putString(MediaMetadataRetriever.METADATA_KEY_TITLE, (currentSong) == null ? null : currentSong.getTitle())
		.putString(MediaMetadataRetriever.METADATA_KEY_GENRE, (currentSong) == null ? null : currentSong.getGenre())
		.putLong(MediaMetadataRetriever.METADATA_KEY_CD_TRACK_NUMBER, (currentSong == null) ? 
			0 : ((currentSong.getTrack() == null) ? 0 : currentSong.getTrack()))
		.putLong(MediaMetadataRetriever.METADATA_KEY_DURATION, (currentSong == null) ? 
			0 : ((currentSong.getDuration() == null) ? 0 : (currentSong.getDuration() * 1000)));
}