Java Code Examples for com.google.android.gms.cast.framework.media.RemoteMediaClient#getIdleReason()
The following examples show how to use
com.google.android.gms.cast.framework.media.RemoteMediaClient#getIdleReason() .
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: GoogleCastDelegate.java From edx-app-android with Apache License 2.0 | 5 votes |
public void loadRemoteMedia(@NonNull Activity activity, @NonNull DownloadEntry videoEntry, long position, boolean autoPlay) { if (castSession == null || !castSession.isConnected()) { return; } final String videoUrl = videoEntry.getBestEncodingUrl(activity); final RemoteMediaClient remoteMediaClient = castSession.getRemoteMediaClient(); // If remote media player is not idle and playing the same video, don't do anything if (remoteMediaClient == null || (remoteMediaClient.getIdleReason() != MediaStatus.IDLE_REASON_FINISHED && remoteMediaClient.getMediaInfo() != null && remoteMediaClient.getMediaInfo().getContentId().equals(videoUrl))) { return; } // open expanded controls when start the video casting. remoteMediaClient.registerCallback(new RemoteMediaClient.Callback() { @Override public void onStatusUpdated() { final Intent intent = new Intent(activity, ExpandedControlsActivity.class); activity.startActivity(intent); remoteMediaClient.unregisterCallback(this); // Track video is casted on casting device. double currentTime = position / AppConstants.MILLISECONDS_PER_SECOND; analyticsRegistry.trackVideoPlaying(videoEntry.videoId, currentTime, videoEntry.eid, videoEntry.lmsUrl, Analytics.Values.GOOGLE_CAST); } }); // load video media on remote client / media player. remoteMediaClient.load(buildMediaInfo(videoEntry, videoUrl), new MediaLoadOptions.Builder() .setAutoplay(autoPlay) .setPlayPosition(position).build()); }
Example 2
Source File: GoogleCastDelegate.java From edx-app-android with Apache License 2.0 | 5 votes |
@Override public void onStatusUpdated() { super.onStatusUpdated(); if (sessionListener != null && castSession != null) { final RemoteMediaClient remoteMediaPlayer = castSession.getRemoteMediaClient(); if (remoteMediaPlayer != null) { if (remoteMediaPlayer.getPlayerState() == MediaStatus.PLAYER_STATE_IDLE && remoteMediaPlayer.getIdleReason() == MediaStatus.IDLE_REASON_FINISHED) { sessionListener.onVideoComplete(); } else if (remoteMediaPlayer.getPlayerState() == MediaStatus.PLAYER_STATE_PLAYING) { sessionListener.onVideoPlaying(); } } } }