當前位置: 首頁>>代碼示例>>Java>>正文


Java RemoteControlClient.MetadataEditor方法代碼示例

本文整理匯總了Java中android.media.RemoteControlClient.MetadataEditor方法的典型用法代碼示例。如果您正苦於以下問題:Java RemoteControlClient.MetadataEditor方法的具體用法?Java RemoteControlClient.MetadataEditor怎麽用?Java RemoteControlClient.MetadataEditor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.media.RemoteControlClient的用法示例。


在下文中一共展示了RemoteControlClient.MetadataEditor方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onDestroy

import android.media.RemoteControlClient; //導入方法依賴的package包/類
@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);
}
 
開發者ID:dibakarece,項目名稱:DMAudioStreamer,代碼行數:21,代碼來源:AudioStreamingService.java

示例2: updateRemote

import android.media.RemoteControlClient; //導入方法依賴的package包/類
/**
 * Update the remote with new metadata.
 * {@link #registerRemote(Context, AudioManager)} must have been called
 * first.
 *
 * @param context A context to use.
 * @param song The song containing the new metadata.
 * @param state PlaybackService state, used to determine playback state.
 */
public static void updateRemote(Context context, Song song, int state)
{
	RemoteControlClient remote = sRemote;
	if (remote == null)
		return;

	remote.setPlaybackState((state & PlaybackService.FLAG_PLAYING) != 0 ? RemoteControlClient.PLAYSTATE_PLAYING : RemoteControlClient.PLAYSTATE_PAUSED);
	RemoteControlClient.MetadataEditor editor = remote.editMetadata(true);
	if (song != null) {
		editor.putString(MediaMetadataRetriever.METADATA_KEY_ARTIST, song.artist);
		editor.putString(MediaMetadataRetriever.METADATA_KEY_ALBUM, song.album);
		editor.putString(MediaMetadataRetriever.METADATA_KEY_TITLE, song.title);
		Bitmap bitmap = song.getCover(context);
		if (bitmap != null) {
			// Create a copy of the cover art, since RemoteControlClient likes
			// to recycle what we give it.
			bitmap = bitmap.copy(Bitmap.Config.RGB_565, false);
		}
		editor.putBitmap(RemoteControlClient.MetadataEditor.BITMAP_KEY_ARTWORK, bitmap);
	}
	editor.apply();
}
 
開發者ID:owoc,項目名稱:teardrop,代碼行數:32,代碼來源:CompatIcs.java

示例3: updateMetadata

import android.media.RemoteControlClient; //導入方法依賴的package包/類
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);
   	}
}
 
開發者ID:popeen,項目名稱:Popeens-DSub,代碼行數:20,代碼來源:RemoteControlClientICS.java

示例4: broadcastStateChangeToRemoteControl

import android.media.RemoteControlClient; //導入方法依賴的package包/類
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
private static void broadcastStateChangeToRemoteControl(String title, boolean preparing, boolean titleOrSongHaveChanged) {
	try {
		if (localSong == null) {
			remoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_STOPPED);
		} else {
			remoteControlClient.setPlaybackState(preparing ? RemoteControlClient.PLAYSTATE_BUFFERING : (playing ? RemoteControlClient.PLAYSTATE_PLAYING : RemoteControlClient.PLAYSTATE_PAUSED));
			if (titleOrSongHaveChanged) {
				final RemoteControlClient.MetadataEditor ed = remoteControlClient.editMetadata(true);
				ed.putString(MediaMetadataRetriever.METADATA_KEY_TITLE, title);
				ed.putString(MediaMetadataRetriever.METADATA_KEY_ARTIST, localSong.artist);
				ed.putString(MediaMetadataRetriever.METADATA_KEY_ALBUM, localSong.album);
				ed.putLong(MediaMetadataRetriever.METADATA_KEY_CD_TRACK_NUMBER, localSong.track);
				ed.putLong(MediaMetadataRetriever.METADATA_KEY_DURATION, localSong.lengthMS);
				//Oh!!!! METADATA_KEY_YEAR is only handled in API 19+ !!! :(
				//http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/4.4_r1/android/media/MediaMetadataEditor.java#MediaMetadataEditor.0METADATA_KEYS_TYPE
				//http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/4.1.2_r1/android/media/RemoteControlClient.java#RemoteControlClient.0METADATA_KEYS_TYPE_LONG
				if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT)
					ed.putLong(MediaMetadataRetriever.METADATA_KEY_YEAR, localSong.year);
				ed.apply();
			}
		}
	} catch (Throwable ex) {
		ex.printStackTrace();
	}
}
 
開發者ID:siva000000,項目名稱:Pink-Music,代碼行數:27,代碼來源:Player.java

示例5: refreshRemoteControlClient

import android.media.RemoteControlClient; //導入方法依賴的package包/類
private void refreshRemoteControlClient(int playstate) {
  if (playerManager.isRunning()) {
    remoteControlClient.setPlaybackState(playstate);
    RemoteControlClient.MetadataEditor editor = remoteControlClient.editMetadata(false);
    AbstractMediaSource ams                   = playerManager.getCurrentMediaSource();

    editor.putString(MediaMetadataRetriever.METADATA_KEY_TITLE, ams.getTitle());
    editor.putString(MediaMetadataRetriever.METADATA_KEY_ALBUM, ams.getSummary());
    //editor.putLong(MediaMetadataRetriever.METADATA_KEY_DURATION, ams.getDuration());
    //editor.putLong(MediaMetadataRetriever.METADATA_KEY_LOCATION, ams.getPosition());
    editor.apply();

    bluetoothNotifyChange(ams, AVRCP_ACTION_PLAYER_STATUS_CHANGED);
    bluetoothNotifyChange(ams, AVRCP_ACTION_META_CHANGED);
  }
}
 
開發者ID:macbury,項目名稱:EnklawaPlayer,代碼行數:17,代碼來源:PlayerService.java

示例6: onDestroy

import android.media.RemoteControlClient; //導入方法依賴的package包/類
@SuppressLint("NewApi")
@Override
public void onDestroy() {
    super.onDestroy();
    if (remoteControlClient != null) {
        RemoteControlClient.MetadataEditor metadataEditor = remoteControlClient.editMetadata(true);
        metadataEditor.clear();
        metadataEditor.apply();
        audioManager.unregisterRemoteControlClient(remoteControlClient);
    }
    NotificationCenter.getInstance().removeObserver(this, NotificationCenter.audioProgressDidChanged);
    NotificationCenter.getInstance().removeObserver(this, NotificationCenter.audioPlayStateChanged);
}
 
開發者ID:MLNO,項目名稱:airgram,代碼行數:14,代碼來源:MusicPlayerService.java

示例7: updateRemoteControlClient

import android.media.RemoteControlClient; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
private void updateRemoteControlClient(final String what) {
    //Legacy for ICS
    if (mRemoteControlClient != null) {
        int playState = mIsSupposedToBePlaying
                ? RemoteControlClient.PLAYSTATE_PLAYING
                : RemoteControlClient.PLAYSTATE_PAUSED;
        if (what.equals(META_CHANGED) || what.equals(QUEUE_CHANGED)) {
            Bitmap albumArt = null;
            if (mShowAlbumArtOnLockscreen) {
                albumArt = ImageLoader.getInstance().loadImageSync(TimberUtils.getAlbumArtUri(getAlbumId()).toString());
                if (albumArt != null) {

                    Bitmap.Config config = albumArt.getConfig();
                    if (config == null) {
                        config = Bitmap.Config.ARGB_8888;
                    }
                    albumArt = albumArt.copy(config, false);
                }
            }

            RemoteControlClient.MetadataEditor editor = mRemoteControlClient.editMetadata(true);
            editor.putString(MediaMetadataRetriever.METADATA_KEY_ALBUM, getAlbumName());
            editor.putString(MediaMetadataRetriever.METADATA_KEY_ARTIST, getArtistName());
            editor.putString(MediaMetadataRetriever.METADATA_KEY_TITLE, getTrackName());
            editor.putLong(MediaMetadataRetriever.METADATA_KEY_DURATION, duration());
            editor.putBitmap(MediaMetadataEditor.BITMAP_KEY_ARTWORK, albumArt);
            editor.apply();

        }
        mRemoteControlClient.setPlaybackState(playState);
    }
}
 
開發者ID:Vinetos,項目名稱:Hello-Music-droid,代碼行數:35,代碼來源:MusicService.java

示例8: updateClientBitmap

import android.media.RemoteControlClient; //導入方法依賴的package包/類
private synchronized Void updateClientBitmap(Bitmap bitmap) {
	if (remoteClientBitmap == bitmap) return null;

	final RemoteControlClient.MetadataEditor metaData = remoteControlClient.editMetadata(false);
	metaData.putBitmap(MediaMetadataEditor.BITMAP_KEY_ARTWORK, bitmap).apply();

	// Track the remote client bitmap and recycle it in case the remote control client
	// does not properly recycle the bitmap
	if (remoteClientBitmap != null) remoteClientBitmap.recycle();
	remoteClientBitmap = bitmap;

	return null;
}
 
開發者ID:danrien,項目名稱:projectBlue,代碼行數:14,代碼來源:RemoteControlClientBroadcaster.java

示例9: notifyChange

import android.media.RemoteControlClient; //導入方法依賴的package包/類
/**
 * Notify the change-receivers that something has changed.
 * The intent that is sent contains the following data
 * for the currently playing track:
 * "id" - Integer: the database row ID
 * "artist" - String: the name of the artist
 * "album" - String: the name of the album
 * "track" - String: the name of the track
 * The intent has an action that is one of
 * "com.android.music.metachanged"
 * "com.android.music.queuechanged",
 * "com.android.music.playbackcomplete"
 * "com.android.music.playstatechanged"
 * respectively indicating that a new track has
 * started playing, that the playback queue has
 * changed, that playback has stopped because
 * the last file in the list has been played,
 * or that the play-state changed (paused/resumed).
 */
private void notifyChange(String what) {

    Intent i = new Intent(what);
    i.putExtra("id", Long.valueOf(getAudioId()));
    i.putExtra("artist", getArtistName());
    i.putExtra("album",getAlbumName());
    i.putExtra("track", getTrackName());
    i.putExtra("playing", isPlaying());
    sendStickyBroadcast(i);

    if (what.equals(PLAYSTATE_CHANGED)) {
        mRemoteControlClient.setPlaybackState(isPlaying() ?
                RemoteControlClient.PLAYSTATE_PLAYING : RemoteControlClient.PLAYSTATE_PAUSED);
    } else if (what.equals(META_CHANGED)) {
        RemoteControlClient.MetadataEditor ed = mRemoteControlClient.editMetadata(true);
        ed.putString(MediaMetadataRetriever.METADATA_KEY_TITLE, getTrackName());
        ed.putString(MediaMetadataRetriever.METADATA_KEY_ALBUM, getAlbumName());
        ed.putString(MediaMetadataRetriever.METADATA_KEY_ARTIST, getArtistName());
        ed.putLong(MediaMetadataRetriever.METADATA_KEY_DURATION, duration());
        Bitmap b = MusicUtils.getArtwork(this, getAudioId(), getAlbumId(), false);
        if (b != null) {
            ed.putBitmap(MetadataEditor.BITMAP_KEY_ARTWORK, b);
        }
        ed.apply();
    }

    if (what.equals(QUEUE_CHANGED)) {
        saveQueue(true);
    } else {
        saveQueue(false);
    }
    
    // Share this notification directly with our widgets
    mAppWidgetProvider.notifyChange(this, what);
}
 
開發者ID:AndroidLearnerchn,項目名稱:Android-Application-Using-CAF-Library,代碼行數:55,代碼來源:MediaPlaybackService.java

示例10: setMetaData

import android.media.RemoteControlClient; //導入方法依賴的package包/類
@TargetApi(19)
private void setMetaData() {

    RemoteControlClient localRemoteControlClient = (RemoteControlClient) this.remoteControlClient;

    RemoteControlClient.MetadataEditor editor = localRemoteControlClient.editMetadata(true);

    editor.putString(MediaMetadataRetriever.METADATA_KEY_ALBUMARTIST, authorField.getText().toString());
    editor.putString(MediaMetadataRetriever.METADATA_KEY_TITLE, bookTitle);

    editor.apply();
    //Set cover too?

    localRemoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_PLAYING);

    LOG.debug("Focus: updated meta-data");
}
 
開發者ID:benjamarle,項目名稱:typhon,代碼行數:18,代碼來源:ReadingFragment.java

示例11: notifyChange

import android.media.RemoteControlClient; //導入方法依賴的package包/類
/**
 * Notify the change-receivers that something has changed. The intent that
 * is sent contains the following data for the currently playing track: "id"
 * - Integer: the database row ID "artist" - String: the name of the artist
 * "album" - String: the name of the album "track" - String: the name of the
 * track The intent has an action that is one of
 * "com.cp.monsterMod.metachanged" "com.cp.monsterMod.queuechanged",
 * "com.cp.monsterMod.playbackcomplete" "com.cp.monsterMod.playstatechanged"
 * respectively indicating that a new track has started playing, that the
 * playback queue has changed, that playback has stopped because the last
 * file in the list has been played, or that the play-state changed
 * (paused/resumed).
 */
public void notifyChange(String what) {

    Intent i = new Intent(what);
    i.putExtra("id", Long.valueOf(getAudioId()));
    i.putExtra("artist", getArtistName());
    i.putExtra("album", getAlbumName());
    i.putExtra("track", getTrackName());
    i.putExtra("playing", mIsSupposedToBePlaying);
    i.putExtra("isfavorite", isFavorite());
    //粘滯廣播
    sendStickyBroadcast(i);

    i = new Intent(i);
    i.setAction(what.replace(APOLLO_PACKAGE_NAME, MUSIC_PACKAGE_NAME));
    sendStickyBroadcast(i);

    if (what.equals(PLAYSTATE_CHANGED)) {
        mRemoteControlClient
                .setPlaybackState(mIsSupposedToBePlaying ? RemoteControlClient.PLAYSTATE_PLAYING
                        : RemoteControlClient.PLAYSTATE_PAUSED);
    } else if (what.equals(META_CHANGED)) {
        RemoteControlClient.MetadataEditor ed = mRemoteControlClient.editMetadata(true);
        ed.putString(MediaMetadataRetriever.METADATA_KEY_TITLE, getTrackName());
        ed.putString(MediaMetadataRetriever.METADATA_KEY_ALBUM, getAlbumName());
        ed.putString(MediaMetadataRetriever.METADATA_KEY_ARTIST, getArtistName());
        ed.putLong(MediaMetadataRetriever.METADATA_KEY_DURATION, duration());
        Bitmap b = getAlbumBitmap();
        if (b != null) {
            ed.putBitmap(MetadataEditor.BITMAP_KEY_ARTWORK, b);
        }
        ed.apply();
    }

    if (what.equals(QUEUE_CHANGED)) {
        saveQueue(true);
    } else {
        saveQueue(false);
    }
    mAppWidgetProvider1x1.notifyChange(this, what);
    mAppWidgetProvider4x1.notifyChange(this, what);
    mAppWidgetProvider4x2.notifyChange(this, what);

}
 
開發者ID:cpoopc,項目名稱:com.cp.monsterMod,代碼行數:57,代碼來源:ApolloService.java

示例12: notifyChange

import android.media.RemoteControlClient; //導入方法依賴的package包/類
/**
 * Notify the change-receivers that something has changed. The intent that
 * is sent contains the following data for the currently playing track: "id"
 * - Integer: the database row ID "artist" - String: the name of the artist
 * "album" - String: the name of the album "track" - String: the name of the
 * track The intent has an action that is one of
 * "com.andrew.apolloMod.metachanged" "com.andrew.apolloMod.queuechanged",
 * "com.andrew.apolloMod.playbackcomplete" "com.andrew.apolloMod.playstatechanged"
 * respectively indicating that a new track has started playing, that the
 * playback queue has changed, that playback has stopped because the last
 * file in the list has been played, or that the play-state changed
 * (paused/resumed).
 */
public void notifyChange(String what) {

    Intent i = new Intent(what);
    i.putExtra("id", Long.valueOf(getAudioId()));
    i.putExtra("artist", getArtistName());
    i.putExtra("album", getAlbumName());
    i.putExtra("track", getTrackName());
    i.putExtra("playing", mIsSupposedToBePlaying);
    i.putExtra("isfavorite", isFavorite());
    sendStickyBroadcast(i);

    i = new Intent(i);
    i.setAction(what.replace(APOLLO_PACKAGE_NAME, MUSIC_PACKAGE_NAME));
    sendStickyBroadcast(i);

    if (what.equals(PLAYSTATE_CHANGED)) {
        mRemoteControlClient
                .setPlaybackState(mIsSupposedToBePlaying ? RemoteControlClient.PLAYSTATE_PLAYING
                        : RemoteControlClient.PLAYSTATE_PAUSED);
    } else if (what.equals(META_CHANGED)) {
        RemoteControlClient.MetadataEditor ed = mRemoteControlClient.editMetadata(true);
        ed.putString(MediaMetadataRetriever.METADATA_KEY_TITLE, getTrackName());
        ed.putString(MediaMetadataRetriever.METADATA_KEY_ALBUM, getAlbumName());
        ed.putString(MediaMetadataRetriever.METADATA_KEY_ARTIST, getArtistName());
        ed.putLong(MediaMetadataRetriever.METADATA_KEY_DURATION, duration());
        Bitmap b = getAlbumBitmap();
        if (b != null) {
            ed.putBitmap(MetadataEditor.BITMAP_KEY_ARTWORK, b);
        }
        ed.apply();
    }

    if (what.equals(QUEUE_CHANGED)) {
        saveQueue(true);
    } else {
        saveQueue(false);
    }
    mAppWidgetProvider1x1.notifyChange(this, what);
    mAppWidgetProvider4x1.notifyChange(this, what);
    mAppWidgetProvider4x2.notifyChange(this, what);

}
 
開發者ID:liufeiit,項目名稱:itmarry,代碼行數:56,代碼來源:ApolloService.java

示例13: notifyChange

import android.media.RemoteControlClient; //導入方法依賴的package包/類
/**
 * Notify the change-receivers that something has changed. The intent that
 * is sent contains the following data for the currently playing track: "id"
 * - Integer: the database row ID "artist" - String: the name of the artist
 * "album" - String: the name of the album "track" - String: the name of the
 * track The intent has an action that is one of
 * "com.aniruddhc.xPlod.metachanged" "com.aniruddhc.xPlod.queuechanged",
 * "com.aniruddhc.xPlod.playbackcomplete" "com.aniruddhc.xPlod.playstatechanged"
 * respectively indicating that a new track has started playing, that the
 * playback queue has changed, that playback has stopped because the last
 * file in the list has been played, or that the play-state changed
 * (paused/resumed).
 */
public void notifyChange(String what) {

    Intent i = new Intent(what);
    i.putExtra("id", Long.valueOf(getAudioId()));
    i.putExtra("artist", getArtistName());
    i.putExtra("album", getAlbumName());
    i.putExtra("track", getTrackName());
    i.putExtra("playing", mIsSupposedToBePlaying);
    i.putExtra("isfavorite", isFavorite());
    sendStickyBroadcast(i);

    i = new Intent(i);
    i.setAction(what.replace(APOLLO_PACKAGE_NAME, MUSIC_PACKAGE_NAME));
    sendStickyBroadcast(i);

    if (what.equals(PLAYSTATE_CHANGED)) {
        mRemoteControlClient
                .setPlaybackState(mIsSupposedToBePlaying ? RemoteControlClient.PLAYSTATE_PLAYING
                        : RemoteControlClient.PLAYSTATE_PAUSED);
    } else if (what.equals(META_CHANGED)) {
        RemoteControlClient.MetadataEditor ed = mRemoteControlClient.editMetadata(true);
        ed.putString(MediaMetadataRetriever.METADATA_KEY_TITLE, getTrackName());
        ed.putString(MediaMetadataRetriever.METADATA_KEY_ALBUM, getAlbumName());
        ed.putString(MediaMetadataRetriever.METADATA_KEY_ARTIST, getArtistName());
        ed.putLong(MediaMetadataRetriever.METADATA_KEY_DURATION, duration());
        Bitmap b = getAlbumBitmap();
        if (b != null) {
            ed.putBitmap(MetadataEditor.BITMAP_KEY_ARTWORK, b);
        }
        ed.apply();
    }

    if (what.equals(QUEUE_CHANGED)) {
        saveQueue(true);
    } else {
        saveQueue(false);
    }
    mAppWidgetProvider1x1.notifyChange(this, what);
    mAppWidgetProvider4x1.notifyChange(this, what);
    mAppWidgetProvider4x2.notifyChange(this, what);

}
 
開發者ID:C-Aniruddh,項目名稱:xPlodMusic,代碼行數:56,代碼來源:ApolloService.java


注:本文中的android.media.RemoteControlClient.MetadataEditor方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。