List of usage examples for android.support.v4.media.session PlaybackStateCompat STATE_PAUSED
int STATE_PAUSED
To view the source code for android.support.v4.media.session PlaybackStateCompat STATE_PAUSED.
Click Source Link
From source file:com.devalladolid.musictoday.MusicService.java
private void updateMediaSession(final String what) { int playState = mIsSupposedToBePlaying ? PlaybackStateCompat.STATE_PLAYING : PlaybackStateCompat.STATE_PAUSED; if (what.equals(PLAYSTATE_CHANGED) || what.equals(POSITION_CHANGED)) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { mSession.setPlaybackState(new PlaybackStateCompat.Builder().setState(playState, position(), 1.0f) .setActions(PlaybackStateCompat.ACTION_PLAY | PlaybackStateCompat.ACTION_PAUSE | PlaybackStateCompat.ACTION_PLAY_PAUSE | PlaybackStateCompat.ACTION_SKIP_TO_NEXT | PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS) .build());//from www . j av a 2 s. c o m } } else if (what.equals(META_CHANGED) || what.equals(QUEUE_CHANGED)) { Bitmap 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); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { 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()); mSession.setPlaybackState(new PlaybackStateCompat.Builder().setState(playState, position(), 1.0f) .setActions(PlaybackStateCompat.ACTION_PLAY | PlaybackStateCompat.ACTION_PAUSE | PlaybackStateCompat.ACTION_PLAY_PAUSE | PlaybackStateCompat.ACTION_SKIP_TO_NEXT | PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS) .build()); } } }
From source file:com.naman14.timber.musicplayer.MusicService.java
private void updateMediaSession(final String what) { int playState = mIsSupposedToBePlaying ? PlaybackStateCompat.STATE_PLAYING : PlaybackStateCompat.STATE_PAUSED; if (what.equals(PLAYSTATE_CHANGED) || what.equals(POSITION_CHANGED)) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { mSession.setPlaybackState(new PlaybackStateCompat.Builder().setState(playState, position(), 1.0f) .setActions(PlaybackStateCompat.ACTION_PLAY | PlaybackStateCompat.ACTION_PAUSE | PlaybackStateCompat.ACTION_PLAY_PAUSE | PlaybackStateCompat.ACTION_SKIP_TO_NEXT | PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS) .build());//from ww w . ja va 2 s. co m } } else if (what.equals(META_CHANGED) || what.equals(QUEUE_CHANGED)) { //TODO: Replace below Image download using Picasso Bitmap 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); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { 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().size()) .putString(MediaMetadataCompat.METADATA_KEY_GENRE, getGenreName()) .putBitmap(MediaMetadataCompat.METADATA_KEY_ALBUM_ART, mShowAlbumArtOnLockscreen ? albumArt : null) .build()); mSession.setPlaybackState(new PlaybackStateCompat.Builder().setState(playState, position(), 1.0f) .setActions(PlaybackStateCompat.ACTION_PLAY | PlaybackStateCompat.ACTION_PAUSE | PlaybackStateCompat.ACTION_PLAY_PAUSE | PlaybackStateCompat.ACTION_SKIP_TO_NEXT | PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS) .build()); } } }
From source file:com.bluros.music.MusicService.java
private void updateMediaSession(final String what) { int playState = mIsSupposedToBePlaying ? PlaybackStateCompat.STATE_PLAYING : PlaybackStateCompat.STATE_PAUSED; if (what.equals(PLAYSTATE_CHANGED) || what.equals(POSITION_CHANGED)) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { mSession.setPlaybackState(new PlaybackStateCompat.Builder().setState(playState, position(), 1.0f) .setActions(PlaybackStateCompat.ACTION_PLAY | PlaybackStateCompat.ACTION_PAUSE | PlaybackStateCompat.ACTION_PLAY_PAUSE | PlaybackStateCompat.ACTION_SKIP_TO_NEXT | PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS) .build());//from w w w. j a v a 2s . co m } } else if (what.equals(META_CHANGED) || what.equals(QUEUE_CHANGED)) { Bitmap albumArt = ImageLoader.getInstance() .loadImageSync(MusicUtils.getAlbumArtUri(getAlbumId()).toString()); if (albumArt != null) { Bitmap.Config config = albumArt.getConfig(); if (config == null) { config = Bitmap.Config.ARGB_8888; } albumArt = albumArt.copy(config, false); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { 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()); mSession.setPlaybackState(new PlaybackStateCompat.Builder().setState(playState, position(), 1.0f) .setActions(PlaybackStateCompat.ACTION_PLAY | PlaybackStateCompat.ACTION_PAUSE | PlaybackStateCompat.ACTION_PLAY_PAUSE | PlaybackStateCompat.ACTION_SKIP_TO_NEXT | PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS) .build()); } } }
From source file:androidx.media.widget.VideoView2.java
private int getCorrespondingPlaybackState() { switch (mCurrentState) { case STATE_ERROR: return PlaybackStateCompat.STATE_ERROR; case STATE_IDLE: return PlaybackStateCompat.STATE_NONE; case STATE_PREPARING: return PlaybackStateCompat.STATE_CONNECTING; case STATE_PREPARED: return PlaybackStateCompat.STATE_PAUSED; case STATE_PLAYING: return PlaybackStateCompat.STATE_PLAYING; case STATE_PAUSED: return PlaybackStateCompat.STATE_PAUSED; case STATE_PLAYBACK_COMPLETED: return PlaybackStateCompat.STATE_STOPPED; default:// ww w . jav a2s. co m return -1; } }
From source file:singh.amandeep.musicplayer.MusicService.java
private void updateMediaSession(final String what) { int playState = mIsSupposedToBePlaying ? PlaybackStateCompat.STATE_PLAYING : PlaybackStateCompat.STATE_PAUSED; final Uri mAlbumArtUri = ContentUris.withAppendedId(sArtUri, getAlbumId()); final Bitmap defBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.default_album_art); final MediaMetadataCompat.Builder builder = 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, ImageLoader.getAlbumArt(getApplicationContext(), getAlbumId())); mSession.setMetadata(builder.build()); if (what.equals(PLAYSTATE_CHANGED) || what.equals(POSITION_CHANGED)) { mSession.setPlaybackState(//from www . ja v a 2 s .c o m new PlaybackStateCompat.Builder().setState(playState, position(), 1.0f).build()); } else if (what.equals(META_CHANGED) || what.equals(QUEUE_CHANGED)) { mSession.setPlaybackState( new PlaybackStateCompat.Builder().setState(playState, position(), 1.0f).build()); } }
From source file:com.cyanogenmod.eleven.MusicPlaybackService.java
private void updateMediaSession(final String what) { int playState = mIsSupposedToBePlaying ? PlaybackStateCompat.STATE_PLAYING : PlaybackStateCompat.STATE_PAUSED; long playBackStateActions = PlaybackStateCompat.ACTION_PLAY | PlaybackStateCompat.ACTION_PLAY_PAUSE | PlaybackStateCompat.ACTION_PLAY_FROM_MEDIA_ID | PlaybackStateCompat.ACTION_PAUSE | PlaybackStateCompat.ACTION_SKIP_TO_NEXT | PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS; if (what.equals(PLAYSTATE_CHANGED) || what.equals(POSITION_CHANGED)) { mSession.setPlaybackState(new PlaybackStateCompat.Builder().setActions(playBackStateActions) .setState(playState, position(), 1.0f).build()); } else if (what.equals(META_CHANGED) || what.equals(QUEUE_CHANGED)) { Bitmap albumArt = getAlbumArt(false).getBitmap(); 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; }//from www .j a v a 2 s. c o m 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()); mSession.setPlaybackState(new PlaybackStateCompat.Builder().setActions(playBackStateActions) .setState(playState, position(), 1.0f).build()); } }