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


Java PlaybackState.ACTION_SKIP_TO_NEXT屬性代碼示例

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


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

示例1: getAvailableActions

private long getAvailableActions(int nextState) {
    long actions = PlaybackState.ACTION_PLAY |
            PlaybackState.ACTION_PLAY_FROM_MEDIA_ID |
            PlaybackState.ACTION_PLAY_FROM_SEARCH |
            PlaybackState.ACTION_SKIP_TO_NEXT |
            PlaybackState.ACTION_SKIP_TO_PREVIOUS |
            PlaybackState.ACTION_FAST_FORWARD |
            PlaybackState.ACTION_REWIND |
            PlaybackState.ACTION_PAUSE;

    if (nextState == PlaybackState.STATE_PLAYING) {
        actions |= PlaybackState.ACTION_PAUSE;
    }

    return actions;
}
 
開發者ID:nejtv,項目名稱:androidtv-sample,代碼行數:16,代碼來源:PlaybackOverlayFragment.java

示例2: getAvailableActions

private long getAvailableActions() {
    long actions = PlaybackState.ACTION_PLAY | PlaybackState.ACTION_PLAY_FROM_MEDIA_ID |
            PlaybackState.ACTION_PLAY_FROM_SEARCH;
    if (mPlayingQueue == null || mPlayingQueue.isEmpty()) {
        return actions;
    }
    if (mPlayback.isPlaying()) {
        actions |= PlaybackState.ACTION_PAUSE;
    }
    if (mCurrentIndexOnQueue > 0) {
        actions |= PlaybackState.ACTION_SKIP_TO_PREVIOUS;
    }
    if (mCurrentIndexOnQueue < mPlayingQueue.size() - 1) {
        actions |= PlaybackState.ACTION_SKIP_TO_NEXT;
    }
    return actions;
}
 
開發者ID:mrinalgit-dev,項目名稱:MrinalMusicPlayer,代碼行數:17,代碼來源:MusicService.java

示例3: getAvailableActions

private long getAvailableActions() {
    long actions = PlaybackState.ACTION_PLAY | PlaybackState.ACTION_PLAY_FROM_MEDIA_ID | PlaybackState.ACTION_PLAY_FROM_SEARCH;
    MessageObject playingMessageObject = MediaController.getInstance().getPlayingMessageObject();
    if (playingMessageObject != null) {
        if (!MediaController.getInstance().isAudioPaused()) {
            actions |= PlaybackState.ACTION_PAUSE;
        }
        actions |= PlaybackState.ACTION_SKIP_TO_PREVIOUS;
        actions |= PlaybackState.ACTION_SKIP_TO_NEXT;
    }
    return actions;
}
 
開發者ID:MLNO,項目名稱:airgram,代碼行數:12,代碼來源:MusicBrowserService.java

示例4: getAvailableActions

private long getAvailableActions(int nextState) {
	long actions = PlaybackState.ACTION_PLAY |
			PlaybackState.ACTION_SKIP_TO_NEXT |
			PlaybackState.ACTION_SKIP_TO_PREVIOUS |
			PlaybackState.ACTION_FAST_FORWARD |
			PlaybackState.ACTION_REWIND |
			PlaybackState.ACTION_PAUSE;

	if (nextState == PlaybackState.STATE_PLAYING) {
		actions |= PlaybackState.ACTION_PAUSE;
	}

	return actions;
}
 
開發者ID:NiciDieNase,項目名稱:chaosflix-leanback,代碼行數:14,代碼來源:OverlayFragment.java

示例5: getAvailableActions

private long getAvailableActions() {
    long actions = PlaybackState.ACTION_PLAY |
            PlaybackState.ACTION_PLAY_FROM_MEDIA_ID |
            PlaybackState.ACTION_PLAY_FROM_SEARCH |
            PlaybackState.ACTION_SKIP_TO_NEXT |
            PlaybackState.ACTION_SKIP_TO_PREVIOUS |
            PlaybackState.ACTION_FAST_FORWARD |
            PlaybackState.ACTION_REWIND;

    if (mPlaybackState == LeanbackPlaybackState.PLAYING) actions |= PlaybackState.ACTION_PAUSE;
    return actions;
}
 
開發者ID:hitherejoe,項目名稱:PictureInPicturePlayground,代碼行數:12,代碼來源:PlaybackActivity.java

示例6: availableActions

private long availableActions() {
    Log.d ( TAG, "availableActions()...") ;
    long actions = PlaybackState.ACTION_PLAY | PlaybackState.ACTION_PLAY_FROM_MEDIA_ID |
            PlaybackState.ACTION_SKIP_TO_NEXT  | PlaybackState.ACTION_SKIP_TO_PREVIOUS
            | PlaybackState.ACTION_SKIP_TO_NEXT |PlaybackState.ACTION_PLAY_FROM_SEARCH
            | PlaybackState.ACTION_PLAY_FROM_URI ;
    if (isPlaying()) {
        actions |= PlaybackState.ACTION_PAUSE;
    }
    return actions;
}
 
開發者ID:smitzey,項目名稱:AndroidAutoTourGuide,代碼行數:11,代碼來源:AudioPlaybackHelper.java

示例7: getAvailableActions

private long getAvailableActions() {
    long actions = PlaybackState.ACTION_PLAY | PlaybackState.ACTION_PLAY_FROM_MEDIA_ID |
            PlaybackState.ACTION_PLAY_FROM_SEARCH |
            PlaybackState.ACTION_SKIP_TO_NEXT  | PlaybackState.ACTION_SKIP_TO_PREVIOUS;
    if (isPlaying()) {
        actions |= PlaybackState.ACTION_PAUSE;
    }
    return actions;
}
 
開發者ID:googlecodelabs,項目名稱:android-music-player,代碼行數:9,代碼來源:PlaybackManager.java

示例8: updateMediaSession

private void updateMediaSession(final String what) {
    LogUtils.i(TAG, "updateMediaSession what : " + what);
    int playState = mIsSupposedToBePlaying
            ? PlaybackState.STATE_PLAYING
            : PlaybackState.STATE_PAUSED;

    long playBackStateActions = PlaybackState.ACTION_PLAY |
            PlaybackState.ACTION_PLAY_PAUSE |
            PlaybackState.ACTION_PLAY_FROM_MEDIA_ID |
            PlaybackState.ACTION_PAUSE |
            PlaybackState.ACTION_SKIP_TO_NEXT |
            PlaybackState.ACTION_SKIP_TO_PREVIOUS |
            PlaybackState.ACTION_STOP;

    if (what.equals(MusicServiceConstants.PLAYSTATE_CHANGED) || what.equals(MusicServiceConstants.POSITION_CHANGED)) {
        mSession.setPlaybackState(new PlaybackState.Builder()
                .setActions(playBackStateActions)
                .setActiveQueueItemId(getAudioId())
                .setState(playState, position(), 1.0f).build());
    } else if (what.equals(META_CHANGED) || what.equals(MusicServiceConstants.QUEUE_CHANGED)) {
        LogUtils.i(TAG, "sadsadsadsad thread id : " + Thread.currentThread().getId() + "name : " + Thread.currentThread().getName());
        /*if (albumArt != null) {
            // RemoteControlClient wants to recycle the bitmaps thrown at it, so we need
            // to make sure not to hand out our cache copy
            Bitmap.Config config = albumArt.getConfig();
            if (config == null) {
                config = Bitmap.Config.ARGB_8888;
            }
            albumArt = albumArt.copy(config, false);
        }*/

        /*mSession.setMetadata(new MediaMetadataCompat.Builder()
                .putString(MediaMetadataCompat.METADATA_KEY_ARTIST, getArtistName())
                .putString(MediaMetadataCompat.METADATA_KEY_ALBUM_ARTIST, getAlbumArtistName())
                .putString(MediaMetadataCompat.METADATA_KEY_ALBUM, getAlbumName())
                .putString(MediaMetadataCompat.METADATA_KEY_TITLE, getTrackName())
                .putLong(MediaMetadataCompat.METADATA_KEY_DURATION, duration())
                .putLong(MediaMetadataCompat.METADATA_KEY_TRACK_NUMBER, getQueuePosition() + 1)
                .putLong(MediaMetadataCompat.METADATA_KEY_NUM_TRACKS, getQueue().length)
                .putString(MediaMetadataCompat.METADATA_KEY_GENRE, getGenreName())
                .putBitmap(MediaMetadataCompat.METADATA_KEY_ALBUM_ART,
                        mShowAlbumArtOnLockscreen ? albumArt : null)
                .build());*/

        if (what.equals(MusicServiceConstants.QUEUE_CHANGED)) {
            updateMediaSessionQueue();
        }

        mSession.setPlaybackState(new PlaybackState.Builder()
                .setActions(playBackStateActions)
                .setActiveQueueItemId(getAudioId())
                .setState(playState, position(), 1.0f).build());
    }
    LogUtils.i(TAG, "updateMediaSession finished");
}
 
開發者ID:komamj,項目名稱:KomaMusic,代碼行數:55,代碼來源:MusicService.java

示例9: update

public void update(MediaMetadata metadata, PlaybackState state, MediaSession.Token token) {
    if (state == null || state.getState() == PlaybackState.STATE_STOPPED ||
            state.getState() == PlaybackState.STATE_NONE) {
        muziKarMusicService.stopForeground(true);
        try {
            muziKarMusicService.unregisterReceiver(this);
        } catch (IllegalArgumentException ex) {
            Log.w ( TAG, "update metadata=" + metadata) ;
        }
        muziKarMusicService.stopSelf();
        return;
    }
    if (metadata == null) {
        return;
    }
    boolean isPlaying = state.getState() == PlaybackState.STATE_PLAYING;
    Notification.Builder notificationBuilder = new Notification.Builder(muziKarMusicService);
    MediaDescription description = metadata.getDescription();

    notificationBuilder
            .setContentTitle(description.getTitle())
            .setVisibility(Notification.VISIBILITY_PUBLIC)
            .setOngoing(isPlaying)
            .setWhen(isPlaying ? System.currentTimeMillis() - state.getPosition() : 0)
            .setShowWhen(isPlaying)
            .setUsesChronometer(isPlaying)
            .setContentText(description.getSubtitle())
            .setLargeIcon(LocalMusicSource.getAlbumBitmap(muziKarMusicService, description.getMediaId()))
            .setStyle(new Notification.MediaStyle().setMediaSession(token).setShowActionsInCompactView(0, 1, 2))
            .setColor(muziKarMusicService.getApplication().getResources().getColor(R.color.colorPrimary))
            .setSmallIcon(R.drawable.art);

    if ((state.getActions() & PlaybackState.ACTION_SKIP_TO_PREVIOUS) != 0) {
        notificationBuilder.addAction(previousAction);
    }

    notificationBuilder.addAction(isPlaying ? pauseAction : playAction);
    if ((state.getActions() & PlaybackState.ACTION_SKIP_TO_NEXT) != 0) {
        notificationBuilder.addAction(nextAction);
    }

    Notification notification = notificationBuilder.build();

    if (isPlaying && !runningFlag) {
        muziKarMusicService.startService(new Intent(muziKarMusicService.getApplicationContext(), MuziKarMusicService.class));
        muziKarMusicService.startForeground(NOTIFICATION_ID, notification);
        runningFlag = true;
    } else {
        if (!isPlaying) {
            muziKarMusicService.stopForeground(false);
            runningFlag = false;
        }
        notificationManager.notify(NOTIFICATION_ID, notification);
    }
}
 
開發者ID:smitzey,項目名稱:AndroidAutoTourGuide,代碼行數:55,代碼來源:PlaybackControlEventBroadcastReceiver.java

示例10: createNotification

private Notification createNotification() {
    LogHelper.d(TAG, "updateNotificationMetadata. mMetadata=" + mMetadata);
    if (mMetadata == null || mPlaybackState == null) {
        return null;
    }

    Notification.Builder notificationBuilder = new Notification.Builder(mService);
    int playPauseButtonPosition = 0;

    // If skip to previous action is enabled
    if ((mPlaybackState.getActions() & PlaybackState.ACTION_SKIP_TO_PREVIOUS) != 0) {
        notificationBuilder.addAction(R.drawable.ic_skip_previous_white_24dp,
                    mService.getString(R.string.label_previous), mPreviousIntent);

        // If there is a "skip to previous" button, the play/pause button will
        // be the second one. We need to keep track of it, because the MediaStyle notification
        // requires to specify the index of the buttons (actions) that should be visible
        // when in compact view.
        playPauseButtonPosition = 1;
    }

    addPlayPauseAction(notificationBuilder);

    // If skip to next action is enabled
    if ((mPlaybackState.getActions() & PlaybackState.ACTION_SKIP_TO_NEXT) != 0) {
        notificationBuilder.addAction(R.drawable.ic_skip_next_white_24dp,
            mService.getString(R.string.label_next), mNextIntent);
    }

    MediaDescription description = mMetadata.getDescription();

    String fetchArtUrl = null;
    Bitmap art = null;
    if (description.getIconUri() != null) {
        // This sample assumes the iconUri will be a valid URL formatted String, but
        // it can actually be any valid Android Uri formatted String.
        // async fetch the album art icon
        String artUrl = description.getIconUri().toString();
        art = AlbumArtCache.getInstance().getBigImage(artUrl);
        if (art == null) {
            fetchArtUrl = artUrl;
            // use a placeholder art while the remote art is being downloaded
            art = BitmapFactory.decodeResource(mService.getResources(),
                R.drawable.ic_default_art);
        }
    }

    notificationBuilder
            .setStyle(new Notification.MediaStyle()
                .setShowActionsInCompactView(
                    new int[]{playPauseButtonPosition})  // show only play/pause in compact view
                .setMediaSession(mSessionToken))
            .setColor(mNotificationColor)
            .setSmallIcon(R.drawable.ic_notification)
            .setVisibility(Notification.VISIBILITY_PUBLIC)
            .setUsesChronometer(true)
            .setContentIntent(createContentIntent(description))
            .setContentTitle(description.getTitle())
            .setContentText(description.getSubtitle())
            .setLargeIcon(art);

    if (mController != null && mController.getExtras() != null) {
        String castName = mController.getExtras().getString(MusicService.EXTRA_CONNECTED_CAST);
        if (castName != null) {
            String castInfo = mService.getResources()
                    .getString(R.string.casting_to_device, castName);
            notificationBuilder.setSubText(castInfo);
            notificationBuilder.addAction(R.drawable.ic_close_black_24dp,
                    mService.getString(R.string.stop_casting), mStopCastIntent);
        }
    }

    setNotificationPlaybackState(notificationBuilder);
    if (fetchArtUrl != null) {
        fetchBitmapFromURLAsync(fetchArtUrl, notificationBuilder);
    }

    return notificationBuilder.build();
}
 
開發者ID:mrinalgit-dev,項目名稱:MrinalMusicPlayer,代碼行數:79,代碼來源:MediaNotificationManager.java

示例11: update

public void update(MediaMetadata metadata, PlaybackState state, MediaSession.Token token) {
    if (state == null || state.getState() == PlaybackState.STATE_STOPPED ||
            state.getState() == PlaybackState.STATE_NONE) {
        mService.stopForeground(true);
        try {
            mService.unregisterReceiver(this);
        } catch (IllegalArgumentException ex) {
            // ignore receiver not registered
        }
        mService.stopSelf();
        return;
    }
    if (metadata == null) {
        return;
    }
    boolean isPlaying = state.getState() == PlaybackState.STATE_PLAYING;
    Notification.Builder notificationBuilder = new Notification.Builder(mService);
    MediaDescription description = metadata.getDescription();

    notificationBuilder
            .setStyle(new Notification.MediaStyle()
                    .setMediaSession(token)
                    .setShowActionsInCompactView(0, 1, 2))
            .setColor(mService.getApplication().getResources().getColor(R.color.notification_bg))
            .setSmallIcon(R.drawable.ic_notification)
            .setVisibility(Notification.VISIBILITY_PUBLIC)
            .setContentIntent(createContentIntent())
            .setContentTitle(description.getTitle())
            .setContentText(description.getSubtitle())
            .setLargeIcon(MusicLibrary.getAlbumBitmap(mService, description.getMediaId()))
            .setOngoing(isPlaying)
            .setWhen(isPlaying ? System.currentTimeMillis() - state.getPosition() : 0)
            .setShowWhen(isPlaying)
            .setUsesChronometer(isPlaying);

    // If skip to next action is enabled
    if ((state.getActions() & PlaybackState.ACTION_SKIP_TO_PREVIOUS) != 0) {
        notificationBuilder.addAction(mPrevAction);
    }

    notificationBuilder.addAction(isPlaying ? mPauseAction : mPlayAction);

    // If skip to prev action is enabled
    if ((state.getActions() & PlaybackState.ACTION_SKIP_TO_NEXT) != 0) {
        notificationBuilder.addAction(mNextAction);
    }

    Notification notification = notificationBuilder.build();

    if (isPlaying && !mStarted) {
        mService.startService(new Intent(mService.getApplicationContext(), MusicService.class));
        mService.startForeground(NOTIFICATION_ID, notification);
        mStarted = true;
    } else {
        if (!isPlaying) {
            mService.stopForeground(false);
            mStarted = false;
        }
        mNotificationManager.notify(NOTIFICATION_ID, notification);
    }
}
 
開發者ID:googlecodelabs,項目名稱:android-music-player,代碼行數:61,代碼來源:MediaNotificationManager.java


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