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


Java MediaStatus类代码示例

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


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

示例1: run

import com.google.android.gms.cast.MediaStatus; //导入依赖的package包/类
@Override
public void run() {
    int currentPos;
    if (getPlaybackStatus() == MediaStatus.PLAYER_STATE_BUFFERING || !isConnected()) {
        return;
    }
    try {
        int duration = (int) getMediaDuration();
        if (duration > 0) {
            currentPos = (int) getCurrentMediaPosition();
            updateProgress(currentPos, duration);
        }
    } catch (TransientNetworkDisconnectionException | NoConnectionException e) {
        LOGE(TAG, "Failed to update the progress tracker due to network issues", e);
    }
}
 
开发者ID:archos-sa,项目名称:aos-Video,代码行数:17,代码来源:ArchosVideoCastManager.java

示例2: getPlaybackStatus

import com.google.android.gms.cast.MediaStatus; //导入依赖的package包/类
public int getPlaybackStatus() {
    if(mIsPreparing) {
        return ArchosMediaStatus.PLAYER_STATE_PREPARING;
    }
    if(mIsSwitching) {
        return ArchosMediaStatus.PLAYER_STATE_SWITCHING;
    }
    if(Player.sPlayer !=null){
        if(Player.sPlayer.isBusy()){
            return MediaStatus.PLAYER_STATE_PLAYING;
        }
        if (Player.sPlayer.isPlaying()){
            return MediaStatus.PLAYER_STATE_PLAYING;
        }
        if(!Player.sPlayer.isPlaying()&&Player.sPlayer.isInPlaybackState()){
            return MediaStatus.PLAYER_STATE_PAUSED;
        }
    }else if (mCastManager.isConnected()){
        return mCastManager.getPlaybackStatus();
    }
    return MediaStatus.PLAYER_STATE_IDLE;
}
 
开发者ID:archos-sa,项目名称:aos-Video,代码行数:23,代码来源:ArchosVideoCastManager.java

示例3: onStopTrackingTouch

import com.google.android.gms.cast.MediaStatus; //导入依赖的package包/类
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
    try {
        if (mPlaybackState == MediaStatus.PLAYER_STATE_PLAYING) {
            mPlaybackState = MediaStatus.PLAYER_STATE_BUFFERING;
            mCastController.setPlaybackStatus(mPlaybackState);
            mCastManager.play(seekBar.getProgress());
        } else if (mPlaybackState == MediaStatus.PLAYER_STATE_PAUSED) {
            mCastManager.seek(seekBar.getProgress());
        }
        restartTrickplayTimer();
    } catch (Exception e) {
        LOGE(TAG, "Failed to complete seek", e);
        mCastController.closeActivity();
    }
}
 
开发者ID:archos-sa,项目名称:aos-Video,代码行数:17,代码来源:VideoCastControllerFragment.java

示例4: CastDebug

import com.google.android.gms.cast.MediaStatus; //导入依赖的package包/类
public CastDebug(Context context){
    super();

    sCastDebug = this;
    mContext = context;
    mHandler = new android.os.Handler(){
        public void handleMessage(Message msg) {
            try {
                if((ArchosVideoCastManager.getInstance().isRemoteMediaPlaying()||
                        ArchosVideoCastManager.getInstance().getPlaybackStatus()== MediaStatus.PLAYER_STATE_IDLE)&&is_media_loading){
                    goToNextVideo();
                }
            } catch (TransientNetworkDisconnectionException e) {
                e.printStackTrace();
            } catch (NoConnectionException e) {
                e.printStackTrace();
            }
        }


    };
    mVideoMapper = new VideoCursorMapper();
    ArchosVideoCastManager.getInstance().addArchosCastManagerListener(this);

}
 
开发者ID:archos-sa,项目名称:aos-Video,代码行数:26,代码来源:CastDebug.java

示例5: playFiles

import com.google.android.gms.cast.MediaStatus; //导入依赖的package包/类
@Override
public void playFiles(List<MediaQueueItem> mediaItems) {
    CastSession castSession =
            CastContext.getSharedInstance(this).getSessionManager().getCurrentCastSession();
    if (castSession == null) {
        Toast.makeText(this, "Not connected", Toast.LENGTH_LONG).show();
        return;
    }

    // For variety, shuffle the list.
    Collections.shuffle(mediaItems);

    Log.d(TAG, "playFiles: sending " + mediaItems.size() + " files to Chromecast");
    RemoteMediaClient mediaClient = castSession.getRemoteMediaClient();
    int startIndex = 0;
    mediaClient.queueLoad(mediaItems.toArray(new MediaQueueItem[0]), startIndex,
            MediaStatus.REPEAT_MODE_REPEAT_ALL_AND_SHUFFLE, null);
}
 
开发者ID:stephenmcgruer,项目名称:simple-upnp,代码行数:19,代码来源:MainActivity.java

示例6: shouldRemoteUiBeVisible

import com.google.android.gms.cast.MediaStatus; //导入依赖的package包/类
/**
 * A helper method to determine if, given a player state and an idle reason (if the state is
 * idle) will warrant having a UI for remote presentation of the remote content.
 *
 * @throws TransientNetworkDisconnectionException
 * @throws NoConnectionException
 */
public boolean shouldRemoteUiBeVisible(int state, int idleReason)
        throws TransientNetworkDisconnectionException, NoConnectionException {
    switch (state) {
        case MediaStatus.PLAYER_STATE_PLAYING:
        case MediaStatus.PLAYER_STATE_PAUSED:
        case MediaStatus.PLAYER_STATE_BUFFERING:
            return true;
        case MediaStatus.PLAYER_STATE_IDLE:
            if (isRemoteStreamLive() && (idleReason == MediaStatus.IDLE_REASON_CANCELED)) {
                // we have a live stream and we have "stopped/paused" it
                return true;
            } else {
                // if we have not reached the end of queue, return true otherwise return false
                return mMediaStatus != null && (mMediaStatus.getLoadingItemId()
                        != MediaQueueItem.INVALID_ITEM_ID);
            }
        default:
    }
    return false;
}
 
开发者ID:SebastianRask,项目名称:Pocket-Plays-for-Twitch,代码行数:28,代码来源:VideoCastManager.java

示例7: togglePlayback

import com.google.android.gms.cast.MediaStatus; //导入依赖的package包/类
/**
 * Toggles the playback of the movie.
 *
 * @throws CastException
 * @throws NoConnectionException
 * @throws TransientNetworkDisconnectionException
 */
public void togglePlayback() throws CastException, TransientNetworkDisconnectionException,
        NoConnectionException {
    checkConnectivity();
    boolean isPlaying = isRemoteMediaPlaying();
    if (isPlaying) {
        pause();
    } else {
        if (mState == MediaStatus.PLAYER_STATE_IDLE
                && mIdleReason == MediaStatus.IDLE_REASON_FINISHED) {
            loadMedia(getRemoteMediaInformation(), true, 0);
        } else {
            play();
        }
    }
}
 
开发者ID:SebastianRask,项目名称:Pocket-Plays-for-Twitch,代码行数:23,代码来源:VideoCastManager.java

示例8: onQueueUpdated

import com.google.android.gms.cast.MediaStatus; //导入依赖的package包/类
private void onQueueUpdated(List<MediaQueueItem> queueItems, MediaQueueItem item,
        int repeatMode, boolean shuffle) {
    LOGD(TAG, "onQueueUpdated() reached");
    LOGD(TAG, String.format("Queue Items size: %d, Item: %s, Repeat Mode: %d, Shuffle: %s",
            queueItems == null ? 0 : queueItems.size(), item, repeatMode, shuffle));
    if (queueItems != null) {
        mMediaQueue = new MediaQueue(new CopyOnWriteArrayList<>(queueItems), item, shuffle,
                repeatMode);
    } else {
        mMediaQueue = new MediaQueue(new CopyOnWriteArrayList<MediaQueueItem>(), null, false,
                MediaStatus.REPEAT_MODE_REPEAT_OFF);
    }
    for (VideoCastConsumer consumer : mVideoConsumers) {
        consumer.onMediaQueueUpdated(queueItems, item, repeatMode, shuffle);
    }
}
 
开发者ID:SebastianRask,项目名称:Pocket-Plays-for-Twitch,代码行数:17,代码来源:VideoCastManager.java

示例9: changeVolume

import com.google.android.gms.cast.MediaStatus; //导入依赖的package包/类
private boolean changeVolume(double volumeIncrement, boolean isKeyDown) {
    if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN)
            && getPlaybackStatus() == MediaStatus.PLAYER_STATE_PLAYING
            && isFeatureEnabled(CastConfiguration.FEATURE_LOCKSCREEN)) {
        return false;
    }

    if (isKeyDown) {
        try {
            adjustVolume(volumeIncrement);
        } catch (CastException | TransientNetworkDisconnectionException |
                NoConnectionException e) {
            LOGE(TAG, "Failed to change volume", e);
        }
    }
    return true;
}
 
开发者ID:SebastianRask,项目名称:Pocket-Plays-for-Twitch,代码行数:18,代码来源:VideoCastManager.java

示例10: run

import com.google.android.gms.cast.MediaStatus; //导入依赖的package包/类
@Override
public void run() {
    int currentPos;
    if (mState == MediaStatus.PLAYER_STATE_BUFFERING || !isConnected()
            || mRemoteMediaPlayer == null) {
        return;
    }
    try {
        int duration = (int) getMediaDuration();
        if (duration > 0) {
            currentPos = (int) getCurrentMediaPosition();
            updateProgress(currentPos, duration);
        }
    } catch (TransientNetworkDisconnectionException | NoConnectionException e) {
        LOGE(TAG, "Failed to update the progress tracker due to network issues", e);
    }
}
 
开发者ID:SebastianRask,项目名称:Pocket-Plays-for-Twitch,代码行数:18,代码来源:VideoCastManager.java

示例11: syncWithRemoteQueue

import com.google.android.gms.cast.MediaStatus; //导入依赖的package包/类
private void syncWithRemoteQueue() {
    RemoteMediaClient remoteMediaClient = getRemoteMediaClient();
    if (remoteMediaClient != null) {
        remoteMediaClient.addListener(mRemoteMediaClientListener);
        MediaStatus mediaStatus = remoteMediaClient.getMediaStatus();
        if (mediaStatus != null) {
            List<MediaQueueItem> items = mediaStatus.getQueueItems();
            if (items != null && !items.isEmpty()) {
                mQueue.clear();
                mQueue.addAll(items);
                mRepeatMode = mediaStatus.getQueueRepeatMode();
                mCurrentIem = mediaStatus.getQueueItemById(mediaStatus.getCurrentItemId());
                mDetachedQueue = false;
                mUpcomingItem = mediaStatus.getQueueItemById(mediaStatus.getPreloadedItemId());
            }
        }
    }
}
 
开发者ID:nordfalk,项目名称:EsperantoRadio,代码行数:19,代码来源:QueueDataProvider.java

示例12: onPreloadStatusUpdated

import com.google.android.gms.cast.MediaStatus; //导入依赖的package包/类
@Override
public void onPreloadStatusUpdated() {
    RemoteMediaClient remoteMediaClient = getRemoteMediaClient();
    if (remoteMediaClient == null) {
        return;
    }
    MediaStatus mediaStatus = remoteMediaClient.getMediaStatus();
    if (mediaStatus == null) {
        return;
    }
    mUpcomingItem = mediaStatus.getQueueItemById(mediaStatus.getPreloadedItemId());
    Log.d(TAG, "onRemoteMediaPreloadStatusUpdated() with item=" + mUpcomingItem);
    if (mListener != null) {
        mListener.onQueueDataChanged();
    }
}
 
开发者ID:nordfalk,项目名称:EsperantoRadio,代码行数:17,代码来源:QueueDataProvider.java

示例13: updateMediaQueue

import com.google.android.gms.cast.MediaStatus; //导入依赖的package包/类
private void updateMediaQueue() {
    RemoteMediaClient remoteMediaClient = getRemoteMediaClient();
    MediaStatus mediaStatus;
    List<MediaQueueItem> queueItems = null;
    if (remoteMediaClient != null) {
        mediaStatus = remoteMediaClient.getMediaStatus();
        if (mediaStatus != null) {
            queueItems = mediaStatus.getQueueItems();
            mRepeatMode = mediaStatus.getQueueRepeatMode();
            mCurrentIem = mediaStatus.getQueueItemById(mediaStatus.getCurrentItemId());
        }
    }
    mQueue.clear();
    if (queueItems == null) {
        Log.d(TAG, "Queue is cleared");
    } else {
        Log.d(TAG, "Queue is updated with a list of size: " + queueItems.size());
        if (queueItems.size() > 0) {
            mQueue.addAll(queueItems);
            mDetachedQueue = false;
        } else {
            mDetachedQueue = true;
        }
    }
}
 
开发者ID:nordfalk,项目名称:EsperantoRadio,代码行数:26,代码来源:QueueDataProvider.java

示例14: updatePlayPauseButtonImageResource

import com.google.android.gms.cast.MediaStatus; //导入依赖的package包/类
private void updatePlayPauseButtonImageResource(ImageButton button) {
    CastSession castSession = CastContext.getSharedInstance(mAppContext)
            .getSessionManager().getCurrentCastSession();
    RemoteMediaClient remoteMediaClient =
            (castSession == null) ? null : castSession.getRemoteMediaClient();
    if (remoteMediaClient == null) {
        button.setVisibility(View.GONE);
        return;
    }
    int status = remoteMediaClient.getPlayerState();
    switch (status) {
        case MediaStatus.PLAYER_STATE_PLAYING:
            button.setImageResource(PAUSE_RESOURCE);
            break;
        case MediaStatus.PLAYER_STATE_PAUSED:
            button.setImageResource(PLAY_RESOURCE);
            break;
        default:
            button.setVisibility(View.GONE);
    }
}
 
开发者ID:nordfalk,项目名称:EsperantoRadio,代码行数:22,代码来源:QueueListAdapter.java

示例15: onResume

import com.google.android.gms.cast.MediaStatus; //导入依赖的package包/类
@Override
protected void onResume() {
    mCastContext.getSessionManager().addSessionManagerListener(
            mSessionManagerListener, CastSession.class);
    if (mRemoteMediaClient == null) {
        mRemoteMediaClient = getRemoteMediaClient();
    }
    if (mRemoteMediaClient != null) {
        mRemoteMediaClient.addListener(mRemoteMediaClientListener);
        MediaStatus mediaStatus = mRemoteMediaClient.getMediaStatus();
        List<MediaQueueItem> queueItems =
                (mediaStatus == null) ? null : mediaStatus.getQueueItems();
        if (queueItems != null && !queueItems.isEmpty()) {
            mEmptyView.setVisibility(View.GONE);
        }
    }
    super.onResume();
}
 
开发者ID:nordfalk,项目名称:EsperantoRadio,代码行数:19,代码来源:QueueListViewActivity.java


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