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


Java PlaybackState.STATE_STOPPED屬性代碼示例

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


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

示例1: stop

@Override
public void stop(boolean notifyListeners) {
    mState = PlaybackState.STATE_STOPPED;
    if (notifyListeners && mCallback != null) {
        mCallback.onPlaybackStatusChanged(mState);
    }
    mCurrentPosition = getCurrentStreamPosition();
    // Give up Audio focus
    giveUpAudioFocus();
    unregisterAudioNoisyReceiver();
    // Relax all resources
    relaxResources(true);
    if (mWifiLock.isHeld()) {
        mWifiLock.release();
    }
}
 
開發者ID:mrinalgit-dev,項目名稱:MrinalMusicPlayer,代碼行數:16,代碼來源:LocalPlayback.java

示例2: onClick

@Override
public void onClick(View v) {
    PlaybackState stateObj = getActivity().getMediaController().getPlaybackState();
    final int state = stateObj == null ?
            PlaybackState.STATE_NONE : stateObj.getState();
    LogHelper.d(TAG, "Button pressed, in state " + state);
    switch (v.getId()) {
        case R.id.play_pause:
            LogHelper.d(TAG, "Play button pressed, in state " + state);
            if (state == PlaybackState.STATE_PAUSED ||
                    state == PlaybackState.STATE_STOPPED ||
                    state == PlaybackState.STATE_NONE) {
                playMedia();
            } else if (state == PlaybackState.STATE_PLAYING ||
                    state == PlaybackState.STATE_BUFFERING ||
                    state == PlaybackState.STATE_CONNECTING) {
                pauseMedia();
            }
            break;
    }
}
 
開發者ID:mrinalgit-dev,項目名稱:MrinalMusicPlayer,代碼行數:21,代碼來源:PlaybackControlsFragment.java

示例3: shouldShowControls

/**
 * Check if the MediaSession is active and in a "playback-able" state
 * (not NONE and not STOPPED).
 *
 * @return true if the MediaSession's state requires playback controls to be visible.
 */
protected boolean shouldShowControls() {
    MediaController mediaController = getMediaController();
    if (mediaController == null ||
        mediaController.getMetadata() == null ||
        mediaController.getPlaybackState() == null) {
        return false;
    }
    switch (mediaController.getPlaybackState().getState()) {
        case PlaybackState.STATE_ERROR:
        case PlaybackState.STATE_NONE:
        case PlaybackState.STATE_STOPPED:
            return false;
        default:
            return true;
    }
}
 
開發者ID:mrinalgit-dev,項目名稱:MrinalMusicPlayer,代碼行數:22,代碼來源:BaseActivity.java

示例4: onClick

@Override
public void onClick(View v) {
    final int state = mCurrentState == null ?
            PlaybackState.STATE_NONE : mCurrentState.getState();
    if (state == PlaybackState.STATE_PAUSED ||
            state == PlaybackState.STATE_STOPPED ||
            state == PlaybackState.STATE_NONE) {

        if (mCurrentMetadata == null) {
            mCurrentMetadata = MusicLibrary.getMetadata(MusicPlayerActivity.this,
                    MusicLibrary.getMediaItems().get(0).getMediaId());
            updateMetadata(mCurrentMetadata);
        }
        getMediaController().getTransportControls().playFromMediaId(
                mCurrentMetadata.getDescription().getMediaId(), null);

    } else {
        getMediaController().getTransportControls().pause();
    }
}
 
開發者ID:googlecodelabs,項目名稱:android-music-player,代碼行數:20,代碼來源:MusicPlayerActivity.java

示例5: updatePlaybackState

private void updatePlaybackState(String error) {
    long position = PlaybackState.PLAYBACK_POSITION_UNKNOWN;
    MessageObject playingMessageObject = MediaController.getInstance().getPlayingMessageObject();
    if (playingMessageObject != null) {
        position = playingMessageObject.audioProgressSec * 1000;
    }

    PlaybackState.Builder stateBuilder = new PlaybackState.Builder().setActions(getAvailableActions());
    int state;
    if (playingMessageObject == null) {
        state = PlaybackState.STATE_STOPPED;
    } else {
        if (MediaController.getInstance().isDownloadingCurrentMessage()) {
            state = PlaybackState.STATE_BUFFERING;
        } else {
            state = MediaController.getInstance().isAudioPaused() ? PlaybackState.STATE_PAUSED : PlaybackState.STATE_PLAYING;
        }
    }

    if (error != null) {
        stateBuilder.setErrorMessage(error);
        state = PlaybackState.STATE_ERROR;
    }
    stateBuilder.setState(state, position, 1.0f, SystemClock.elapsedRealtime());
    if (playingMessageObject != null) {
        stateBuilder.setActiveQueueItemId(MediaController.getInstance().getPlayingMessageObjectNum());
    } else {
        stateBuilder.setActiveQueueItemId(0);
    }

    mediaSession.setPlaybackState(stateBuilder.build());
}
 
開發者ID:MLNO,項目名稱:airgram,代碼行數:32,代碼來源:MusicBrowserService.java

示例6: updatePlaybackState

private void updatePlaybackState(PlaybackStateCompat state) {
    mCurrentState = state;
    if (state == null
            || state.getState() == PlaybackState.STATE_PAUSED
            || state.getState() == PlaybackState.STATE_STOPPED) {
        mPlayPause.setImageDrawable(
                ContextCompat.getDrawable(this, R.drawable.ic_play_arrow_black_36dp));
    } else {
        mPlayPause.setImageDrawable(
                ContextCompat.getDrawable(this, R.drawable.ic_pause_black_36dp));
    }
    mPlaybackControls.setVisibility(state == null ? View.GONE : View.VISIBLE);
}
 
開發者ID:googlecodelabs,項目名稱:musicplayer-devices,代碼行數:13,代碼來源:MusicPlayerActivity.java

示例7: onClick

@Override
public void onClick(View v) {
    final int state =
            mCurrentState == null
                    ? PlaybackStateCompat.STATE_NONE
                    : mCurrentState.getState();
    if (state == PlaybackState.STATE_PAUSED
            || state == PlaybackState.STATE_STOPPED
            || state == PlaybackState.STATE_NONE) {

        if (mCurrentMetadata == null) {
            mCurrentMetadata =
                    MusicLibrary.getMetadata(
                            MusicPlayerActivity.this,
                            MusicLibrary.getMediaItems().get(0).getMediaId());
            updateMetadata(mCurrentMetadata);
        }
        MediaControllerCompat.getMediaController(MusicPlayerActivity.this)
                .getTransportControls()
                .playFromMediaId(
                        mCurrentMetadata.getDescription().getMediaId(), null);
    } else {
        MediaControllerCompat.getMediaController(MusicPlayerActivity.this)
                .getTransportControls()
                .pause();
    }
}
 
開發者ID:googlecodelabs,項目名稱:musicplayer-devices,代碼行數:27,代碼來源:MusicPlayerActivity.java

示例8: stop

public void stop() {
    Log.d ( TAG, "stop.." ) ;
    playbackState = PlaybackState.STATE_STOPPED;
    updatePlaybackState();
    audioManager.abandonAudioFocus(this);

    if (mediaPlayer != null) {
        mediaPlayer.reset();
        mediaPlayer.release();
    }
}
 
開發者ID:smitzey,項目名稱:AndroidAutoTourGuide,代碼行數:11,代碼來源:AudioPlaybackHelper.java

示例9: stop

@Override
public void stop(boolean notifyListeners) {
    mCastManager.removeVideoCastConsumer(mCastConsumer);
    mState = PlaybackState.STATE_STOPPED;
    if (notifyListeners && mCallback != null) {
        mCallback.onPlaybackStatusChanged(mState);
    }
}
 
開發者ID:mrinalgit-dev,項目名稱:MrinalMusicPlayer,代碼行數:8,代碼來源:CastPlayback.java

示例10: onPlaybackStateChanged

private void onPlaybackStateChanged(PlaybackState state) {
    LogHelper.d(TAG, "onPlaybackStateChanged ", state);
    if (getActivity() == null) {
        LogHelper.w(TAG, "onPlaybackStateChanged called when getActivity null," +
                "this should not happen if the callback was properly unregistered. Ignoring.");
        return;
    }
    if (state == null) {
        return;
    }
    boolean enablePlay = false;
    switch (state.getState()) {
        case PlaybackState.STATE_PAUSED:
        case PlaybackState.STATE_STOPPED:
            enablePlay = true;
            break;
        case PlaybackState.STATE_ERROR:
            LogHelper.e(TAG, "error playbackstate: ", state.getErrorMessage());
            Toast.makeText(getActivity(), state.getErrorMessage(), Toast.LENGTH_LONG).show();
            break;
    }

    if (enablePlay) {
        mPlayPause.setImageDrawable(
                getActivity().getDrawable(R.drawable.ic_play_arrow_black_36dp));
    } else {
        mPlayPause.setImageDrawable(getActivity().getDrawable(R.drawable.ic_pause_black_36dp));
    }

    MediaController controller = getActivity().getMediaController();
    String extraInfo = null;
    if (controller != null && controller.getExtras() != null) {
        String castName = controller.getExtras().getString(MusicService.EXTRA_CONNECTED_CAST);
        if (castName != null) {
            extraInfo = getResources().getString(R.string.casting_to_device, castName);
        }
    }
    setExtraInfo(extraInfo);
}
 
開發者ID:mrinalgit-dev,項目名稱:MrinalMusicPlayer,代碼行數:39,代碼來源:PlaybackControlsFragment.java

示例11: onPlaybackStateChanged

@Override
public void onPlaybackStateChanged(@NonNull PlaybackState state) {
    mPlaybackState = state;
    LogHelper.d(TAG, "Received new playback state", state);
    if (state.getState() == PlaybackState.STATE_STOPPED ||
            state.getState() == PlaybackState.STATE_NONE) {
        stopNotification();
    } else {
        Notification notification = createNotification();
        if (notification != null) {
            mNotificationManager.notify(NOTIFICATION_ID, notification);
        }
    }
}
 
開發者ID:mrinalgit-dev,項目名稱:MrinalMusicPlayer,代碼行數:14,代碼來源:MediaNotificationManager.java

示例12: updatePlaybackState

private void updatePlaybackState(PlaybackState state) {
    mCurrentState = state;
    if (state == null || state.getState() == PlaybackState.STATE_PAUSED ||
            state.getState() == PlaybackState.STATE_STOPPED) {
        mPlayPause.setImageDrawable(getDrawable(R.drawable.ic_play_arrow_black_36dp));
    } else {
        mPlayPause.setImageDrawable(getDrawable(R.drawable.ic_pause_black_36dp));
    }
    mPlaybackControls.setVisibility(state == null ? View.GONE : View.VISIBLE);
}
 
開發者ID:googlecodelabs,項目名稱:android-music-player,代碼行數:10,代碼來源:MusicPlayerActivity.java

示例13: onClick

@Override
public void onClick(View v) {
    final int state = mCurrentState == null ?
            PlaybackState.STATE_NONE : mCurrentState.getState();
    if (state == PlaybackState.STATE_PAUSED ||
            state == PlaybackState.STATE_STOPPED ||
            state == PlaybackState.STATE_NONE) {

        if (mCurrentMetadata == null) {
            mCurrentMetadata = MusicLibrary.getMetadata(MusicPlayerActivity.this,
                    MusicLibrary.getMediaItems().get(0).getMediaId());
            updateMetadata(mCurrentMetadata);
        }
        // ------------ CHANGE 5 - REMOVE FOLLOWING LINES FOR PLAYBACK ON A SERVICE
        mPlaybackManager.play(mCurrentMetadata);

        /* ------------ CHANGE 5 - UNCOMMENT FOLLOWING LINES FOR PLAYBACK ON A SERVICE
        getMediaController().getTransportControls().playFromMediaId(
                mCurrentMetadata.getDescription().getMediaId(), null);
        // ------------ CHANGE 5 - END OF PLAYBACK ON A SERVICE SNIPPET */

    } else {
        // ------------ CHANGE 6 - REMOVE FOLLOWING LINES FOR PLAYBACK ON A SERVICE
        mPlaybackManager.pause();

        /* ------------ CHANGE 6 - UNCOMMENT FOLLOWING LINES FOR PLAYBACK ON A SERVICE
        getMediaController().getTransportControls().pause();
        // ------------ CHANGE 6 - END OF PLAYBACK ON A SERVICE SNIPPET */
    }
}
 
開發者ID:googlecodelabs,項目名稱:android-music-player,代碼行數:30,代碼來源:MusicPlayerActivity.java

示例14: stop

public void stop() {
    mState = PlaybackState.STATE_STOPPED;
    updatePlaybackState();
    // Give up Audio focus
    mAudioManager.abandonAudioFocus(this);
    // Relax all resources
    releaseMediaPlayer();
}
 
開發者ID:googlecodelabs,項目名稱:android-music-player,代碼行數:8,代碼來源:PlaybackManager.java

示例15: onPlayerStateChanged

@Override
public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
    switch (playbackState){
        case PlaybackState.STATE_PLAYING:
            mProgressWheel.setVisibility(GONE);
            mDanmakuView.resume();
            startUitimer();
            hideSystemUI();
            mPlayBtn.setOnCheckedChangeListener(null);
            mPlayBtn.setChecked(false);
            mPlayBtn.setOnCheckedChangeListener(this);
            break;
        case PlaybackState.STATE_PAUSED:
            mPlayBtn.setOnCheckedChangeListener(null);
            mPlayBtn.setChecked(true);
            mPlayBtn.setOnCheckedChangeListener(this);
            break;
        case PlaybackState.STATE_BUFFERING:
            mProgressWheel.setVisibility(VISIBLE);
            break;
        case PlaybackState.STATE_STOPPED:
            break;
        case PlaybackState.STATE_ERROR:

            break;
        default:
            break;
    }
}
 
開發者ID:ayaseruri,項目名稱:luxunPro,代碼行數:29,代碼來源:VideoView.java


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