Java Code Examples for com.google.android.gms.cast.MediaStatus#getQueueItems()

The following examples show how to use com.google.android.gms.cast.MediaStatus#getQueueItems() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: QueueDataProvider.java    From CastVideos-android with Apache License 2.0 6 votes vote down vote up
private void syncWithRemoteQueue() {
    RemoteMediaClient remoteMediaClient = getRemoteMediaClient();
    if (remoteMediaClient != null) {
        remoteMediaClient.registerCallback(mRemoteMediaClientCallback);
        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());
            }
        }
    }
}
 
Example 2
Source File: QueueDataProvider.java    From CastVideos-android with Apache License 2.0 6 votes vote down vote up
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;
        }
    }
}
 
Example 3
Source File: QueueListViewActivity.java    From CastVideos-android with Apache License 2.0 6 votes vote down vote up
@Override
protected void onResume() {
    mCastContext.getSessionManager().addSessionManagerListener(
            mSessionManagerListener, CastSession.class);
    if (mRemoteMediaClient == null) {
        mRemoteMediaClient = getRemoteMediaClient();
    }
    if (mRemoteMediaClient != null) {
        mRemoteMediaClient.registerCallback(mRemoteMediaClientCallback);
        MediaStatus mediaStatus = mRemoteMediaClient.getMediaStatus();
        List<MediaQueueItem> queueItems =
                (mediaStatus == null) ? null : mediaStatus.getQueueItems();
        if (queueItems != null && !queueItems.isEmpty()) {
            mEmptyView.setVisibility(View.GONE);
        }
    }
    super.onResume();
}
 
Example 4
Source File: QueueListViewActivity.java    From CastVideos-android with Apache License 2.0 5 votes vote down vote up
private void updateMediaQueue() {
    MediaStatus mediaStatus = mRemoteMediaClient.getMediaStatus();
    List<MediaQueueItem> queueItems =
            (mediaStatus == null) ? null : mediaStatus.getQueueItems();
    if (queueItems == null || queueItems.isEmpty()) {
        mEmptyView.setVisibility(View.VISIBLE);
    } else {
        mEmptyView.setVisibility(View.GONE);
    }
}