本文整理汇总了Java中com.google.android.gms.cast.framework.CastSession类的典型用法代码示例。如果您正苦于以下问题:Java CastSession类的具体用法?Java CastSession怎么用?Java CastSession使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CastSession类属于com.google.android.gms.cast.framework包,在下文中一共展示了CastSession类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: playFiles
import com.google.android.gms.cast.framework.CastSession; //导入依赖的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);
}
示例2: onPause
import com.google.android.gms.cast.framework.CastSession; //导入依赖的package包/类
@Override
public void onPause() {
super.onPause();
if (castContext != null)
castContext.getSessionManager().removeSessionManagerListener(
sessionManagerListener, CastSession.class);
switch (location) {
case LOCAL:
pauseLocalVideo();
break;
case REMOTE:
break;
default:
break;
}
}
示例3: onPause
import com.google.android.gms.cast.framework.CastSession; //导入依赖的package包/类
@Override
protected void onPause() {
super.onPause();
Log.d(TAG, "onPause() was called");
if (mLocation == PlaybackLocation.LOCAL) {
if (mSeekbarTimer != null) {
mSeekbarTimer.cancel();
mSeekbarTimer = null;
}
if (mControllersTimer != null) {
mControllersTimer.cancel();
}
// since we are playing locally, we need to stop the playback of
// video (if user is not watching, pause it!)
mVideoView.pause();
mPlaybackState = PlaybackState.PAUSED;
updatePlayButton(PlaybackState.PAUSED);
}
mCastContext.getSessionManager().removeSessionManagerListener(
mSessionManagerListener, CastSession.class);
}
示例4: onResume
import com.google.android.gms.cast.framework.CastSession; //导入依赖的package包/类
@Override
protected void onResume() {
Log.d(TAG, "onResume() was called");
mCastContext.getSessionManager().addSessionManagerListener(
mSessionManagerListener, CastSession.class);
if (mCastSession != null && mCastSession.isConnected()) {
updatePlaybackLocation(PlaybackLocation.REMOTE);
} else {
updatePlaybackLocation(PlaybackLocation.LOCAL);
}
if (mQueueMenuItem != null) {
mQueueMenuItem.setVisible(
(mCastSession != null) && mCastSession.isConnected());
}
super.onResume();
}
示例5: updatePlayPauseButtonImageResource
import com.google.android.gms.cast.framework.CastSession; //导入依赖的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);
}
}
示例6: onResume
import com.google.android.gms.cast.framework.CastSession; //导入依赖的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();
}
示例7: onSessionStarted
import com.google.android.gms.cast.framework.CastSession; //导入依赖的package包/类
@Override
public void onSessionStarted(CastSession castSession, String sessionId) {
Log.v(TAG, "Session started");
mCastSession = castSession;
invalidateOptionsMenu();
startCustomMessageChannel();
sendCredentials();
dashboard.setOnDataRefreshListener(new OnCompleteCallback() {
@Override
public void onComplete() {
sendAllOptions();
(new CastCommunicator(mCastSession)).sendAllWidgets(getApplicationContext(), getDashboard());
}
@Override
public void onError(Exception e) {
Bundle bundle = new Bundle();
bundle.putString("ERROR", e.toString());
mFirebaseAnalytics.logEvent("ON_CONNECTED_REFRESH_ON_ERROR", bundle);
}
});
}
示例8: onDestroy
import com.google.android.gms.cast.framework.CastSession; //导入依赖的package包/类
/**
* (non-Javadoc)
* @see android.app.Service#onDestroy()
*/
@Override
public void onDestroy() {
LogHelper.d(TAG, "onDestroy");
unregisterCarConnectionReceiver();
// Service is being killed, so make sure we release our resources
mPlaybackManager.handleStopRequest(null);
mMediaNotificationManager.stopNotification();
if (mCastSessionManager != null) {
mCastSessionManager.removeSessionManagerListener(mCastSessionManagerListener,
CastSession.class);
}
mDelayedStopHandler.removeCallbacksAndMessages(null);
mSession.release();
}
示例9: onPause
import com.google.android.gms.cast.framework.CastSession; //导入依赖的package包/类
@Override
public void onPause() {
super.onPause();
castContext.getSessionManager().removeSessionManagerListener(
sessionManagerListener, CastSession.class);
switch (location) {
case LOCAL:
pauseLocalVideo();
break;
case REMOTE:
break;
default:
break;
}
}
示例10: onResume
import com.google.android.gms.cast.framework.CastSession; //导入依赖的package包/类
@Override
protected void onResume() {
super.onResume();
Utils.log(TAG, "--- onResume()");
if (Utils.isGooglePlayServicesAvailable(this)) {
try {
mCastContext.getSessionManager().addSessionManagerListener(
mSessionManagerListener, CastSession.class);
} catch (Exception e) {
Log.e(TAG, "Cast Error - onResume", e);
}
}
hideSearch();
if (wifiLock == null) {
wifiLock = Utils.getWifiLock();
}
}
示例11: onResume
import com.google.android.gms.cast.framework.CastSession; //导入依赖的package包/类
@Override
public void onResume() {
super.onResume();
if (castContext != null)
castContext.getSessionManager().addSessionManagerListener(
sessionManagerListener, CastSession.class);
if (castSession != null && castSession.isConnected()) {
location = PlaybackLocation.REMOTE;
} else {
location = PlaybackLocation.LOCAL;
}
if (!isLocalVideoPlaying() && playbackState == PlaybackState.PLAYING) {
switch (location) {
case LOCAL:
resumeLocalVideo();
break;
case REMOTE:
updateLocalVideoPosition(castSession.getRemoteMediaClient().getApproximateStreamPosition());
resumeLocalVideo();
break;
default:
break;
}
}
}
示例12: registerCast
import com.google.android.gms.cast.framework.CastSession; //导入依赖的package包/类
private void registerCast() {
if (TextUtils.isEmpty(getString(R.string.cast_app_id)))
return;
mCastContext.addCastStateListener(mCastStateListener);
mCastContext.getSessionManager().addSessionManagerListener(
mSessionManagerListener, CastSession.class);
if (mCastSession == null) {
mCastSession = CastContext.getSharedInstance(this).getSessionManager()
.getCurrentCastSession();
}
if (mQueueMenuItem != null) {
mQueueMenuItem.setVisible(
(mCastSession != null) && mCastSession.isConnected());
}
}
示例13: unregisterCast
import com.google.android.gms.cast.framework.CastSession; //导入依赖的package包/类
private void unregisterCast() {
if (TextUtils.isEmpty(getString(R.string.cast_app_id)))
return;
mCastContext.removeCastStateListener(mCastStateListener);
mCastContext.getSessionManager().removeSessionManagerListener(
mSessionManagerListener, CastSession.class);
}
示例14: onSessionEnded
import com.google.android.gms.cast.framework.CastSession; //导入依赖的package包/类
@Override
public void onSessionEnded(CastSession session, int error) {
if (session == mCastSession) {
mCastSession = null;
}
invalidateOptionsMenu();
}
示例15: handleCurrentCastSession
import com.google.android.gms.cast.framework.CastSession; //导入依赖的package包/类
private void handleCurrentCastSession() {
CastSession newCastSession = CastContext.getSharedInstance(activity).getSessionManager().getCurrentCastSession();
if (castSession == null) {
if (newCastSession != null) {
onConnected(newCastSession);
}
} else {
if (newCastSession == null) {
onDisconnected();
} else if (newCastSession != castSession) {
onConnected(newCastSession);
}
}
}