本文整理汇总了Java中com.google.android.gms.cast.MediaQueueItem类的典型用法代码示例。如果您正苦于以下问题:Java MediaQueueItem类的具体用法?Java MediaQueueItem怎么用?Java MediaQueueItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MediaQueueItem类属于com.google.android.gms.cast包,在下文中一共展示了MediaQueueItem类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: playItems
import com.google.android.gms.cast.MediaQueueItem; //导入依赖的package包/类
@Override
public void playItems(List<Item> itemsToPlay) {
if (mListener == null)
return;
// Convert to MediaQueueItem for Cast.
List<MediaQueueItem> mediaItems = new ArrayList<>();
for (Item item : itemsToPlay) {
// Assumption: first non-null resource is the URL. No idea if correct.
Res urlResource = item.getFirstResource();
if (urlResource != null) {
MediaMetadata metadata = new MediaMetadata(MediaMetadata.MEDIA_TYPE_MUSIC_TRACK);
metadata.putString(MediaMetadata.KEY_TITLE, item.getTitle());
MediaInfo mediaInfo = new MediaInfo.Builder(urlResource.getValue())
.setStreamType(MediaInfo.STREAM_TYPE_BUFFERED)
.setContentType("audio/mp3")
.setMetadata(metadata)
.build();
mediaItems.add(new MediaQueueItem.Builder(mediaInfo).build());
}
}
mListener.playFiles(mediaItems);
}
开发者ID:stephenmcgruer,项目名称:simple-upnp,代码行数:24,代码来源:FileBrowserFragment.java
示例2: playFiles
import com.google.android.gms.cast.MediaQueueItem; //导入依赖的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
示例3: shouldRemoteUiBeVisible
import com.google.android.gms.cast.MediaQueueItem; //导入依赖的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
示例4: queueUpdateItems
import com.google.android.gms.cast.MediaQueueItem; //导入依赖的package包/类
/**
* Updates properties of a subset of the existing items in the media queue.
*
* @param itemsToUpdate List of queue items to be updated. The items will retain the existing
* order and will be fully replaced with the ones provided, including the
* media information. Any other items currently in the queue will remain
* unchanged. The tracks information can not change once the item is loaded
* (if the item is the currentItem). If any of the items does not exist it
* will be ignored.
* @param customData Custom application-specific data to pass along with the request. May be
* {@code null}.
* @throws TransientNetworkDisconnectionException
* @throws NoConnectionException
*/
public void queueUpdateItems(final MediaQueueItem[] itemsToUpdate, final JSONObject customData)
throws TransientNetworkDisconnectionException, NoConnectionException {
checkConnectivity();
if (mRemoteMediaPlayer == null) {
LOGE(TAG, "Trying to update the queue with no active media session");
throw new NoConnectionException();
}
mRemoteMediaPlayer
.queueUpdateItems(mApiClient, itemsToUpdate, customData).setResultCallback(
new ResultCallback<MediaChannelResult>() {
@Override
public void onResult(MediaChannelResult result) {
LOGD(TAG, "queueUpdateItems() " + result.getStatus() + result.getStatus()
.isSuccess());
for (VideoCastConsumer consumer : mVideoConsumers) {
consumer.onMediaQueueOperationResult(QUEUE_OPERATION_UPDATE_ITEMS,
result.getStatus().getStatusCode());
}
}
});
}
开发者ID:SebastianRask,项目名称:Pocket-Plays-for-Twitch,代码行数:37,代码来源:VideoCastManager.java
示例5: queueJumpToItem
import com.google.android.gms.cast.MediaQueueItem; //导入依赖的package包/类
/**
* Plays the item with {@code itemId} in the queue.
* <p>
* If {@code itemId} is not found in the queue, this method will report success without sending
* a request to the receiver.
*
* @param itemId The ID of the item to which to jump.
* @param customData Custom application-specific data to pass along with the request. May be
* {@code null}.
* @throws TransientNetworkDisconnectionException
* @throws NoConnectionException
* @throws IllegalArgumentException
*/
public void queueJumpToItem(int itemId, final JSONObject customData)
throws TransientNetworkDisconnectionException, NoConnectionException,
IllegalArgumentException {
checkConnectivity();
if (itemId == MediaQueueItem.INVALID_ITEM_ID) {
throw new IllegalArgumentException("itemId is not valid");
}
if (mRemoteMediaPlayer == null) {
LOGE(TAG, "Trying to jump in a queue with no active media session");
throw new NoConnectionException();
}
mRemoteMediaPlayer
.queueJumpToItem(mApiClient, itemId, customData).setResultCallback(
new ResultCallback<MediaChannelResult>() {
@Override
public void onResult(MediaChannelResult result) {
for (VideoCastConsumer consumer : mVideoConsumers) {
consumer.onMediaQueueOperationResult(QUEUE_OPERATION_JUMP,
result.getStatus().getStatusCode());
}
}
});
}
开发者ID:SebastianRask,项目名称:Pocket-Plays-for-Twitch,代码行数:38,代码来源:VideoCastManager.java
示例6: queueRemoveItem
import com.google.android.gms.cast.MediaQueueItem; //导入依赖的package包/类
/**
* Removes the item with {@code itemId} from the queue.
* <p>
* If {@code itemId} is not found in the queue, this method will silently return without sending
* a request to the receiver. A {@code itemId} may not be in the queue because it wasn't
* originally in the queue, or it was removed by another sender.
*
* @param itemId The ID of the item to be removed.
* @param customData Custom application-specific data to pass along with the request. May be
* {@code null}.
* @throws TransientNetworkDisconnectionException
* @throws NoConnectionException
* @throws IllegalArgumentException
*/
public void queueRemoveItem(final int itemId, final JSONObject customData)
throws TransientNetworkDisconnectionException, NoConnectionException,
IllegalArgumentException {
LOGD(TAG, "queueRemoveItem");
checkConnectivity();
if (itemId == MediaQueueItem.INVALID_ITEM_ID) {
throw new IllegalArgumentException("itemId is invalid");
}
if (mRemoteMediaPlayer == null) {
LOGE(TAG, "Trying to remove an item from queue with no active media session");
throw new NoConnectionException();
}
mRemoteMediaPlayer
.queueRemoveItem(mApiClient, itemId, customData).setResultCallback(
new ResultCallback<MediaChannelResult>() {
@Override
public void onResult(MediaChannelResult result) {
for (VideoCastConsumer consumer : mVideoConsumers) {
consumer.onMediaQueueOperationResult(QUEUE_OPERATION_REMOVE_ITEM,
result.getStatus().getStatusCode());
}
}
});
}
开发者ID:SebastianRask,项目名称:Pocket-Plays-for-Twitch,代码行数:40,代码来源:VideoCastManager.java
示例7: queueAppendItem
import com.google.android.gms.cast.MediaQueueItem; //导入依赖的package包/类
/**
* Appends a new media item to the end of the queue.
*
* @param item The item to append. Must not be {@code null}.
* @param customData Custom application-specific data to pass along with the request. May be
* {@code null}.
* @throws TransientNetworkDisconnectionException
* @throws NoConnectionException
*/
public void queueAppendItem(MediaQueueItem item, final JSONObject customData)
throws TransientNetworkDisconnectionException, NoConnectionException {
mRemoteMediaPlayer
.queueAppendItem(mApiClient, item, customData)
.setResultCallback(
new ResultCallback<MediaChannelResult>() {
@Override
public void onResult(MediaChannelResult result) {
for (VideoCastConsumer consumer : mVideoConsumers) {
consumer.onMediaQueueOperationResult(QUEUE_OPERATION_APPEND,
result.getStatus().getStatusCode());
}
}
});
}
开发者ID:SebastianRask,项目名称:Pocket-Plays-for-Twitch,代码行数:26,代码来源:VideoCastManager.java
示例8: onQueueUpdated
import com.google.android.gms.cast.MediaQueueItem; //导入依赖的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: syncWithRemoteQueue
import com.google.android.gms.cast.MediaQueueItem; //导入依赖的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
示例10: updateMediaQueue
import com.google.android.gms.cast.MediaQueueItem; //导入依赖的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
示例11: QueueListAdapter
import com.google.android.gms.cast.MediaQueueItem; //导入依赖的package包/类
public QueueListAdapter(Context context, OnStartDragListener dragStartListener) {
mAppContext = context.getApplicationContext();
mDragStartListener = dragStartListener;
mProvider = QueueDataProvider.getInstance(context);
mProvider.setOnQueueDataChangedListener(new QueueDataProvider.OnQueueDataChangedListener() {
@Override
public void onQueueDataChanged() {
notifyDataSetChanged();
}
});
mItemViewOnClickListener = new View.OnClickListener() {
@Override
public void onClick(View view) {
if (view.getTag(R.string.queue_tag_item) != null) {
MediaQueueItem item = (MediaQueueItem) view.getTag(R.string.queue_tag_item);
Log.d(TAG, String.valueOf(item.getItemId()));
}
onItemViewClick(view);
}
};
setHasStableIds(true);
}
开发者ID:nordfalk,项目名称:EsperantoRadio,代码行数:23,代码来源:QueueListAdapter.java
示例12: onResume
import com.google.android.gms.cast.MediaQueueItem; //导入依赖的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
示例13: prepareForNextTrack
import com.google.android.gms.cast.MediaQueueItem; //导入依赖的package包/类
public void prepareForNextTrack() {
if (isConnected() && hasCurrent()) {
MediaStatus status = mRemoteMediaPlayer.getMediaStatus();
if (status.getQueueItemCount() > 1) {
int current = status.getCurrentItemId();
int[] ids = new int[status.getQueueItemCount()-1];
int ii=0;
for (MediaQueueItem item : status.getQueueItems()) {
if (item.getItemId() != current) {
ids[ii++] = item.getItemId();
}
}
try {
mRemoteMediaPlayer.queueRemoveItems(mApiClient, ids, null).await();
} catch (IllegalArgumentException e) {
Timber.e(e, "prepareForNextTrack");
}
}
}
}
开发者ID:OpenSilk,项目名称:Orpheus,代码行数:21,代码来源:CastRendererService.java
示例14: setUpcomingItem
import com.google.android.gms.cast.MediaQueueItem; //导入依赖的package包/类
@Override
public void setUpcomingItem(MediaQueueItem item) {
mUpcomingItem = item;
if (item != null) {
MediaInfo mediaInfo = item.getMedia();
if (mediaInfo != null) {
MediaMetadata metadata = mediaInfo.getMetadata();
setUpcomingTitle(metadata.getString(MediaMetadata.KEY_TITLE));
setUpcomingIcon(Utils.getImageUri(mediaInfo, 0));
}
} else {
setUpcomingTitle("");
setUpcomingIcon((Uri) null);
}
}
开发者ID:archos-sa,项目名称:aos-Video,代码行数:16,代码来源:ArchosMiniPlayer.java
示例15: setUpcomingItem
import com.google.android.gms.cast.MediaQueueItem; //导入依赖的package包/类
@Override
public void setUpcomingItem(MediaQueueItem item) {
if(mCastManager.isConnected())
synchronized (mMiniControllers) {
for (final IMiniController controller : mMiniControllers) {
controller.setUpcomingItem(item);
}
}
}
开发者ID:archos-sa,项目名称:aos-Video,代码行数:10,代码来源:ArchosVideoCastManager.java
示例16: onMediaQueueUpdated
import com.google.android.gms.cast.MediaQueueItem; //导入依赖的package包/类
@Override
public void onMediaQueueUpdated(List<MediaQueueItem> queueItems, MediaQueueItem item,
int repeatMode, boolean shuffle) {
int size = 0;
int position = 0;
if (queueItems != null) {
size = queueItems.size();
position = queueItems.indexOf(item);
}
mCastController.onQueueItemsUpdated(size, position);
}
开发者ID:archos-sa,项目名称:aos-Video,代码行数:13,代码来源:VideoCastControllerFragment.java
示例17: updateMiniControllersVisibilityForUpcoming
import com.google.android.gms.cast.MediaQueueItem; //导入依赖的package包/类
public void updateMiniControllersVisibilityForUpcoming(MediaQueueItem item) {
synchronized (mMiniControllers) {
for (IMiniController controller : mMiniControllers) {
controller.setUpcomingItem(item);
controller.setUpcomingVisibility(item != null);
}
}
}
开发者ID:SebastianRask,项目名称:Pocket-Plays-for-Twitch,代码行数:9,代码来源:VideoCastManager.java
示例18: queueInsertItems
import com.google.android.gms.cast.MediaQueueItem; //导入依赖的package包/类
/**
* Inserts a list of new media items into the queue.
*
* @param itemsToInsert List of items to insert into the queue, in the order that they should be
* played. The itemId field of the items should be unassigned or the
* request will fail with an INVALID_PARAMS error. Must not be {@code null}
* or empty.
* @param insertBeforeItemId ID of the item that will be located immediately after the inserted
* list. If the value is {@link MediaQueueItem#INVALID_ITEM_ID} or
* invalid, the inserted list will be appended to the end of the
* queue.
* @param customData Custom application-specific data to pass along with the request. May be
* {@code null}.
* @throws TransientNetworkDisconnectionException
* @throws NoConnectionException
* @throws IllegalArgumentException
*/
public void queueInsertItems(final MediaQueueItem[] itemsToInsert, final int insertBeforeItemId,
final JSONObject customData)
throws TransientNetworkDisconnectionException, NoConnectionException {
LOGD(TAG, "queueInsertItems");
checkConnectivity();
if (itemsToInsert == null || itemsToInsert.length == 0) {
throw new IllegalArgumentException("items cannot be empty or null");
}
if (mRemoteMediaPlayer == null) {
LOGE(TAG, "Trying to insert into queue with no active media session");
throw new NoConnectionException();
}
mRemoteMediaPlayer
.queueInsertItems(mApiClient, itemsToInsert, insertBeforeItemId, customData)
.setResultCallback(
new ResultCallback<MediaChannelResult>() {
@Override
public void onResult(MediaChannelResult result) {
for (VideoCastConsumer consumer : mVideoConsumers) {
consumer.onMediaQueueOperationResult(
QUEUE_OPERATION_INSERT_ITEMS,
result.getStatus().getStatusCode());
}
}
});
}
开发者ID:SebastianRask,项目名称:Pocket-Plays-for-Twitch,代码行数:45,代码来源:VideoCastManager.java
示例19: queueInsertBeforeCurrentAndPlay
import com.google.android.gms.cast.MediaQueueItem; //导入依赖的package包/类
/**
* Inserts an item in the queue and starts the playback of that newly inserted item. It is
* assumed that we are inserting before the "current item"
*
* @param item The item to be inserted
* @param insertBeforeItemId ID of the item that will be located immediately after the inserted
* and is assumed to be the "current item"
* @param customData Custom application-specific data to pass along with the request. May be
* {@code null}.
* @throws TransientNetworkDisconnectionException
* @throws NoConnectionException
* @throws IllegalArgumentException
*/
public void queueInsertBeforeCurrentAndPlay(MediaQueueItem item, int insertBeforeItemId,
final JSONObject customData)
throws TransientNetworkDisconnectionException, NoConnectionException {
checkConnectivity();
if (mRemoteMediaPlayer == null) {
LOGE(TAG, "Trying to insert into queue with no active media session");
throw new NoConnectionException();
}
if (item == null || insertBeforeItemId == MediaQueueItem.INVALID_ITEM_ID) {
throw new IllegalArgumentException(
"item cannot be empty or insertBeforeItemId cannot be invalid");
}
mRemoteMediaPlayer.queueInsertItems(mApiClient, new MediaQueueItem[]{item},
insertBeforeItemId, customData).setResultCallback(
new ResultCallback<MediaChannelResult>() {
@Override
public void onResult(MediaChannelResult result) {
if (result.getStatus().isSuccess()) {
try {
queuePrev(customData);
} catch (TransientNetworkDisconnectionException |
NoConnectionException e) {
LOGE(TAG, "queuePrev() Failed to skip to previous", e);
}
}
for (VideoCastConsumer consumer : mVideoConsumers) {
consumer.onMediaQueueOperationResult(QUEUE_OPERATION_INSERT_ITEMS,
result.getStatus().getStatusCode());
}
}
});
}
开发者ID:SebastianRask,项目名称:Pocket-Plays-for-Twitch,代码行数:48,代码来源:VideoCastManager.java
示例20: onRemoteMediaPreloadStatusUpdated
import com.google.android.gms.cast.MediaQueueItem; //导入依赖的package包/类
private void onRemoteMediaPreloadStatusUpdated() {
MediaQueueItem item = null;
mMediaStatus = mRemoteMediaPlayer != null ? mRemoteMediaPlayer
.getMediaStatus() : null;
if (mMediaStatus != null) {
item = mMediaStatus.getQueueItemById(mMediaStatus.getPreloadedItemId());
}
mPreLoadingItem = item;
updateMiniControllersVisibilityForUpcoming(item);
LOGD(TAG, "onRemoteMediaPreloadStatusUpdated() " + item);
for (VideoCastConsumer consumer : mVideoConsumers) {
consumer.onRemoteMediaPreloadStatusUpdated(item);
}
}
开发者ID:SebastianRask,项目名称:Pocket-Plays-for-Twitch,代码行数:15,代码来源:VideoCastManager.java
注:本文中的com.google.android.gms.cast.MediaQueueItem类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论