com.google.android.gms.cast.framework.CastSession Java Examples
The following examples show how to use
com.google.android.gms.cast.framework.CastSession.
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: VideoBrowserActivity.java From CastVideos-android with Apache License 2.0 | 6 votes |
@Override protected void onResume() { mCastContext.addCastStateListener(mCastStateListener); mCastContext.getSessionManager().addSessionManagerListener( mSessionManagerListener, CastSession.class); intentToJoin(); if (mCastSession == null) { mCastSession = CastContext.getSharedInstance(this).getSessionManager() .getCurrentCastSession(); } if (mQueueMenuItem != null) { mQueueMenuItem.setVisible( (mCastSession != null) && mCastSession.isConnected()); } super.onResume(); }
Example #2
Source File: VideoDetailsFragment.java From Loop with Apache License 2.0 | 6 votes |
@Override public void onPause() { super.onPause(); castContext.getSessionManager().removeSessionManagerListener( sessionManagerListener, CastSession.class); switch (location) { case LOCAL: pauseLocalVideo(); break; case REMOTE: break; default: break; } }
Example #3
Source File: StreamFragment.java From Pocket-Plays-for-Twitch with GNU General Public License v3.0 | 6 votes |
@Override public void onCastStateChanged(int i) { switch (i) { case CastState.CONNECTED: CastSession session = mCastContext != null ? mCastContext.getSessionManager().getCurrentCastSession() : null; if (session == null) break; castingTextView.setText(getString(R.string.stream_chromecast_playing, session.getCastDevice().getFriendlyName())); break; case CastState.CONNECTING: castingTextView.setText(getString(R.string.stream_chromecast_connecting)); break; default: break; } }
Example #4
Source File: MusicService.java From klingar with Apache License 2.0 | 6 votes |
@Override public void onDestroy() { Timber.d("onDestroy"); // Service is being killed, so make sure we release our resources playbackManager.handleStopRequest(); mediaNotificationManager.stopNotification(); if (castSessionManager != null) { castSessionManager.removeSessionManagerListener(castSessionManagerListener, CastSession.class); } timelineManager.stop(); delayedStopHandler.removeCallbacksAndMessages(null); session.release(); }
Example #5
Source File: LocalPlayerActivity.java From CastVideos-android with Apache License 2.0 | 6 votes |
@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); }
Example #6
Source File: GoogleCastSessionManagerListener.java From react-native-google-cast with MIT License | 6 votes |
private void onApplicationConnected(final CastSession castSession) { module.setCastSession(castSession); module.runOnUiQueueThread(new Runnable() { @Override public void run() { RemoteMediaClient client = castSession.getRemoteMediaClient(); if (client == null) { return; } remoteMediaClientListener = new GoogleCastRemoteMediaClientListener(module); client.addListener(remoteMediaClientListener); client.addProgressListener(remoteMediaClientListener, 1000); } }); }
Example #7
Source File: LocalPlayerActivity.java From cast-videos-android with Apache License 2.0 | 6 votes |
@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); }
Example #8
Source File: VideoBrowserActivity.java From CastVideos-android with Apache License 2.0 | 5 votes |
@Override public void onSessionEnded(CastSession session, int error) { if (session == mCastSession) { mCastSession = null; } invalidateOptionsMenu(); }
Example #9
Source File: QueueListViewActivity.java From CastVideos-android with Apache License 2.0 | 5 votes |
@Override public void onSessionSuspended(CastSession session, int reason) { if (mRemoteMediaClient != null) { mRemoteMediaClient.unregisterCallback(mRemoteMediaClientCallback); } mRemoteMediaClient = null; }
Example #10
Source File: MusicService.java From klingar with Apache License 2.0 | 5 votes |
@Override public void onCreate() { super.onCreate(); Timber.d("onCreate"); KlingarApp.get(this).component().inject(this); Playback playback = new LocalPlayback(getApplicationContext(), musicController, audioManager, wifiManager, client); playbackManager = new PlaybackManager(queueManager, this, AndroidClock.DEFAULT, playback); session = new MediaSessionCompat(this, "MusicService"); try { MediaControllerCompat mediaController = new MediaControllerCompat(this.getApplicationContext(), session.getSessionToken()); musicController.setMediaController(mediaController); } catch (RemoteException e) { Timber.e(e, "Could not create MediaController"); throw new IllegalStateException(); } session.setCallback(playbackManager.getMediaSessionCallback()); Context context = getApplicationContext(); Intent intent = new Intent(context, KlingarActivity.class); session.setSessionActivity(PendingIntent.getActivity(context, 99, intent, FLAG_UPDATE_CURRENT)); playbackManager.updatePlaybackState(); mediaNotificationManager = new MediaNotificationManager(this, musicController, queueManager, rx); castSessionManager = CastContext.getSharedInstance(this).getSessionManager(); castSessionManagerListener = new CastSessionManagerListener(); castSessionManager.addSessionManagerListener(castSessionManagerListener, CastSession.class); mediaRouter = MediaRouter.getInstance(getApplicationContext()); timelineManager = new TimelineManager(musicController, queueManager, media, rx); timelineManager.start(); }
Example #11
Source File: MusicService.java From klingar with Apache License 2.0 | 5 votes |
@Override public void onSessionEnding(CastSession session) { // This is our final chance to update the underlying stream position // In onSessionEnded(), the underlying CastPlayback#mRemoteMediaClient // is disconnected and hence we update our local value of stream position // to the latest position. playbackManager.getPlayback().updateLastKnownStreamPosition(); }
Example #12
Source File: QueueListViewActivity.java From CastVideos-android with Apache License 2.0 | 5 votes |
@Override protected void onPause() { if (mRemoteMediaClient != null) { mRemoteMediaClient.unregisterCallback(mRemoteMediaClientCallback); } mCastContext.getSessionManager().removeSessionManagerListener( mSessionManagerListener, CastSession.class); super.onPause(); }
Example #13
Source File: ChromeCastDiscovery.java From DeviceConnect-Android with MIT License | 5 votes |
@Override public void onSessionSuspended(CastSession castSession, int i) { if (BuildConfig.DEBUG) { Log.d(TAG, "================================>"); Log.d(TAG, "SessionManagerListener.onSessionSuspended"); Log.d(TAG, "<================================"); } mCallbacks.onCastDeviceUnselected(mSelectedDevice); }
Example #14
Source File: ChromeCastDiscovery.java From DeviceConnect-Android with MIT License | 5 votes |
@Override public void onSessionResumeFailed(CastSession castSession, int i) { if (BuildConfig.DEBUG) { Log.d(TAG, "================================>"); Log.d(TAG, "SessionManagerListener.onSessionResumeFailed"); Log.d(TAG, "<================================"); } }
Example #15
Source File: GoogleCastModule.java From react-native-google-cast with MIT License | 5 votes |
@Override public void onHostResume() { getReactApplicationContext().runOnUiQueueThread(new Runnable() { @Override public void run() { SessionManager sessionManager = CastContext.getSharedInstance(getReactApplicationContext()) .getSessionManager(); sessionManager.addSessionManagerListener(mSessionManagerListener, CastSession.class); } }); }
Example #16
Source File: LocalPlayerActivity.java From cast-videos-android with Apache License 2.0 | 5 votes |
@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); } super.onResume(); }
Example #17
Source File: VideoBrowserActivity.java From CastVideos-android with Apache License 2.0 | 5 votes |
@Override protected void onPause() { mCastContext.removeCastStateListener(mCastStateListener); mCastContext.getSessionManager().removeSessionManagerListener( mSessionManagerListener, CastSession.class); super.onPause(); }
Example #18
Source File: CastPlayback.java From klingar with Apache License 2.0 | 5 votes |
CastPlayback(Context context) { appContext = context.getApplicationContext(); CastSession castSession = CastContext.getSharedInstance(appContext).getSessionManager() .getCurrentCastSession(); remoteMediaClient = castSession.getRemoteMediaClient(); remoteMediaClientCallback = new CastMediaClientCallback(); }
Example #19
Source File: GoogleCastModule.java From react-native-google-cast with MIT License | 5 votes |
@Override public void onHostPause() { getReactApplicationContext().runOnUiQueueThread(new Runnable() { @Override public void run() { SessionManager sessionManager = CastContext.getSharedInstance(getReactApplicationContext()) .getSessionManager(); sessionManager.removeSessionManagerListener(mSessionManagerListener, CastSession.class); } }); }
Example #20
Source File: QueueListViewActivity.java From CastVideos-android with Apache License 2.0 | 5 votes |
@Override public void onSessionStarted(CastSession session, String sessionId) { mRemoteMediaClient = getRemoteMediaClient(); if (mRemoteMediaClient != null) { mRemoteMediaClient.registerCallback(mRemoteMediaClientCallback); } }
Example #21
Source File: ChromeCastDiscovery.java From DeviceConnect-Android with MIT License | 5 votes |
@Override public void onSessionEnded(CastSession castSession, int i) { if (BuildConfig.DEBUG) { Log.d(TAG, "================================>"); Log.d(TAG, "SessionManagerListener.onSessionEnded"); Log.d(TAG, "<================================"); } // WiFiをOFFにしたのちにChromeCastへリクエストを送ると、onSessionEndingが呼ばれずにこのメソッドが呼ばれる。 if (mIsEnding) { mCallbacks.onCastDeviceUnselected(mSelectedDevice); mSelectedDevice = null; } mIsEnding = false; }
Example #22
Source File: QueueListViewActivity.java From CastVideos-android with Apache License 2.0 | 5 votes |
@Override public void onSessionEnded(CastSession session, int error) { if (mRemoteMediaClient != null) { mRemoteMediaClient.registerCallback(mRemoteMediaClientCallback); } mRemoteMediaClient = null; mEmptyView.setVisibility(View.VISIBLE); }
Example #23
Source File: ChromeCastDiscovery.java From DeviceConnect-Android with MIT License | 5 votes |
@Override public void onSessionStarted(CastSession castSession, String s) { if (BuildConfig.DEBUG) { Log.d(TAG, "================================>"); Log.d(TAG, "SessionManagerListener.onSessionStarted"); Log.d(TAG, "<================================"); } mSelectedDevice = castSession.getCastDevice(); mCallbacks.onCastDeviceSelected(mSelectedDevice); }
Example #24
Source File: QueueListViewFragment.java From CastVideos-android with Apache License 2.0 | 5 votes |
private RemoteMediaClient getRemoteMediaClient() { CastSession castSession = CastContext.getSharedInstance(getContext()).getSessionManager() .getCurrentCastSession(); if (castSession != null && castSession.isConnected()) { return castSession.getRemoteMediaClient(); } return null; }
Example #25
Source File: CastApplication.java From googleads-ima-android with Apache License 2.0 | 5 votes |
private void onApplicationConnected(CastSession castSession) { mCastSession = castSession; try { mCastSession.setMessageReceivedCallbacks(NAMESPACE, CastApplication.this); } catch (IOException e) { Log.e(TAG, "Exception when creating channel", e); } mVideoPlayerController = mVideoFragment.getVideoPlayerController(); mAdTagUrl = mVideoPlayerController.getAdTagUrl(); mContentUrl = mVideoPlayerController.getContentVideoUrl(); mVideoPlayerController.pause(); loadMedia(); mActivity.invalidateOptionsMenu(); }
Example #26
Source File: QueueDataProvider.java From CastVideos-android with Apache License 2.0 | 5 votes |
private RemoteMediaClient getRemoteMediaClient() { CastSession castSession = CastContext.getSharedInstance(mAppContext).getSessionManager() .getCurrentCastSession(); if (castSession == null || !castSession.isConnected()) { Log.w(TAG, "Trying to get a RemoteMediaClient when no CastSession is started."); return null; } return castSession.getRemoteMediaClient(); }
Example #27
Source File: MusicService.java From klingar with Apache License 2.0 | 4 votes |
@Override public void onSessionResumed(CastSession session, boolean wasSuspended) { }
Example #28
Source File: QueueDataProvider.java From CastVideos-android with Apache License 2.0 | 4 votes |
@Override public void onSessionStarting(CastSession session) { }
Example #29
Source File: GoogleCastSessionManagerListener.java From react-native-google-cast with MIT License | 4 votes |
@Override public void onSessionResumeFailed(CastSession session, int error) { onApplicationDisconnected(); // TODO: find corresponding iOS event }
Example #30
Source File: QueueDataProvider.java From CastVideos-android with Apache License 2.0 | 4 votes |
@Override public void onSessionStartFailed(CastSession session, int error) { }