本文整理汇总了Java中com.google.android.libraries.cast.companionlibrary.cast.exceptions.TransientNetworkDisconnectionException类的典型用法代码示例。如果您正苦于以下问题:Java TransientNetworkDisconnectionException类的具体用法?Java TransientNetworkDisconnectionException怎么用?Java TransientNetworkDisconnectionException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TransientNetworkDisconnectionException类属于com.google.android.libraries.cast.companionlibrary.cast.exceptions包,在下文中一共展示了TransientNetworkDisconnectionException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: showTracksChooserDialog
import com.google.android.libraries.cast.companionlibrary.cast.exceptions.TransientNetworkDisconnectionException; //导入依赖的package包/类
private void showTracksChooserDialog()
throws TransientNetworkDisconnectionException, NoConnectionException {
if(!(getContext() instanceof FragmentActivity))
throw new IllegalStateException("Activity needs to be FragmentActivity");
FragmentTransaction transaction = ((FragmentActivity)getContext()).getSupportFragmentManager().beginTransaction();
Fragment prev = ((FragmentActivity)getContext()).getSupportFragmentManager().findFragmentByTag(DIALOG_TAG);
if (prev != null) {
transaction.remove(prev);
}
transaction.addToBackStack(null);
// Create and show the dialog.
/* <--archos changes> */
ArchosTracksChooserDialog dialogFragment = ArchosTracksChooserDialog
.newInstance(ArchosVideoCastManager.getInstance().getMediaInfo());
/* <!--archos changes> */
dialogFragment.show(transaction, DIALOG_TAG);
}
示例2: showTracksChooserDialog
import com.google.android.libraries.cast.companionlibrary.cast.exceptions.TransientNetworkDisconnectionException; //导入依赖的package包/类
private void showTracksChooserDialog()
throws TransientNetworkDisconnectionException, NoConnectionException {
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
Fragment prev = getSupportFragmentManager().findFragmentByTag(DIALOG_TAG);
if (prev != null) {
transaction.remove(prev);
}
transaction.addToBackStack(null);
// Create and show the dialog.
/* <--archos changes> */
ArchosTracksChooserDialog dialogFragment = ArchosTracksChooserDialog
.newInstance(ArchosVideoCastManager.getInstance().getMediaInfo());
/* <!--archos changes> */
dialogFragment.show(transaction, DIALOG_TAG);
}
示例3: run
import com.google.android.libraries.cast.companionlibrary.cast.exceptions.TransientNetworkDisconnectionException; //导入依赖的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);
}
}
示例4: addMiniController
import com.google.android.libraries.cast.companionlibrary.cast.exceptions.TransientNetworkDisconnectionException; //导入依赖的package包/类
public void addMiniController(IMiniController miniController,
MiniController.OnMiniControllerChangedListener onChangedListener) {
if (miniController != null) {
boolean result;
synchronized (mMiniControllers) {
result = mMiniControllers.add(miniController);
}
if (result) {
miniController.setOnMiniControllerChangedListener(onChangedListener == null ? this
: onChangedListener);
try {
if (isConnected()) {
updateMiniController(miniController);
miniController.setVisibility(shouldMiniControllerBeVisible()?View.VISIBLE:View.GONE);
}
} catch (TransientNetworkDisconnectionException | NoConnectionException e) {
}
} else {
}
}
}
示例5: CastDebug
import com.google.android.libraries.cast.companionlibrary.cast.exceptions.TransientNetworkDisconnectionException; //导入依赖的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);
}
示例6: updateMetadata
import com.google.android.libraries.cast.companionlibrary.cast.exceptions.TransientNetworkDisconnectionException; //导入依赖的package包/类
private void updateMetadata() {
MediaInfo info;
try {
info = mCastManager.getRemoteMediaInformation();
} catch (TransientNetworkDisconnectionException | NoConnectionException e) {
hideControls(true, R.string.ccl_failed_no_connection_short);
return;
}
if (info == null) {
hideControls(true, R.string.ccl_no_media_info);
return;
}
mStreamType = info.getStreamType();
hideControls(false, 0);
MediaMetadata mm = info.getMetadata();
mTitle.setText(mm.getString(MediaMetadata.KEY_TITLE));
mSubTitle.setText(mm.getString(MediaMetadata.KEY_SUBTITLE));
setIcon(mm.hasImages() ? mm.getImages().get(0).getUrl() : null);
}
示例7: addNamespace
import com.google.android.libraries.cast.companionlibrary.cast.exceptions.TransientNetworkDisconnectionException; //导入依赖的package包/类
/**
* Adds a channel with the given {@code namespace} and registers {@link DataCastManager} as
* the callback receiver. If the namespace is already registered, this returns
* <code>false</code>, otherwise returns <code>true</code>.
*
* @throws NoConnectionException If no connectivity to the device exists
* @throws TransientNetworkDisconnectionException If framework is still trying to recover from a
* possibly transient loss of network
*/
public boolean addNamespace(String namespace) throws
TransientNetworkDisconnectionException, NoConnectionException {
checkConnectivity();
if (TextUtils.isEmpty(namespace)) {
throw new IllegalArgumentException("namespace cannot be empty");
}
if (mNamespaceList.contains(namespace)) {
LOGD(TAG, "Ignoring to add a namespace that is already added.");
return false;
}
try {
Cast.CastApi.setMessageReceivedCallbacks(mApiClient, namespace, this);
mNamespaceList.add(namespace);
return true;
} catch (IOException | IllegalStateException e) {
LOGE(TAG, String.format("addNamespace(%s)", namespace), e);
}
return false;
}
示例8: removeNamespace
import com.google.android.libraries.cast.companionlibrary.cast.exceptions.TransientNetworkDisconnectionException; //导入依赖的package包/类
/**
* Unregisters a namespace. If namespace is not already registered, it returns
* <code>false</code>, otherwise a successful removal returns <code>true</code>.
*
* @throws NoConnectionException If no connectivity to the device exists
* @throws TransientNetworkDisconnectionException If framework is still trying to recover from a
* possibly transient loss of network
*/
public boolean removeNamespace(String namespace) throws TransientNetworkDisconnectionException,
NoConnectionException {
checkConnectivity();
if (TextUtils.isEmpty(namespace)) {
throw new IllegalArgumentException("namespace cannot be empty");
}
if (!mNamespaceList.contains(namespace)) {
LOGD(TAG, "Ignoring to remove a namespace that is not registered.");
return false;
}
try {
Cast.CastApi.removeMessageReceivedCallbacks(mApiClient, namespace);
mNamespaceList.remove(namespace);
return true;
} catch (IOException | IllegalStateException e) {
LOGE(TAG, String.format("removeNamespace(%s)", namespace), e);
}
return false;
}
示例9: updateMiniController
import com.google.android.libraries.cast.companionlibrary.cast.exceptions.TransientNetworkDisconnectionException; //导入依赖的package包/类
/**
* Updates the information and state of a MiniController.
*
* @throws TransientNetworkDisconnectionException
* @throws NoConnectionException
*/
private void updateMiniController(IMiniController controller)
throws TransientNetworkDisconnectionException, NoConnectionException {
checkConnectivity();
checkRemoteMediaPlayerAvailable();
if (mRemoteMediaPlayer.getStreamDuration() > 0 || isRemoteStreamLive()) {
MediaInfo mediaInfo = getRemoteMediaInformation();
MediaMetadata mm = mediaInfo.getMetadata();
controller.setStreamType(mediaInfo.getStreamType());
controller.setPlaybackStatus(mState, mIdleReason);
controller.setSubtitle(mContext.getResources().getString(R.string.ccl_casting_to_device,
mDeviceName));
controller.setTitle(mm.getString(MediaMetadata.KEY_TITLE));
controller.setIcon(Utils.getImageUri(mediaInfo, 0));
}
}
示例10: shouldRemoteUiBeVisible
import com.google.android.libraries.cast.companionlibrary.cast.exceptions.TransientNetworkDisconnectionException; //导入依赖的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;
}
示例11: stopApplication
import com.google.android.libraries.cast.companionlibrary.cast.exceptions.TransientNetworkDisconnectionException; //导入依赖的package包/类
/**
* Stops the application on the receiver device.
*
* @throws NoConnectionException
* @throws TransientNetworkDisconnectionException
*/
public final void stopApplication()
throws TransientNetworkDisconnectionException, NoConnectionException {
checkConnectivity();
Cast.CastApi.stopApplication(mApiClient, mSessionId).setResultCallback(
new ResultCallback<Status>() {
@Override
public void onResult(Status result) {
if (!result.isSuccess()) {
LOGD(TAG, "stopApplication -> onResult: stopping "
+ "application failed");
onApplicationStopFailed(result.getStatusCode());
} else {
LOGD(TAG, "stopApplication -> onResult Stopped application "
+ "successfully");
}
}
});
}
示例12: loadMedia
import com.google.android.libraries.cast.companionlibrary.cast.exceptions.TransientNetworkDisconnectionException; //导入依赖的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());
}
}
});
}
示例13: queueUpdateItems
import com.google.android.libraries.cast.companionlibrary.cast.exceptions.TransientNetworkDisconnectionException; //导入依赖的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());
}
}
});
}
示例14: queueJumpToItem
import com.google.android.libraries.cast.companionlibrary.cast.exceptions.TransientNetworkDisconnectionException; //导入依赖的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());
}
}
});
}
示例15: queueRemoveItems
import com.google.android.libraries.cast.companionlibrary.cast.exceptions.TransientNetworkDisconnectionException; //导入依赖的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());
}
}
});
}