com.google.android.gms.cast.ApplicationMetadata Java Examples
The following examples show how to use
com.google.android.gms.cast.ApplicationMetadata.
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: CastDeviceControllerImpl.java From android_packages_apps_GmsCore with Apache License 2.0 | 6 votes |
@Override public void spontaneousEventReceived(ChromeCastSpontaneousEvent event) { switch (event.getType()) { case MEDIA_STATUS: break; case STATUS: su.litvak.chromecast.api.v2.Status status = (su.litvak.chromecast.api.v2.Status)event.getData(); Application app = status.getRunningApp(); ApplicationMetadata metadata = this.createMetadataFromApplication(app); if (app != null) { this.onApplicationStatusChanged(new ApplicationStatus(app.statusText)); } int activeInputState = status.activeInput ? 1 : 0; int standbyState = status.standBy ? 1 : 0; this.onDeviceStatusChanged(new CastDeviceStatus(status.volume.level, status.volume.muted, activeInputState, metadata, standbyState)); break; case APPEVENT: break; case CLOSE: this.onApplicationDisconnected(CommonStatusCodes.SUCCESS); break; default: break; } }
Example #2
Source File: CastDeviceControllerImpl.java From android_packages_apps_GmsCore with Apache License 2.0 | 6 votes |
protected ApplicationMetadata createMetadataFromApplication(Application app) { if (app == null) { return null; } ApplicationMetadata metadata = new ApplicationMetadata(); metadata.applicationId = app.id; metadata.name = app.name; Log.d(TAG, "unimplemented: ApplicationMetadata.images"); Log.d(TAG, "unimplemented: ApplicationMetadata.senderAppLaunchUri"); metadata.images = new ArrayList<WebImage>(); metadata.namespaces = new ArrayList<String>(); for(Namespace namespace : app.namespaces) { metadata.namespaces.add(namespace.name); } metadata.senderAppIdentifier = this.context.getPackageName(); return metadata; }
Example #3
Source File: ChromeCastController.java From Popeens-DSub with GNU General Public License v3.0 | 6 votes |
ConnectionCallbacks(boolean isPlaying, int position) { this.isPlaying = isPlaying; this.position = position; resultCallback = new ResultCallback<Cast.ApplicationConnectionResult>() { @Override public void onResult(Cast.ApplicationConnectionResult result) { Status status = result.getStatus(); if (status.isSuccess()) { ApplicationMetadata applicationMetadata = result.getApplicationMetadata(); sessionId = result.getSessionId(); String applicationStatus = result.getApplicationStatus(); boolean wasLaunched = result.getWasLaunched(); applicationStarted = true; setupChannel(); } else { shutdownInternal(); } } }; }
Example #4
Source File: MainActivity.java From AndroidDemoProjects with Apache License 2.0 | 5 votes |
@Override public void onConnected( Bundle hint ) { if( mWaitingForReconnect ) { mWaitingForReconnect = false; reconnectChannels( hint ); } else { try { Cast.CastApi.launchApplication( mApiClient, getString( R.string.app_id ), false ) .setResultCallback( new ResultCallback<Cast.ApplicationConnectionResult>() { @Override public void onResult(Cast.ApplicationConnectionResult applicationConnectionResult) { Status status = applicationConnectionResult.getStatus(); if( status.isSuccess() ) { //Values that can be useful for storing/logic ApplicationMetadata applicationMetadata = applicationConnectionResult.getApplicationMetadata(); String sessionId = applicationConnectionResult.getSessionId(); String applicationStatus = applicationConnectionResult.getApplicationStatus(); boolean wasLaunched = applicationConnectionResult.getWasLaunched(); mApplicationStarted = true; reconnectChannels( null ); } } } ); } catch ( Exception e ) { } } }
Example #5
Source File: SessionImpl.java From android_packages_apps_GmsCore with Apache License 2.0 | 5 votes |
public void onApplicationConnectionSuccess(ApplicationMetadata applicationMetadata, String applicationStatus, String sessionId, boolean wasLaunched) { this.mIsConnecting = false; this.mIsConnected = true; this.castContext.getSessionManagerImpl().onSessionStarted(this, sessionId); try { this.castContext.getRouter().selectRouteById(this.getRouteId()); } catch (RemoteException ex) { Log.e(TAG, "Error calling selectRouteById: " + ex.getMessage()); } }
Example #6
Source File: CastDeviceControllerImpl.java From android_packages_apps_GmsCore with Apache License 2.0 | 5 votes |
public void onApplicationConnectionSuccess(ApplicationMetadata applicationMetadata, String applicationStatus, String sessionId, boolean wasLaunched) { if (this.listener != null) { try { this.listener.onApplicationConnectionSuccess(applicationMetadata, applicationStatus, sessionId, wasLaunched); } catch (RemoteException ex) { Log.e(TAG, "Error calling onApplicationConnectionSuccess: " + ex.getMessage()); } } }
Example #7
Source File: CastDeviceControllerImpl.java From android_packages_apps_GmsCore with Apache License 2.0 | 5 votes |
@Override public void launchApplication(String applicationId, LaunchOptions launchOptions) { Application app = null; try { app = this.chromecast.launchApp(applicationId); } catch (IOException e) { Log.w(TAG, "Error launching cast application: " + e.getMessage()); this.onApplicationConnectionFailure(CommonStatusCodes.NETWORK_ERROR); return; } this.sessionId = app.sessionId; ApplicationMetadata metadata = this.createMetadataFromApplication(app); this.onApplicationConnectionSuccess(metadata, app.statusText, app.sessionId, true); }
Example #8
Source File: CastApiImpl.java From android_external_GmsLib with Apache License 2.0 | 4 votes |
@Override public ApplicationMetadata getApplicationMetadata(GoogleApiClient client) { return null; }
Example #9
Source File: DataCastConsumerImpl.java From UTubeTV with The Unlicense | 4 votes |
@Override public void onApplicationConnected(ApplicationMetadata appMetadata, String applicationStatus, String sessionId, boolean wasLaunched) { }
Example #10
Source File: VideoCastConsumerImpl.java From UTubeTV with The Unlicense | 4 votes |
@Override public void onApplicationConnected(ApplicationMetadata appMetadata, String sessionId, boolean wasLaunched) { }
Example #11
Source File: CastActivity.java From UTubeTV with The Unlicense | 4 votes |
private void setupCastListener() { mCastConsumer = new VideoCastConsumerImpl() { @Override public void onApplicationConnected(ApplicationMetadata appMetadata, String sessionId, boolean wasLaunched) { Log.d(TAG, "onApplicationLaunched() is reached"); if (null != mSelectedMedia) { if (mPlaybackState == PlaybackState.PLAYING) { try { loadRemoteMedia(0, true); finish(); } catch (Exception e) { DUtils.log(e.getMessage()); } } else { } } } @Override public void onApplicationDisconnected(int errorCode) { Log.d(TAG, "onApplicationDisconnected() is reached with errorCode: " + errorCode); } @Override public void onDisconnected() { Log.d(TAG, "onDisconnected() is reached"); mPlaybackState = PlaybackState.PAUSED; } @Override public void onRemoteMediaPlayerMetadataUpdated() { try { mRemoteMediaInformation = mCastManager.getRemoteMediaInformation(); } catch (Exception e) { // silent } } @Override public void onFailed(int resourceId, int statusCode) { } @Override public void onConnectionSuspended(int cause) { Utils.toast(CastActivity.this, "Connection Lost"); } @Override public void onConnectivityRecovered() { Utils.toast(CastActivity.this, "Connection Recovered"); } }; }
Example #12
Source File: CastSessionImpl.java From android_packages_apps_GmsCore with Apache License 2.0 | 4 votes |
@Override public void onApplicationConnectionSuccess(ApplicationMetadata applicationMetadata, String applicationStatus, String sessionId, boolean wasLaunched) { this.session.onApplicationConnectionSuccess(applicationMetadata, applicationStatus, sessionId, wasLaunched); }
Example #13
Source File: CreateRouteRequest.java From delion with Apache License 2.0 | 4 votes |
@Override public void onApplicationMetadataChanged(ApplicationMetadata metadata) { if (mSession == null) return; mSession.updateSessionStatus(); }
Example #14
Source File: CastSessionImpl.java From 365browser with Apache License 2.0 | 4 votes |
/** * Initializes a new {@link CastSessionImpl} instance. * @param apiClient The Google Play Services client used to create the session. * @param sessionId The session identifier to use with the Cast SDK. * @param origin The origin of the frame requesting the route. * @param tabId The id of the tab containing the frame requesting the route. * @param isIncognito Whether the route is beging requested from an Incognito profile. * @param source The {@link MediaSource} corresponding to this session. * @param routeProvider The {@link CastMediaRouteProvider} instance managing this session. */ public CastSessionImpl( GoogleApiClient apiClient, String sessionId, ApplicationMetadata metadata, String applicationStatus, CastDevice castDevice, String origin, int tabId, boolean isIncognito, MediaSource source, CastMediaRouteProvider routeProvider) { mSessionId = sessionId; mRouteProvider = routeProvider; mApiClient = apiClient; mSource = source; mApplicationMetadata = metadata; mApplicationStatus = applicationStatus; mCastDevice = castDevice; mMessageHandler = mRouteProvider.getMessageHandler(); mMessageChannel = new CastMessagingChannel(this); updateNamespaces(); if (mNamespaces.contains(CastMessageHandler.MEDIA_NAMESPACE)) { mMediaPlayer = new RemoteMediaPlayer(); mMediaPlayer.setOnStatusUpdatedListener( new RemoteMediaPlayer.OnStatusUpdatedListener() { @Override public void onStatusUpdated() { MediaStatus mediaStatus = mMediaPlayer.getMediaStatus(); if (mediaStatus == null) return; int playerState = mediaStatus.getPlayerState(); if (playerState == MediaStatus.PLAYER_STATE_PAUSED || playerState == MediaStatus.PLAYER_STATE_PLAYING) { mNotificationBuilder.setPaused( playerState != MediaStatus.PLAYER_STATE_PLAYING); mNotificationBuilder.setActions(MediaNotificationInfo.ACTION_STOP | MediaNotificationInfo.ACTION_PLAY_PAUSE); } else { mNotificationBuilder.setActions(MediaNotificationInfo.ACTION_STOP); } MediaNotificationManager.show(mNotificationBuilder.build()); } }); mMediaPlayer.setOnMetadataUpdatedListener( new RemoteMediaPlayer.OnMetadataUpdatedListener() { @Override public void onMetadataUpdated() { setNotificationMetadata(mNotificationBuilder); MediaNotificationManager.show(mNotificationBuilder.build()); } }); } Intent contentIntent = Tab.createBringTabToFrontIntent(tabId); if (contentIntent != null) { contentIntent.putExtra(MediaNotificationUma.INTENT_EXTRA_NAME, MediaNotificationUma.SOURCE_PRESENTATION); } mNotificationBuilder = new MediaNotificationInfo.Builder() .setPaused(false) .setOrigin(origin) // TODO(avayvod): the same session might have more than one tab id. Should we track // the last foreground alive tab and update the notification with it? .setTabId(tabId) .setPrivate(isIncognito) .setActions(MediaNotificationInfo.ACTION_STOP) .setContentIntent(contentIntent) .setNotificationSmallIcon(R.drawable.ic_notification_media_route) .setDefaultNotificationLargeIcon(R.drawable.cast_playing_square) .setId(R.id.presentation_notification) .setListener(this); setNotificationMetadata(mNotificationBuilder); MediaNotificationManager.show(mNotificationBuilder.build()); }
Example #15
Source File: CreateRouteRequest.java From 365browser with Apache License 2.0 | 4 votes |
@Override public void onApplicationMetadataChanged(ApplicationMetadata metadata) { if (mSession == null) return; mSession.updateSessionStatus(); }
Example #16
Source File: LocalPlayerActivity.java From android with Apache License 2.0 | 4 votes |
private void setupCastListener() { mCastConsumer = new VideoCastConsumerImpl() { @Override public void onApplicationConnected(ApplicationMetadata appMetadata, String sessionId, boolean wasLaunched) { Log.d(TAG, "onApplicationLaunched() is reached"); if (null != mLink) { if (mPlaybackState == PlaybackState.PLAYING) { mVideoView.pause(); try { if (mCastPlugin) { loadRemoteMedia(mSeekbar.getProgress(), true); finish(); } else { AppUtils.showCastDialog(LocalPlayerActivity.this); } } catch (Exception ignored) { } } else { updatePlaybackLocation(PlaybackLocation.REMOTE); } } } @Override public void onApplicationDisconnected(int errorCode) { Log.d(TAG, "onApplicationDisconnected() is reached with errorCode: " + errorCode); updatePlaybackLocation(PlaybackLocation.LOCAL); } @Override public void onDisconnected() { Log.d(TAG, "onDisconnected() is reached"); mPlaybackState = PlaybackState.PAUSED; mLocation = PlaybackLocation.LOCAL; } @Override public void onRemoteMediaPlayerMetadataUpdated() { try { mRemoteMediaInformation = mCastManager.getRemoteMediaInformation(); } catch (Exception ignored) { } } @Override public void onFailed(int resourceId, int statusCode) { } @Override public void onConnectionSuspended(int cause) { } @Override public void onConnectivityRecovered() { } }; }
Example #17
Source File: DataCastConsumerImpl.java From android with Apache License 2.0 | 4 votes |
@Override public void onApplicationConnected(ApplicationMetadata appMetadata, String applicationStatus, String sessionId, boolean wasLaunched) { }
Example #18
Source File: VideoCastConsumerImpl.java From android with Apache License 2.0 | 4 votes |
@Override public void onApplicationConnected(ApplicationMetadata appMetadata, String sessionId, boolean wasLaunched) { }
Example #19
Source File: CastSessionImpl.java From AndroidChromium with Apache License 2.0 | 4 votes |
/** * Initializes a new {@link CastSessionImpl} instance. * @param apiClient The Google Play Services client used to create the session. * @param sessionId The session identifier to use with the Cast SDK. * @param origin The origin of the frame requesting the route. * @param tabId The id of the tab containing the frame requesting the route. * @param isIncognito Whether the route is beging requested from an Incognito profile. * @param source The {@link MediaSource} corresponding to this session. * @param routeProvider The {@link CastMediaRouteProvider} instance managing this session. */ public CastSessionImpl( GoogleApiClient apiClient, String sessionId, ApplicationMetadata metadata, String applicationStatus, CastDevice castDevice, String origin, int tabId, boolean isIncognito, MediaSource source, CastMediaRouteProvider routeProvider) { mSessionId = sessionId; mRouteProvider = routeProvider; mApiClient = apiClient; mSource = source; mApplicationMetadata = metadata; mApplicationStatus = applicationStatus; mCastDevice = castDevice; mMessageHandler = mRouteProvider.getMessageHandler(); mMessageChannel = new CastMessagingChannel(this); updateNamespaces(); final Context context = ContextUtils.getApplicationContext(); if (mNamespaces.contains(CastMessageHandler.MEDIA_NAMESPACE)) { mMediaPlayer = new RemoteMediaPlayer(); mMediaPlayer.setOnStatusUpdatedListener( new RemoteMediaPlayer.OnStatusUpdatedListener() { @Override public void onStatusUpdated() { MediaStatus mediaStatus = mMediaPlayer.getMediaStatus(); if (mediaStatus == null) return; int playerState = mediaStatus.getPlayerState(); if (playerState == MediaStatus.PLAYER_STATE_PAUSED || playerState == MediaStatus.PLAYER_STATE_PLAYING) { mNotificationBuilder.setPaused( playerState != MediaStatus.PLAYER_STATE_PLAYING); mNotificationBuilder.setActions(MediaNotificationInfo.ACTION_STOP | MediaNotificationInfo.ACTION_PLAY_PAUSE); } else { mNotificationBuilder.setActions(MediaNotificationInfo.ACTION_STOP); } MediaNotificationManager.show(context, mNotificationBuilder.build()); } }); mMediaPlayer.setOnMetadataUpdatedListener( new RemoteMediaPlayer.OnMetadataUpdatedListener() { @Override public void onMetadataUpdated() { setNotificationMetadata(mNotificationBuilder); MediaNotificationManager.show(context, mNotificationBuilder.build()); } }); } Intent contentIntent = Tab.createBringTabToFrontIntent(tabId); if (contentIntent != null) { contentIntent.putExtra(MediaNotificationUma.INTENT_EXTRA_NAME, MediaNotificationUma.SOURCE_PRESENTATION); } mNotificationBuilder = new MediaNotificationInfo.Builder() .setPaused(false) .setOrigin(origin) // TODO(avayvod): the same session might have more than one tab id. Should we track // the last foreground alive tab and update the notification with it? .setTabId(tabId) .setPrivate(isIncognito) .setActions(MediaNotificationInfo.ACTION_STOP) .setContentIntent(contentIntent) .setIcon(R.drawable.ic_notification_media_route) .setDefaultLargeIcon(R.drawable.cast_playing_square) .setId(R.id.presentation_notification) .setListener(this); setNotificationMetadata(mNotificationBuilder); MediaNotificationManager.show(context, mNotificationBuilder.build()); }
Example #20
Source File: CreateRouteRequest.java From AndroidChromium with Apache License 2.0 | 4 votes |
@Override public void onApplicationMetadataChanged(ApplicationMetadata metadata) { if (mSession == null) return; mSession.updateSessionStatus(); }
Example #21
Source File: CastSessionImpl.java From delion with Apache License 2.0 | 4 votes |
/** * Initializes a new {@link CastSessionImpl} instance. * @param apiClient The Google Play Services client used to create the session. * @param sessionId The session identifier to use with the Cast SDK. * @param origin The origin of the frame requesting the route. * @param tabId The id of the tab containing the frame requesting the route. * @param isIncognito Whether the route is beging requested from an Incognito profile. * @param source The {@link MediaSource} corresponding to this session. * @param routeProvider The {@link CastMediaRouteProvider} instance managing this session. */ public CastSessionImpl( GoogleApiClient apiClient, String sessionId, ApplicationMetadata metadata, String applicationStatus, CastDevice castDevice, String origin, int tabId, boolean isIncognito, MediaSource source, CastMediaRouteProvider routeProvider) { mSessionId = sessionId; mRouteProvider = routeProvider; mApiClient = apiClient; mSource = source; mApplicationMetadata = metadata; mApplicationStatus = applicationStatus; mCastDevice = castDevice; mMessageHandler = mRouteProvider.getMessageHandler(); mMessageChannel = new CastMessagingChannel(this); updateNamespaces(); final Context context = ContextUtils.getApplicationContext(); if (mNamespaces.contains(CastMessageHandler.MEDIA_NAMESPACE)) { mMediaPlayer = new RemoteMediaPlayer(); mMediaPlayer.setOnStatusUpdatedListener( new RemoteMediaPlayer.OnStatusUpdatedListener() { @Override public void onStatusUpdated() { MediaStatus mediaStatus = mMediaPlayer.getMediaStatus(); if (mediaStatus == null) return; int playerState = mediaStatus.getPlayerState(); if (playerState == MediaStatus.PLAYER_STATE_PAUSED || playerState == MediaStatus.PLAYER_STATE_PLAYING) { mNotificationBuilder.setPaused( playerState != MediaStatus.PLAYER_STATE_PLAYING); mNotificationBuilder.setActions(MediaNotificationInfo.ACTION_STOP | MediaNotificationInfo.ACTION_PLAY_PAUSE); } else { mNotificationBuilder.setActions(MediaNotificationInfo.ACTION_STOP); } MediaNotificationManager.show(context, mNotificationBuilder.build()); } }); mMediaPlayer.setOnMetadataUpdatedListener( new RemoteMediaPlayer.OnMetadataUpdatedListener() { @Override public void onMetadataUpdated() { setNotificationMetadata(mNotificationBuilder); MediaNotificationManager.show(context, mNotificationBuilder.build()); } }); } Intent contentIntent = Tab.createBringTabToFrontIntent(tabId); if (contentIntent != null) { contentIntent.putExtra(MediaNotificationUma.INTENT_EXTRA_NAME, MediaNotificationUma.SOURCE_PRESENTATION); } mNotificationBuilder = new MediaNotificationInfo.Builder() .setPaused(false) .setOrigin(origin) // TODO(avayvod): the same session might have more than one tab id. Should we track // the last foreground alive tab and update the notification with it? .setTabId(tabId) .setPrivate(isIncognito) .setActions(MediaNotificationInfo.ACTION_STOP) .setContentIntent(contentIntent) .setIcon(R.drawable.ic_notification_media_route) .setDefaultLargeIcon(R.drawable.cast_playing_square) .setId(R.id.presentation_notification) .setListener(this); setNotificationMetadata(mNotificationBuilder); MediaNotificationManager.show(context, mNotificationBuilder.build()); }
Example #22
Source File: IVideoCastConsumer.java From android with Apache License 2.0 | 2 votes |
/** * Called when the application is successfully launched or joined. Upon successful connection, a * session ID is returned. <code>wasLaunched</code> indicates if the application was launched or * joined. * * @param appMetadata * @param sessionId * @param wasLaunched */ public void onApplicationConnected(ApplicationMetadata appMetadata, String sessionId, boolean wasLaunched);
Example #23
Source File: IDataCastConsumer.java From android with Apache License 2.0 | 2 votes |
/** * Called when the application is successfully launched or joined. Upon successful connection, a * session ID is returned. <code>wasLaunched</code> indicates if the application was launched or * joined. * * @param appMetadata * @param applicationStatus * @param sessionId * @param wasLaunched */ public void onApplicationConnected(ApplicationMetadata appMetadata, String applicationStatus, String sessionId, boolean wasLaunched);
Example #24
Source File: BaseCastManager.java From android with Apache License 2.0 | 2 votes |
/** * Subclasses should implement this to react appropriately to the successful launch of their * application. This is called when the application is successfully launched. * * @param applicationMetadata * @param applicationStatus * @param sessionId * @param wasLaunched */ abstract void onApplicationConnected(ApplicationMetadata applicationMetadata, String applicationStatus, String sessionId, boolean wasLaunched);
Example #25
Source File: BaseCastManager.java From UTubeTV with The Unlicense | 2 votes |
/** * Subclasses should implement this to react appropriately to the successful launch of their * application. This is called when the application is successfully launched. */ abstract void onApplicationConnected(ApplicationMetadata applicationMetadata, String applicationStatus, String sessionId, boolean wasLaunched);
Example #26
Source File: IDataCastConsumer.java From UTubeTV with The Unlicense | 2 votes |
/** * Called when the application is successfully launched or joined. Upon successful connection, a * session ID is returned. <code>wasLaunched</code> indicates if the application was launched or * joined. * * @param appMetadata * @param applicationStatus * @param sessionId * @param wasLaunched */ public void onApplicationConnected(ApplicationMetadata appMetadata, String applicationStatus, String sessionId, boolean wasLaunched);
Example #27
Source File: IVideoCastConsumer.java From UTubeTV with The Unlicense | 2 votes |
/** * Called when the application is successfully launched or joined. Upon successful connection, a * session ID is returned. <code>wasLaunched</code> indicates if the application was launched or * joined. */ public void onApplicationConnected(ApplicationMetadata appMetadata, String sessionId, boolean wasLaunched);