当前位置: 首页>>代码示例>>Java>>正文


Java RemoteControlClient类代码示例

本文整理汇总了Java中android.media.RemoteControlClient的典型用法代码示例。如果您正苦于以下问题:Java RemoteControlClient类的具体用法?Java RemoteControlClient怎么用?Java RemoteControlClient使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


RemoteControlClient类属于android.media包,在下文中一共展示了RemoteControlClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: registerRemoteControl

import android.media.RemoteControlClient; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
void registerRemoteControl(ComponentName rcvMedia) {
    mAudioManager.requestAudioFocus(this, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN);
    Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
    mediaButtonIntent.setComponent(rcvMedia);
    PendingIntent mediaPendingIntent = PendingIntent.getBroadcast(getApplicationContext(),
            0, mediaButtonIntent, 0);
    remoteControlClient = new RemoteControlClient(mediaPendingIntent);

    remoteControlClient.setTransportControlFlags(
            RemoteControlClient.FLAG_KEY_MEDIA_PLAY_PAUSE |
                    RemoteControlClient.FLAG_KEY_MEDIA_NEXT |
                    RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS
    );
    mAudioManager.registerRemoteControlClient(remoteControlClient);
}
 
开发者ID:dmllr,项目名称:IdealMedia,代码行数:17,代码来源:PlayerService.java

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

示例3: playbackStateUpdate

import android.media.RemoteControlClient; //导入依赖的package包/类
private void playbackStateUpdate(int state) {
    boolean active;
    switch (state) {
        case RemoteControlClient.PLAYSTATE_PLAYING:
            active = true;
            break;
        case RemoteControlClient.PLAYSTATE_ERROR:
        case RemoteControlClient.PLAYSTATE_PAUSED:
        default:
            active = false;
            break;
    }
    if (active != mActive) {
        mActive = active;
        refreshState();
        if (DEBUG) log(getKey() + ": playbackStateUpdate("+state+")");
    }
}
 
开发者ID:WrBug,项目名称:GravityBox,代码行数:19,代码来源:MusicTile.java

示例4: if

import android.media.RemoteControlClient; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
public void registrér() {
  if (Build.VERSION.SDK_INT < Build.VERSION_CODES.FROYO) return;
  App.audioManager.registerMediaButtonEventReceiver(fjernbetjeningReciever);
  if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) return;
  // 'det er irriterende at den ændre billedet på lock - screen, det skal være muligt at disable dette.'
  if (!App.prefs.getBoolean("fjernbetjening", true)) return;

  Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON).setComponent(fjernbetjeningReciever);
  PendingIntent mediaPendingIntent = PendingIntent.getBroadcast(ApplicationSingleton.instans, 0, mediaButtonIntent, 0);
  // create and register the remote control client
  remoteControlClient = new RemoteControlClient(mediaPendingIntent);
  remoteControlClient.setTransportControlFlags(RemoteControlClient.FLAG_KEY_MEDIA_PLAY_PAUSE
          | RemoteControlClient.FLAG_KEY_MEDIA_NEXT
          | RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS
          | RemoteControlClient.FLAG_KEY_MEDIA_STOP
          | RemoteControlClient.FLAG_KEY_MEDIA_PLAY
  );
  App.audioManager.registerRemoteControlClient(remoteControlClient);
}
 
开发者ID:nordfalk,项目名称:EsperantoRadio,代码行数:21,代码来源:Fjernbetjening.java

示例5: registerRemoteControlClient

import android.media.RemoteControlClient; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
private void registerRemoteControlClient(ComponentName componentName) {

    audioManager.requestAudioFocus(null, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN);

    Intent remoteControlIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
    remoteControlIntent.setComponent(componentName);

    RemoteControlClient localRemoteControlClient = new RemoteControlClient(
            PendingIntent.getBroadcast(context, 0, remoteControlIntent, 0));

    localRemoteControlClient.setTransportControlFlags(RemoteControlClient.FLAG_KEY_MEDIA_PLAY_PAUSE
            | RemoteControlClient.FLAG_KEY_MEDIA_NEXT
            | RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS
            | RemoteControlClient.FLAG_KEY_MEDIA_PLAY
            | RemoteControlClient.FLAG_KEY_MEDIA_PAUSE
    );

    audioManager.registerRemoteControlClient(localRemoteControlClient);

    this.remoteControlClient = localRemoteControlClient;
}
 
开发者ID:benjamarle,项目名称:typhon,代码行数:23,代码来源:ReadingFragment.java

示例6: registerRemote

import android.media.RemoteControlClient; //导入依赖的package包/类
/**
 * Perform initialization required for RemoteControlClient.
 *
 * @param context A context to use.
 * @param am The AudioManager service.
 */
public static void registerRemote(Context context, AudioManager am)
{
	if (!MediaButtonReceiver.useHeadsetControls(context)) {
		// RemoteControlClient requires MEDIA_BUTTON intent
		return;
	}

	MediaButtonReceiver.registerMediaButton(context);

	Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
	mediaButtonIntent.setComponent(new ComponentName(context.getPackageName(), MediaButtonReceiver.class.getName()));
	PendingIntent mediaPendingIntent = PendingIntent.getBroadcast(context, 0, mediaButtonIntent, 0);
	RemoteControlClient remote = new RemoteControlClient(mediaPendingIntent);
	int flags = RemoteControlClient.FLAG_KEY_MEDIA_NEXT
		| RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS
		| RemoteControlClient.FLAG_KEY_MEDIA_PLAY_PAUSE
		| RemoteControlClient.FLAG_KEY_MEDIA_PLAY
		| RemoteControlClient.FLAG_KEY_MEDIA_PAUSE;
	remote.setTransportControlFlags(flags);
	am.registerRemoteControlClient(remote);
	sRemote = remote;
}
 
开发者ID:owoc,项目名称:teardrop,代码行数:29,代码来源:CompatIcs.java

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

示例8: setRemoteControlClientPlaybackState

import android.media.RemoteControlClient; //导入依赖的package包/类
/**
 * A function to control the Remote Control Client. It is needed for
 * compatibility with devices below Ice Cream Sandwich (4.0).
 *
 * @param state Playback state
 */
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
private void setRemoteControlClientPlaybackState(int state) {
    if (!AndroidUtil.isICSOrLater() || mRemoteControlClient == null)
        return;

    switch (state) {
        case MediaPlayer.Event.Playing:
            mRemoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_PLAYING);
            break;
        case MediaPlayer.Event.Paused:
            mRemoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_PAUSED);
            break;
        case MediaPlayer.Event.Stopped:
            mRemoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_STOPPED);
            break;
    }
}
 
开发者ID:jiaZengShen,项目名称:vlc_android_win,代码行数:24,代码来源:PlaybackService.java

示例9: changeRemoteControlClient

import android.media.RemoteControlClient; //导入依赖的package包/类
/**
 * Set up the remote control and tell the system we want to be the default receiver for the MEDIA buttons
 */
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
public void changeRemoteControlClient(AudioManager am, boolean acquire) {
    if (acquire) {
        Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
        mediaButtonIntent.setComponent(mRemoteControlClientReceiverComponent);
        PendingIntent mediaPendingIntent = PendingIntent.getBroadcast(this, 0, mediaButtonIntent, 0);

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

        mRemoteControlClient.setTransportControlFlags(
                RemoteControlClient.FLAG_KEY_MEDIA_PLAY |
                        RemoteControlClient.FLAG_KEY_MEDIA_PAUSE |
                        RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS |
                        RemoteControlClient.FLAG_KEY_MEDIA_NEXT |
                        RemoteControlClient.FLAG_KEY_MEDIA_STOP);
    } else {
        am.unregisterRemoteControlClient(mRemoteControlClient);
        mRemoteControlClient = null;
    }
}
 
开发者ID:jiaZengShen,项目名称:vlc_android_win,代码行数:26,代码来源:PlaybackService.java

示例10: setPlaybackState

import android.media.RemoteControlClient; //导入依赖的package包/类
/**
 * Propagate the playback state to the media session and the lock screen remote control.
 * <p/>
 * See also :
 * {@link fr.tvbarthel.cheerleader.library.media.MediaSessionWrapper#PLAYBACK_STATE_STOPPED}
 * {@link fr.tvbarthel.cheerleader.library.media.MediaSessionWrapper#PLAYBACK_STATE_PLAYING}
 * {@link fr.tvbarthel.cheerleader.library.media.MediaSessionWrapper#PLAYBACK_STATE_PAUSED}
 *
 * @param state playback state.
 */
@SuppressWarnings("deprecation")
public void setPlaybackState(int state) {
    switch (state) {
        case PLAYBACK_STATE_STOPPED:
            setRemoteControlClientPlaybackState(RemoteControlClient.PLAYSTATE_STOPPED);
            setMediaSessionCompatPlaybackState(PlaybackStateCompat.STATE_STOPPED);
            mMediaSession.setActive(false);
            break;
        case PLAYBACK_STATE_PLAYING:
            setRemoteControlClientPlaybackState(RemoteControlClient.PLAYSTATE_PLAYING);
            setMediaSessionCompatPlaybackState(PlaybackStateCompat.STATE_PLAYING);
            mMediaSession.setActive(true);
            break;
        case PLAYBACK_STATE_PAUSED:
            setRemoteControlClientPlaybackState(RemoteControlClient.PLAYSTATE_PAUSED);
            setMediaSessionCompatPlaybackState(PlaybackStateCompat.STATE_PAUSED);
            break;
        default:
            Log.e(TAG, "Unknown playback state.");
            break;
    }
}
 
开发者ID:tvbarthel,项目名称:Cheerleader,代码行数:33,代码来源:MediaSessionWrapper.java

示例11: getPlaybackStateActions

import android.media.RemoteControlClient; //导入依赖的package包/类
/**
 * A map between {@link android.media.RemoteControlClient} flags and {@link android.media.session.PlaybackState} actions.
 * @return The value to provide for {@link android.media.session.PlaybackState} for actions.
 */
private static long getPlaybackStateActions(final int transportControlFlags) {
    final Map<Integer, Long> FLAG_MAP = new HashMap<>();
    FLAG_MAP.put(RemoteControlClient.FLAG_KEY_MEDIA_STOP, PlaybackStateCompat.ACTION_STOP);
    FLAG_MAP.put(RemoteControlClient.FLAG_KEY_MEDIA_NEXT, PlaybackStateCompat.ACTION_SKIP_TO_NEXT);
    FLAG_MAP.put(RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS, PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS);
    FLAG_MAP.put(RemoteControlClient.FLAG_KEY_MEDIA_PAUSE, PlaybackStateCompat.ACTION_PAUSE);
    FLAG_MAP.put(RemoteControlClient.FLAG_KEY_MEDIA_FAST_FORWARD, PlaybackStateCompat.ACTION_FAST_FORWARD);
    FLAG_MAP.put(RemoteControlClient.FLAG_KEY_MEDIA_REWIND, PlaybackStateCompat.ACTION_REWIND);
    FLAG_MAP.put(RemoteControlClient.FLAG_KEY_MEDIA_PLAY, PlaybackStateCompat.ACTION_PLAY);
    FLAG_MAP.put(RemoteControlClient.FLAG_KEY_MEDIA_PLAY_PAUSE, PlaybackStateCompat.ACTION_PLAY_PAUSE);
    FLAG_MAP.put(RemoteControlClient.FLAG_KEY_MEDIA_RATING, PlaybackStateCompat.ACTION_SET_RATING);
    long actions = 0;
    for (Map.Entry<Integer, Long> flags : FLAG_MAP.entrySet()) {
        if ((transportControlFlags & flags.getKey()) == flags.getKey()) {
            if (actions == 0)
                actions = flags.getValue();
            else
                actions |= flags.getValue();
        }
    }
    return actions;
}
 
开发者ID:Tombarr,项目名称:Noyze,代码行数:27,代码来源:RemoteControlKitKat.java

示例12: getStateFromPlayState

import android.media.RemoteControlClient; //导入依赖的package包/类
static int getStateFromPlayState(PlayState playState) {
    switch (playState) {
        case BUFFERING:
            return RemoteControlClient.PLAYSTATE_BUFFERING;
        case ERROR:
            return RemoteControlClient.PLAYSTATE_ERROR;
        case FAST_FORWARDING:
            return RemoteControlClient.PLAYSTATE_FAST_FORWARDING;
        case PAUSED:
            return RemoteControlClient.PLAYSTATE_PAUSED;
        case PLAYING:
            return RemoteControlClient.PLAYSTATE_PLAYING;
        case REWINDING:
            return RemoteControlClient.PLAYSTATE_REWINDING;
        case SKIPPING_BACKWARDS:
            return RemoteControlClient.PLAYSTATE_SKIPPING_BACKWARDS;
        case SKIPPING_FORWARDS:
            return RemoteControlClient.PLAYSTATE_SKIPPING_FORWARDS;
        case STOPPED:
            return RemoteControlClient.PLAYSTATE_STOPPED;
        default:
            return RemoteControlClient.PLAYSTATE_ERROR;
    }
}
 
开发者ID:Tombarr,项目名称:Noyze,代码行数:25,代码来源:MediaProviderDelegate.java

示例13: wasPlayingRecently

import android.media.RemoteControlClient; //导入依赖的package包/类
public boolean wasPlayingRecently() {
    switch (mState) {
        case RemoteControlClient.PLAYSTATE_PLAYING:
        case RemoteControlClient.PLAYSTATE_FAST_FORWARDING:
        case RemoteControlClient.PLAYSTATE_REWINDING:
        case RemoteControlClient.PLAYSTATE_SKIPPING_FORWARDS:
        case RemoteControlClient.PLAYSTATE_SKIPPING_BACKWARDS:
        case RemoteControlClient.PLAYSTATE_BUFFERING:
            // actively playing or about to play
            return true;
        case RemoteControlClient.PLAYSTATE_STOPPED:
        case RemoteControlClient.PLAYSTATE_PAUSED:
        case RemoteControlClient.PLAYSTATE_ERROR:
            return ((SystemClock.elapsedRealtime() - mStateChangeTimeMs) < DISPLAY_TIMEOUT_MS);
        default:
            LOGE("PlaybackInfo", "Unknown playback state " + mState + " in wasPlayingRecently()");
            return false;
    }
}
 
开发者ID:Tombarr,项目名称:Noyze,代码行数:20,代码来源:PlaybackInfo.java

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

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


注:本文中的android.media.RemoteControlClient类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。