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


Java RemoteControlClient.setPlaybackState方法代碼示例

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


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

示例1: 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

示例2: a

import android.media.RemoteControlClient; //導入方法依賴的package包/類
public void a(boolean flag, long l1, int i1)
{
    if (m != null)
    {
        RemoteControlClient remotecontrolclient = m;
        byte byte0;
        float f1;
        if (flag)
        {
            byte0 = 3;
        } else
        {
            byte0 = 1;
        }
        if (flag)
        {
            f1 = 1.0F;
        } else
        {
            f1 = 0.0F;
        }
        remotecontrolclient.setPlaybackState(byte0, l1, f1);
        m.setTransportControlFlags(i1);
    }
}
 
開發者ID:vishnudevk,項目名稱:MiBandDecompiled,代碼行數:26,代碼來源:d.java

示例3: register

import android.media.RemoteControlClient; //導入方法依賴的package包/類
public void register(final Context context, final ComponentName mediaButtonReceiverComponent) {
	downloadService = (DownloadService) context;
	AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);

	// build the PendingIntent for the remote control client
	Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
	mediaButtonIntent.setComponent(mediaButtonReceiverComponent);
	PendingIntent mediaPendingIntent = PendingIntent.getBroadcast(context.getApplicationContext(), 0, mediaButtonIntent, 0);

	// create and register the remote control client
	mRemoteControl = new RemoteControlClient(mediaPendingIntent);
	audioManager.registerRemoteControlClient(mRemoteControl);

	mRemoteControl.setPlaybackState(RemoteControlClient.PLAYSTATE_STOPPED);
	mRemoteControl.setTransportControlFlags(getTransportFlags());
	imageLoader = SubsonicActivity.getStaticImageLoader(context);
}
 
開發者ID:popeen,項目名稱:Popeens-DSub,代碼行數:18,代碼來源:RemoteControlClientICS.java

示例4: refreshState

import android.media.RemoteControlClient; //導入方法依賴的package包/類
public void refreshState(boolean flag, long l, int i)
{
    if (mRemoteControl != null)
    {
        RemoteControlClient remotecontrolclient = mRemoteControl;
        float f;
        byte byte0;
        if (flag)
        {
            byte0 = 3;
        } else
        {
            byte0 = 1;
        }
        if (flag)
        {
            f = 1.0F;
        } else
        {
            f = 0.0F;
        }
        remotecontrolclient.setPlaybackState(byte0, l, f);
        mRemoteControl.setTransportControlFlags(i);
    }
}
 
開發者ID:Hamz-a,項目名稱:MyCTFWriteUps,代碼行數:26,代碼來源:TransportMediatorJellybeanMR2.java

示例5: register

import android.media.RemoteControlClient; //導入方法依賴的package包/類
public void register(final Context context, final ComponentName mediaButtonReceiverComponent) {
	downloadService = (DownloadService) context;
	AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);

	// build the PendingIntent for the remote control client
	Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
	mediaButtonIntent.setComponent(mediaButtonReceiverComponent);
	PendingIntent mediaPendingIntent = PendingIntent.getBroadcast(context.getApplicationContext(), 0, mediaButtonIntent, 0);

	// create and register the remote control client
	mRemoteControl = new RemoteControlClient(mediaPendingIntent);
	audioManager.registerRemoteControlClient(mRemoteControl);

	mRemoteControl.setPlaybackState(RemoteControlClient.PLAYSTATE_STOPPED);
	mRemoteControl.setTransportControlFlags(getTransportFlags());
	imageLoader = SubsonicTabActivity.getStaticImageLoader(context);
}
 
開發者ID:MadMarty,項目名稱:madsonic-5.5,代碼行數:18,代碼來源:RemoteControlClientICS.java

示例6: registerRCC

import android.media.RemoteControlClient; //導入方法依賴的package包/類
private void registerRCC() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        // Create the RCC and register with AudioManager and MediaRouter
        mAudioManager.requestAudioFocus(mAfChangeListener,
                AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN);
        mAudioManager.registerMediaButtonEventReceiver(mEventReceiver);
        mRemoteControlClient = new RemoteControlClient(mMediaPendingIntent);
        mAudioManager.registerRemoteControlClient(mRemoteControlClient);
        mMediaRouter.addRemoteControlClient(mRemoteControlClient);
        SampleMediaButtonReceiver.setActivity(SampleMediaRouterActivity.this);
        mRemoteControlClient.setTransportControlFlags(
                RemoteControlClient.FLAG_KEY_MEDIA_PLAY_PAUSE);
        mRemoteControlClient.setPlaybackState(
                RemoteControlClient.PLAYSTATE_PLAYING);
    }
}
 
開發者ID:benhysell,項目名稱:V.FlyoutTest,代碼行數:17,代碼來源:SampleMediaRouterActivity.java

示例7: setUpRemoteControlClient

import android.media.RemoteControlClient; //導入方法依賴的package包/類
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
private void setUpRemoteControlClient() {
    AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
    // Very important to request for the focus.
    audioManager.requestAudioFocus(null, AudioManager.STREAM_MUSIC,
            AudioManager.AUDIOFOCUS_GAIN_TRANSIENT);

    // Set up the RemoteControlClient to invoke our BroadcastReceiver.
    ComponentName eventReceiver = new ComponentName(this,
            RemoteControlReceiver.class.getName());
    Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
    mediaButtonIntent.setComponent(eventReceiver);
    PendingIntent mediaPendingIntent = PendingIntent.
            getBroadcast(getApplicationContext(), 0, mediaButtonIntent, 0);
    mRemoteControlClient = new RemoteControlClient(mediaPendingIntent);

    // Register the remote control client.
    audioManager.registerMediaButtonEventReceiver(eventReceiver);
    audioManager.registerRemoteControlClient(mRemoteControlClient);

    // Add buttons that are needed on the remote control client.
    mRemoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_PLAYING);

    mRemoteControlClient.setTransportControlFlags(
            RemoteControlClient.FLAG_KEY_MEDIA_PLAY_PAUSE
            | RemoteControlClient.FLAG_KEY_MEDIA_NEXT
            | RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS);

    mMediaRouter.addRemoteControlClient(mRemoteControlClient);
}
 
開發者ID:TerribleDev,項目名稱:XamarinAdmobTutorial,代碼行數:31,代碼來源:BaseCastPlayerActivity.java

示例8: 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


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