List of usage examples for android.media.session PlaybackState STATE_PAUSED
int STATE_PAUSED
To view the source code for android.media.session PlaybackState STATE_PAUSED.
Click Source Link
From source file:com.appdevper.mediaplayer.activity.FullScreenPlayerActivity.java
private void updateProgress() { if (mLastPlaybackState == null) { return;//from w ww . j a va 2s . c o m } long currentPosition = mLastPlaybackState.getPosition(); if (mLastPlaybackState.getState() != PlaybackState.STATE_PAUSED) { long timeDelta = SystemClock.elapsedRealtime() - mLastPlaybackState.getLastPositionUpdateTime(); currentPosition += (int) timeDelta * mLastPlaybackState.getPlaybackSpeed(); } mSeekbar.setProgress((int) currentPosition); }
From source file:com.sgottard.tvdemoapp.ui.PlaybackOverlayFragment.java
private void prev(boolean autoPlay) { if (--mCurrentItem < 0) { mCurrentItem = mItems.size() - 1; }/*from w ww. j av a 2s . c om*/ Bundle bundle = new Bundle(); bundle.putBoolean(PlaybackActivity.AUTO_PLAY, autoPlay); if (autoPlay) { mCurrentPlaybackState = PlaybackState.STATE_PAUSED; } mMediaController.getTransportControls().playFromMediaId(mItems.get(mCurrentItem).getId(), bundle); mFfwRwdSpeed = INITIAL_SPEED; }
From source file:com.aengbee.android.leanback.ui.PlaybackOverlayCustomFragment.java
private void pause() { mPauseTransient = false;// w w w. ja v a 2 s .c o m if (mPlayer == null) { setPlaybackState(PlaybackState.STATE_NONE); return; } if (mGlue.isMediaPlaying()) { mPlayer.getPlayerControl().pause(); setPlaybackState(PlaybackState.STATE_PAUSED); } }
From source file:de.kraenksoft.c3tv.ui.PlaybackOverlayFragment.java
private void playVideo(Video v, Bundle extras) { setVideoPath(v.videoUrl); setPlaybackState(PlaybackState.STATE_PAUSED); updateMetadata(v); playPause(extras.getBoolean(AUTO_PLAY)); }
From source file:org.mythtv.android.presentation.view.fragment.TvPlaybackOverlayFragment.java
private void playVideo(VideoModel v, Bundle extras) { Log.d(TAG, "Playing video " + v.title + " with url = " + v.videoUrl); Log.d(TAG, "Video: " + v.toString()); setVideoPath(v.videoUrl);//w ww . j a va2 s . c o m setPlaybackState(PlaybackState.STATE_PAUSED); updateMetadata(v); playPause(extras.getBoolean(AUTO_PLAY)); }
From source file:com.aengbee.android.leanback.ui.PlaybackOverlayCustomFragment.java
private void playVideo(Video video, Bundle extras) { updateSelectedVideo(video);/*from w w w . ja v a 2s. c o m*/ preparePlayer(); setPlaybackState(PlaybackState.STATE_PAUSED); if (extras.getBoolean(AUTO_PLAY)) { play(); } else { pause(); } }
From source file:com.koma.music.service.MusicService.java
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) {/* w ww.ja v a2 s . co m*/ 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"); }
From source file:com.av.remusic.service.MediaService.java
private void updateMediaSession(final String what) { int playState = mIsSupposedToBePlaying ? PlaybackState.STATE_PLAYING : PlaybackState.STATE_PAUSED; if (what.equals(PLAYSTATE_CHANGED) || what.equals(POSITION_CHANGED)) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { mSession.setPlaybackState(new PlaybackState.Builder().setState(playState, position(), 1.0f) .setActions(PlaybackState.ACTION_PLAY | PlaybackState.ACTION_PAUSE | PlaybackState.ACTION_PLAY_PAUSE | PlaybackState.ACTION_SKIP_TO_NEXT | PlaybackState.ACTION_SKIP_TO_PREVIOUS) .build());// w w w. j av a2 s .c o m } } else if (what.equals(META_CHANGED) || what.equals(QUEUE_CHANGED)) { //Bitmap albumArt = ImageLoader.getInstance().loadImageSync(CommonUtils.getAlbumArtUri(getAlbumId()).toString()); Bitmap albumArt = null; 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 MediaMetadata.Builder().putString(MediaMetadata.METADATA_KEY_ARTIST, getArtistName()) .putString(MediaMetadata.METADATA_KEY_ALBUM_ARTIST, getAlbumArtistName()) .putString(MediaMetadata.METADATA_KEY_ALBUM, getAlbumName()) .putString(MediaMetadata.METADATA_KEY_TITLE, getTrackName()) .putLong(MediaMetadata.METADATA_KEY_DURATION, duration()) .putLong(MediaMetadata.METADATA_KEY_TRACK_NUMBER, getQueuePosition() + 1) .putLong(MediaMetadata.METADATA_KEY_NUM_TRACKS, getQueue().length) .putString(MediaMetadata.METADATA_KEY_GENRE, getGenreName()) .putBitmap(MediaMetadata.METADATA_KEY_ALBUM_ART, mShowAlbumArtOnLockscreen ? albumArt : null) .build()); mSession.setPlaybackState(new PlaybackState.Builder().setState(playState, position(), 1.0f) .setActions(PlaybackState.ACTION_PLAY | PlaybackState.ACTION_PAUSE | PlaybackState.ACTION_PLAY_PAUSE | PlaybackState.ACTION_SKIP_TO_NEXT | PlaybackState.ACTION_SKIP_TO_PREVIOUS) .build()); } } }