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


Java MediaStatus.getPlayerState方法代码示例

本文整理汇总了Java中com.google.android.gms.cast.MediaStatus.getPlayerState方法的典型用法代码示例。如果您正苦于以下问题:Java MediaStatus.getPlayerState方法的具体用法?Java MediaStatus.getPlayerState怎么用?Java MediaStatus.getPlayerState使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.android.gms.cast.MediaStatus的用法示例。


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

示例1: onRemoteMediaPlayerStatusUpdated

import com.google.android.gms.cast.MediaStatus; //导入方法依赖的package包/类
@Override
public void onRemoteMediaPlayerStatusUpdated() {
    MediaStatus status = mCastManager.getRemoteMediaPlayer().getMediaStatus();
    int mState = status.getPlayerState();
    int mIdleReason = status.getIdleReason();
    switch (mState) {
        case MediaStatus.PLAYER_STATE_IDLE:
            if (mIdleReason == MediaStatus.IDLE_REASON_FINISHED) {
                loadRemoteNext();
            } else if (mIdleReason == MediaStatus.IDLE_REASON_ERROR) {
                // something bad happened on the cast device
                Log.e(TAG, "onRemoteMediaPlayerStatusUpdated(): IDLE reason = ERROR");
                mCastManager.onFailed(R.string.failed_receiver_player_error, -1);
            }
            break;
    }
}
 
开发者ID:OpenSilk,项目名称:Orpheus,代码行数:18,代码来源:CastMusicPlayer.java

示例2: updateControlViews

import com.google.android.gms.cast.MediaStatus; //导入方法依赖的package包/类
private void updateControlViews(final boolean showAnimations) {
    MediaStatus status = mRemoteMediaPlayer.getMediaStatus();
    MediaInfo info = mRemoteMediaPlayer.getMediaInfo();
    boolean showControls = isApplicationStarted()
            && status != null && info != null && info.getMetadata() != null
            && (MediaStatus.PLAYER_STATE_PLAYING == status.getPlayerState()
            || MediaStatus.PLAYER_STATE_BUFFERING == status.getPlayerState()
            || MediaStatus.PLAYER_STATE_PAUSED == status.getPlayerState());

    if (showControls) {
        final String title = info.getMetadata().getString(MediaMetadata.KEY_TITLE);
        mTitleView.setText(title);
        //noinspection deprecation
        mTitleView.setTextAppearance(this, getControlsTitleStyle(title));
        if (MediaStatus.PLAYER_STATE_PAUSED == status.getPlayerState()) {
            mPlayView.setImageResource(R.drawable.ic_av_play_ripple);
            mStopView.setVisibility(View.VISIBLE);
        } else { // MediaStatus.PLAYER_STATE_PLAYING || MediaStatus.PLAYER_STATE_BUFFERING
            mPlayView.setImageResource(R.drawable.ic_av_pause_ripple);
            mStopView.setVisibility(View.VISIBLE);
        }
    }

    if (showControls) {
        setControlsPosition(0, showAnimations);
    } else {
        setControlsPosition(mControlsHeight, showAnimations);
    }
}
 
开发者ID:felixb,项目名称:basscast,代码行数:30,代码来源:BrowseActivity.java

示例3: onStatusUpdated

import com.google.android.gms.cast.MediaStatus; //导入方法依赖的package包/类
@Override
public void onStatusUpdated() {
    MediaStatus mediaStatus = remoteMediaPlayer.getMediaStatus();
    boolean isPlaying = mediaStatus.getPlayerState() == MediaStatus.PLAYER_STATE_PLAYING;

    // TODO: Do we want to shutdown when there are errors?
    if (mediaStatus.getPlayerState() == MediaStatus.PLAYER_STATE_IDLE &&
        mediaStatus.getIdleReason() == MediaStatus.IDLE_REASON_FINISHED) {

        GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("Casting:Stop", null));
    }
}
 
开发者ID:jrconlin,项目名称:mc_backup,代码行数:13,代码来源:ChromeCast.java

示例4: onRemoteMediaPlayerStatusUpdated

import com.google.android.gms.cast.MediaStatus; //导入方法依赖的package包/类
@Override
//@DebugLog
public void onRemoteMediaPlayerStatusUpdated() {
    MediaStatus status = mCastManager.getRemoteMediaPlayer().getMediaStatus();
    int mState = status.getPlayerState();
    int mIdleReason = status.getIdleReason();
    if (mState == MediaStatus.PLAYER_STATE_PLAYING) {
        if (D) Log.d(TAG, "onRemoteMediaPlayerStatusUpdated(): Player status = playing");
        //HACK
        if (!mService.isSupposedToBePlaying()) {
            mService.setSupposedToBePlaying(true);
            mService.notifyChange(MusicPlaybackService.PLAYSTATE_CHANGED);
        }
    } else if (mState == MediaStatus.PLAYER_STATE_PAUSED) {
        if (D) Log.d(TAG, "onRemoteMediaPlayerStatusUpdated(): Player status = paused");
    } else if (mState == MediaStatus.PLAYER_STATE_IDLE) {
        if (D) Log.d(TAG, "onRemoteMediaPlayerStatusUpdated(): Player status = idle");
        if (mIdleReason == MediaStatus.IDLE_REASON_CANCELED) {
            if (D) Log.d(TAG, "onRemoteMediaPlayerStatusUpdated(): IDLE reason = CANCELLED");
            //TODO
        }
    } else if (mState == MediaStatus.PLAYER_STATE_BUFFERING) {
        if (D) Log.d(TAG, "onRemoteMediaPlayerStatusUpdated(): Player status = buffering");
    } else {
        if (D) Log.d(TAG, "onRemoteMediaPlayerStatusUpdated(): Player status = unknown");
    }
}
 
开发者ID:OpenSilk,项目名称:Orpheus,代码行数:28,代码来源:MusicCastConsumer.java

示例5: updateButtonStates

import com.google.android.gms.cast.MediaStatus; //导入方法依赖的package包/类
private void updateButtonStates() {
    boolean hasDeviceConnection = (mApiClient != null) && mApiClient.isConnected();
    boolean hasAppConnection = (mAppMetadata != null);
    boolean hasMediaConnection = (mMediaPlayer != null);
    boolean hasMedia = false;

    if (hasMediaConnection) {
        MediaStatus mediaStatus = mMediaPlayer.getMediaStatus();
        if (mediaStatus != null) {
            int mediaPlayerState = mediaStatus.getPlayerState();
            int playerState = PLAYER_STATE_NONE;
            if (mediaPlayerState == MediaStatus.PLAYER_STATE_PAUSED) {
                playerState = PLAYER_STATE_PAUSED;
            } else if (mediaPlayerState == MediaStatus.PLAYER_STATE_PLAYING) {
                playerState = PLAYER_STATE_PLAYING;
            } else if (mediaPlayerState == MediaStatus.PLAYER_STATE_BUFFERING) {
                playerState = PLAYER_STATE_BUFFERING;
            }
            setPlayerState(playerState);

            hasMedia = mediaStatus.getPlayerState() != MediaStatus.PLAYER_STATE_IDLE;
            mStopButton.setEnabled(hasMedia);
        }
    } else {
        setPlayerState(PLAYER_STATE_NONE);
        mStopButton.setEnabled(false);
    }

    mLaunchAppButton.setEnabled(hasDeviceConnection && !hasAppConnection);
    mJoinAppButton.setEnabled(hasDeviceConnection && !hasAppConnection);
    mLeaveAppButton.setEnabled(hasDeviceConnection && hasAppConnection);
    mStopAppButton.setEnabled(hasDeviceConnection && hasAppConnection);
    mAutoplayCheckbox.setEnabled(hasDeviceConnection && hasAppConnection);

    mPlayMediaButton.setEnabled(hasMediaConnection);
    setSeekBarEnabled(hasMediaConnection);
    setDeviceVolumeControlsEnabled(hasDeviceConnection);
    setStreamVolumeControlsEnabled(hasMediaConnection);
}
 
开发者ID:TerribleDev,项目名称:XamarinAdmobTutorial,代码行数:40,代码来源:SdkCastPlayerActivity.java

示例6: updateButtonStates

import com.google.android.gms.cast.MediaStatus; //导入方法依赖的package包/类
private void updateButtonStates() {
    boolean hasDeviceConnection = (mApiClient != null) && mApiClient.isConnected()
            && !mWaitingForReconnect;
    boolean hasAppConnection = (mAppMetadata != null) && !mWaitingForReconnect;
    boolean hasMediaConnection = (mMediaPlayer != null) && !mWaitingForReconnect;
    boolean hasMedia = false;

    if (hasMediaConnection) {
        MediaStatus mediaStatus = mMediaPlayer.getMediaStatus();
        if (mediaStatus != null) {
            int mediaPlayerState = mediaStatus.getPlayerState();
            int playerState = PLAYER_STATE_NONE;
            if (mediaPlayerState == MediaStatus.PLAYER_STATE_PAUSED) {
                playerState = PLAYER_STATE_PAUSED;
            } else if (mediaPlayerState == MediaStatus.PLAYER_STATE_PLAYING) {
                playerState = PLAYER_STATE_PLAYING;
            } else if (mediaPlayerState == MediaStatus.PLAYER_STATE_BUFFERING) {
                playerState = PLAYER_STATE_BUFFERING;
            }
            setPlayerState(playerState);

            hasMedia = mediaStatus.getPlayerState() != MediaStatus.PLAYER_STATE_IDLE;
        }
    } else {
        setPlayerState(PLAYER_STATE_NONE);
    }


    mLaunchAppButton.setEnabled(hasDeviceConnection && !hasAppConnection);
    mJoinAppButton.setEnabled(hasDeviceConnection && !hasAppConnection);
    mLeaveAppButton.setEnabled(hasDeviceConnection && hasAppConnection);
    mStopAppButton.setEnabled(hasDeviceConnection && hasAppConnection);
    mAutoplayCheckbox.setEnabled(hasDeviceConnection && hasAppConnection);

    mSelectMediaButton.setEnabled(hasMediaConnection);
    mStopButton.setEnabled(hasMediaConnection && hasMedia);
    setSeekBarEnabled(hasMediaConnection && hasMedia);
    setDeviceVolumeControlsEnabled(hasDeviceConnection);
    setStreamVolumeControlsEnabled(hasMediaConnection && hasMedia);
}
 
开发者ID:benbek,项目名称:HereAStory-Android,代码行数:41,代码来源:SdkCastPlayerActivity.java

示例7: configMediaPlayerState

import com.google.android.gms.cast.MediaStatus; //导入方法依赖的package包/类
/**
 * Reconfigures MediaPlayer according to audio focus settings and
 * starts/restarts it. This method starts/restarts the MediaPlayer
 * respecting the current audio focus state. So if we have focus, it will
 * play normally; if we don't have focus, it will either leave the
 * MediaPlayer paused or set it to a low volume, depending on what is
 * allowed by the current focus settings. This method assumes mPlayer !=
 * null, so if you are calling it, you have to do so from a context where
 * you are sure this is the case.
 */
@DebugLog
private void configMediaPlayerState() {
    Timber.d("configMediaPlayerState. mAudioFocus=%d", mAudioFocus);
    if (mState == STATE_ERROR) {
        return;
    }
    if (mAudioFocus == AUDIO_NO_FOCUS_NO_DUCK) {
        // If we don't have audio focus and can't duck, we have to pause,
        pause();
    } else {  // we have audio focus:
        if (mAudioFocus == AUDIO_NO_FOCUS_CAN_DUCK) {
            if (isConnected() && hasCurrent()) {
                mRemoteMediaPlayer.setStreamVolume(mApiClient, VOLUME_DUCK); // we'll be relatively quiet
            }
        } else {
            if (isConnected() && hasCurrent()) {
                mRemoteMediaPlayer.setStreamVolume(mApiClient, VOLUME_NORMAL); // we can be loud again
            }
        }
        // If we were playing when we lost focus, we need to resume playing.
        if (mPlayOnFocusGain) {
            if (isConnected() && hasCurrent()) {
                MediaStatus status = mRemoteMediaPlayer.getMediaStatus();
                if (status != null && status.getPlayerState() != MediaStatus.PLAYER_STATE_PLAYING) {
                    if (mCurrentPosition == mRemoteMediaPlayer.getApproximateStreamPosition()) {
                        mRemoteMediaPlayer.play(mApiClient);
                        mState = PlaybackStateCompat.STATE_PLAYING;
                    } else {
                        Timber.d("configMediaPlayerState startMediaPlayer. " +
                                "seeking to %s", mCurrentPosition);
                        mRemoteMediaPlayer.seek(mApiClient, mCurrentPosition, RemoteMediaPlayer.RESUME_STATE_PLAY);
                        mState = PlaybackStateCompat.STATE_BUFFERING;
                    }
                }
            }
            mPlayOnFocusGain = false;
        }
    }
    notifyOnPlaybackStatusChanged(mState);
}
 
开发者ID:OpenSilk,项目名称:Orpheus,代码行数:51,代码来源:CastRendererService.java


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