本文整理汇总了Java中com.google.android.gms.cast.RemoteMediaPlayer.MediaChannelResult类的典型用法代码示例。如果您正苦于以下问题:Java MediaChannelResult类的具体用法?Java MediaChannelResult怎么用?Java MediaChannelResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MediaChannelResult类属于com.google.android.gms.cast.RemoteMediaPlayer包,在下文中一共展示了MediaChannelResult类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadMedia
import com.google.android.gms.cast.RemoteMediaPlayer.MediaChannelResult; //导入依赖的package包/类
/**
* Loads a media. For this to succeed, you need to have successfully launched the application.
*
* @param media The media to be loaded
* @param activeTracks An array containing the list of track IDs to be set active for this
* media upon a successful load
* @param autoPlay If <code>true</code>, playback starts after load
* @param position Where to start the playback (only used if autoPlay is <code>true</code>).
* Units is milliseconds.
* @param customData Optional {@link JSONObject} data to be passed to the cast device
* @throws NoConnectionException
* @throws TransientNetworkDisconnectionException
*/
public void loadMedia(MediaInfo media, final long[] activeTracks, boolean autoPlay,
int position, JSONObject customData)
throws TransientNetworkDisconnectionException, NoConnectionException {
LOGD(TAG, "loadMedia");
checkConnectivity();
if (media == null) {
return;
}
if (mRemoteMediaPlayer == null) {
LOGE(TAG, "Trying to load a video with no active media session");
throw new NoConnectionException();
}
mRemoteMediaPlayer.load(mApiClient, media, autoPlay, position, activeTracks, customData)
.setResultCallback(new ResultCallback<RemoteMediaPlayer.MediaChannelResult>() {
@Override
public void onResult(MediaChannelResult result) {
for (VideoCastConsumer consumer : mVideoConsumers) {
consumer.onMediaLoadResult(result.getStatus().getStatusCode());
}
}
});
}
示例2: queueUpdateItems
import com.google.android.gms.cast.RemoteMediaPlayer.MediaChannelResult; //导入依赖的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());
}
}
});
}
示例3: queueJumpToItem
import com.google.android.gms.cast.RemoteMediaPlayer.MediaChannelResult; //导入依赖的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());
}
}
});
}
示例4: queueRemoveItems
import com.google.android.gms.cast.RemoteMediaPlayer.MediaChannelResult; //导入依赖的package包/类
/**
* Removes a list of items from the queue. If the remaining queue is empty, the media session
* will be terminated.
*
* @param itemIdsToRemove The list of media item IDs to remove. Must not be {@code null} or
* empty.
* @param customData Custom application-specific data to pass along with the request. May be
* {@code null}.
* @throws TransientNetworkDisconnectionException
* @throws NoConnectionException
* @throws IllegalArgumentException
*/
public void queueRemoveItems(final int[] itemIdsToRemove, final JSONObject customData)
throws TransientNetworkDisconnectionException, NoConnectionException,
IllegalArgumentException {
LOGD(TAG, "queueRemoveItems");
checkConnectivity();
if (itemIdsToRemove == null || itemIdsToRemove.length == 0) {
throw new IllegalArgumentException("itemIds cannot be empty or null");
}
if (mRemoteMediaPlayer == null) {
LOGE(TAG, "Trying to remove items from queue with no active media session");
throw new NoConnectionException();
}
mRemoteMediaPlayer
.queueRemoveItems(mApiClient, itemIdsToRemove, customData).setResultCallback(
new ResultCallback<MediaChannelResult>() {
@Override
public void onResult(MediaChannelResult result) {
for (VideoCastConsumer consumer : mVideoConsumers) {
consumer.onMediaQueueOperationResult(QUEUE_OPERATION_REMOVE_ITEMS,
result.getStatus().getStatusCode());
}
}
});
}
示例5: queueRemoveItem
import com.google.android.gms.cast.RemoteMediaPlayer.MediaChannelResult; //导入依赖的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());
}
}
});
}
示例6: queueAppendItem
import com.google.android.gms.cast.RemoteMediaPlayer.MediaChannelResult; //导入依赖的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());
}
}
});
}
示例7: queueNext
import com.google.android.gms.cast.RemoteMediaPlayer.MediaChannelResult; //导入依赖的package包/类
/**
* Jumps to the next item in the queue.
*
* @param customData Custom application-specific data to pass along with the request. May be
* {@code null}.
* @throws TransientNetworkDisconnectionException
* @throws NoConnectionException
*/
public void queueNext(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
.queueNext(mApiClient, customData).setResultCallback(
new ResultCallback<MediaChannelResult>() {
@Override
public void onResult(MediaChannelResult result) {
for (VideoCastConsumer consumer : mVideoConsumers) {
consumer.onMediaQueueOperationResult(QUEUE_OPERATION_NEXT,
result.getStatus().getStatusCode());
}
}
});
}
示例8: queuePrev
import com.google.android.gms.cast.RemoteMediaPlayer.MediaChannelResult; //导入依赖的package包/类
/**
* Jumps to the previous item in the queue.
*
* @param customData Custom application-specific data to pass along with the request. May be
* {@code null}.
* @throws TransientNetworkDisconnectionException
* @throws NoConnectionException
*/
public void queuePrev(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
.queuePrev(mApiClient, customData).setResultCallback(
new ResultCallback<MediaChannelResult>() {
@Override
public void onResult(MediaChannelResult result) {
for (VideoCastConsumer consumer : mVideoConsumers) {
consumer.onMediaQueueOperationResult(QUEUE_OPERATION_PREV,
result.getStatus().getStatusCode());
}
}
});
}
示例9: queueSetRepeatMode
import com.google.android.gms.cast.RemoteMediaPlayer.MediaChannelResult; //导入依赖的package包/类
/**
* Sets the repeat mode of the queue.
*
* @param repeatMode The repeat playback mode for the queue.
* @param customData Custom application-specific data to pass along with the request. May be
* {@code null}.
* @throws TransientNetworkDisconnectionException
* @throws NoConnectionException
*/
public void queueSetRepeatMode(final int repeatMode, 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
.queueSetRepeatMode(mApiClient, repeatMode, customData).setResultCallback(
new ResultCallback<MediaChannelResult>() {
@Override
public void onResult(MediaChannelResult result) {
if (!result.getStatus().isSuccess()) {
LOGD(TAG, "Failed with status: " + result.getStatus());
}
for (VideoCastConsumer consumer : mVideoConsumers) {
consumer.onMediaQueueOperationResult(QUEUE_OPERATION_SET_REPEAT,
result.getStatus().getStatusCode());
}
}
});
}
示例10: play
import com.google.android.gms.cast.RemoteMediaPlayer.MediaChannelResult; //导入依赖的package包/类
/**
* Resumes the playback from where it was left (can be the beginning).
*
* @param customData Optional {@link JSONObject} data to be passed to the cast device
* @throws NoConnectionException
* @throws TransientNetworkDisconnectionException
*/
public void play(JSONObject customData) throws
TransientNetworkDisconnectionException, NoConnectionException {
LOGD(TAG, "play(customData)");
checkConnectivity();
if (mRemoteMediaPlayer == null) {
LOGE(TAG, "Trying to play a video with no active media session");
throw new NoConnectionException();
}
mRemoteMediaPlayer.play(mApiClient, customData)
.setResultCallback(new ResultCallback<MediaChannelResult>() {
@Override
public void onResult(MediaChannelResult result) {
if (!result.getStatus().isSuccess()) {
onFailed(R.string.ccl_failed_to_play,
result.getStatus().getStatusCode());
}
}
});
}
示例11: stop
import com.google.android.gms.cast.RemoteMediaPlayer.MediaChannelResult; //导入依赖的package包/类
/**
* Stops the playback of media/stream
*
* @param customData Optional {@link JSONObject}
* @throws TransientNetworkDisconnectionException
* @throws NoConnectionException
*/
public void stop(JSONObject customData) throws
TransientNetworkDisconnectionException, NoConnectionException {
LOGD(TAG, "stop()");
checkConnectivity();
if (mRemoteMediaPlayer == null) {
LOGE(TAG, "Trying to stop a stream with no active media session");
throw new NoConnectionException();
}
mRemoteMediaPlayer.stop(mApiClient, customData).setResultCallback(
new ResultCallback<MediaChannelResult>() {
@Override
public void onResult(MediaChannelResult result) {
if (!result.getStatus().isSuccess()) {
onFailed(R.string.ccl_failed_to_stop,
result.getStatus().getStatusCode());
}
}
}
);
}
示例12: pause
import com.google.android.gms.cast.RemoteMediaPlayer.MediaChannelResult; //导入依赖的package包/类
/**
* Pauses the playback.
*
* @param customData Optional {@link JSONObject} data to be passed to the cast device
* @throws NoConnectionException
* @throws TransientNetworkDisconnectionException
*/
public void pause(JSONObject customData) throws
TransientNetworkDisconnectionException, NoConnectionException {
LOGD(TAG, "attempting to pause media");
checkConnectivity();
if (mRemoteMediaPlayer == null) {
LOGE(TAG, "Trying to pause a video with no active media session");
throw new NoConnectionException();
}
mRemoteMediaPlayer.pause(mApiClient, customData)
.setResultCallback(new ResultCallback<MediaChannelResult>() {
@Override
public void onResult(MediaChannelResult result) {
if (!result.getStatus().isSuccess()) {
onFailed(R.string.ccl_failed_to_pause,
result.getStatus().getStatusCode());
}
}
});
}
示例13: seek
import com.google.android.gms.cast.RemoteMediaPlayer.MediaChannelResult; //导入依赖的package包/类
/**
* Seeks to the given point without changing the state of the player, i.e. after seek is
* completed, it resumes what it was doing before the start of seek.
*
* @param position in milliseconds
* @throws NoConnectionException
* @throws TransientNetworkDisconnectionException
*/
public void seek(int position) throws TransientNetworkDisconnectionException,
NoConnectionException {
LOGD(TAG, "attempting to seek media");
checkConnectivity();
if (mRemoteMediaPlayer == null) {
LOGE(TAG, "Trying to seek a video with no active media session");
throw new NoConnectionException();
}
mRemoteMediaPlayer.seek(mApiClient,
position,
RemoteMediaPlayer.RESUME_STATE_UNCHANGED).
setResultCallback(new ResultCallback<MediaChannelResult>() {
@Override
public void onResult(MediaChannelResult result) {
if (!result.getStatus().isSuccess()) {
onFailed(R.string.ccl_failed_seek, result.getStatus().getStatusCode());
}
}
});
}
示例14: seekAndPlay
import com.google.android.gms.cast.RemoteMediaPlayer.MediaChannelResult; //导入依赖的package包/类
/**
* Seeks to the given point and starts playback regardless of the starting state.
*
* @param position in milliseconds
* @throws NoConnectionException
* @throws TransientNetworkDisconnectionException
*/
public void seekAndPlay(int position) throws TransientNetworkDisconnectionException,
NoConnectionException {
LOGD(TAG, "attempting to seek media");
checkConnectivity();
if (mRemoteMediaPlayer == null) {
LOGE(TAG, "Trying to seekAndPlay a video with no active media session");
throw new NoConnectionException();
}
ResultCallback<MediaChannelResult> resultCallback =
new ResultCallback<MediaChannelResult>() {
@Override
public void onResult(MediaChannelResult result) {
if (!result.getStatus().isSuccess()) {
onFailed(R.string.ccl_failed_seek, result.getStatus().getStatusCode());
}
}
};
mRemoteMediaPlayer.seek(mApiClient,
position,
RemoteMediaPlayer.RESUME_STATE_PLAY).setResultCallback(resultCallback);
}
示例15: setActiveTrackIds
import com.google.android.gms.cast.RemoteMediaPlayer.MediaChannelResult; //导入依赖的package包/类
/**
* Sets the active tracks for the currently loaded media.
*/
public void setActiveTrackIds(long[] trackIds) {
if (mRemoteMediaPlayer == null || mRemoteMediaPlayer.getMediaInfo() == null) {
return;
}
mRemoteMediaPlayer.setActiveMediaTracks(mApiClient, trackIds)
.setResultCallback(new ResultCallback<MediaChannelResult>() {
@Override
public void onResult(MediaChannelResult mediaChannelResult) {
LOGD(TAG, "Setting track result was successful? "
+ mediaChannelResult.getStatus().isSuccess());
if (!mediaChannelResult.getStatus().isSuccess()) {
LOGD(TAG, "Failed since: " + mediaChannelResult.getStatus()
+ " and status code:" + mediaChannelResult.getStatus()
.getStatusCode());
}
}
});
}