public class

MediaIntentReceiver

extends BroadcastReceiver
java.lang.Object
   ↳ android.content.BroadcastReceiver
     ↳ com.google.android.gms.cast.framework.media.MediaIntentReceiver

Class Overview

A BroadcastReceiver for receiving media button actions from the status bar notification, the lock screen, and the cast dialog.

MediaIntentReceiver can be subclassed to handle custom actions, or override the default behaviours when handling pre-defined actions. In that case, set the name of the subclass when building CastMediaOptions by calling setMediaIntentReceiverClassName(String), and declare the subclass in your manifest.

Summary

Constants
String ACTION_DISCONNECT The action for ending the current session and disconnecting from the receiver app.
String ACTION_FORWARD The action for forwarding the current item.
String ACTION_REWIND The action for rewinding the current item.
String ACTION_SKIP_NEXT The action for skipping to the next item in the queue.
String ACTION_SKIP_PREV The action for skipping to the previous item in the queue.
String ACTION_STOP_CASTING The action for ending the current session and stopping the receiver app.
String ACTION_TOGGLE_PLAYBACK The action for toggling remote media playback.
String EXTRA_SKIP_STEP_MS The extra key for specifying how much the currently playing item should be forwarded or rewinded to handle ACTION_FORWARD and ACTION_REWIND.
Public Constructors
MediaIntentReceiver()
Public Methods
void onReceive(Context context, Intent intent)
Protected Methods
void onReceiveActionForward(Session currentSession, long forwardStepMs)
Called when ACTION_FORWARD is received.
void onReceiveActionMediaButton(Session currentSession, Intent intent)
Called when ACTION_MEDIA_BUTTON is received.
void onReceiveActionRewind(Session currentSession, long rewindStepMs)
Called when ACTION_REWIND is received.
void onReceiveActionSkipNext(Session currentSession)
Called when ACTION_SKIP_NEXT is received.
void onReceiveActionSkipPrev(Session currentSession)
Called when ACTION_SKIP_PREV is received.
void onReceiveActionTogglePlayback(Session currentSession)
Called when ACTION_TOGGLE_PLAYBACK is received.
void onReceiveOtherAction(String action, Intent intent)
Called when other type of actions are received.
[Expand]
Inherited Methods
From class android.content.BroadcastReceiver
From class java.lang.Object

Constants

public static final String ACTION_DISCONNECT

The action for ending the current session and disconnecting from the receiver app.

Constant Value: "com.google.android.gms.cast.framework.action.DISCONNECT"

public static final String ACTION_FORWARD

The action for forwarding the current item. When building an Intent with this action, use EXTRA_SKIP_STEP_MS to set the time to forward in milliseconds.

Constant Value: "com.google.android.gms.cast.framework.action.FORWARD"

public static final String ACTION_REWIND

The action for rewinding the current item. When building an Intent with this action, use EXTRA_SKIP_STEP_MS to set the time to rewind in milliseconds.

Constant Value: "com.google.android.gms.cast.framework.action.REWIND"

public static final String ACTION_SKIP_NEXT

The action for skipping to the next item in the queue.

Constant Value: "com.google.android.gms.cast.framework.action.SKIP_NEXT"

public static final String ACTION_SKIP_PREV

The action for skipping to the previous item in the queue.

Constant Value: "com.google.android.gms.cast.framework.action.SKIP_PREV"

public static final String ACTION_STOP_CASTING

The action for ending the current session and stopping the receiver app.

Constant Value: "com.google.android.gms.cast.framework.action.STOP_CASTING"

public static final String ACTION_TOGGLE_PLAYBACK

The action for toggling remote media playback.

Constant Value: "com.google.android.gms.cast.framework.action.TOGGLE_PLAYBACK"

public static final String EXTRA_SKIP_STEP_MS

The extra key for specifying how much the currently playing item should be forwarded or rewinded to handle ACTION_FORWARD and ACTION_REWIND.

Constant Value: "googlecast-extra_skip_step_ms"

Public Constructors

public MediaIntentReceiver ()

Public Methods

public void onReceive (Context context, Intent intent)

Parameters
context Context
intent Intent

Protected Methods

protected void onReceiveActionForward (Session currentSession, long forwardStepMs)

Called when ACTION_FORWARD is received. The default implementation forwards the current playing item by forwardStepMs if currentSession is a CastSession. Subclass can override this method to change the behavior or handle other type of Session. Subclass should call through to super to let the SDK handle the action if currentSession is a CastSession

Parameters
currentSession Session: The current Session.
forwardStepMs long: Time to forward in milliseconds.

protected void onReceiveActionMediaButton (Session currentSession, Intent intent)

Called when ACTION_MEDIA_BUTTON is received. The default implementation toggles playback state if currentSession is a CastSession. Subclass can override this method to change the behavior or handle other type of Session. Subclass should call through to super to let the SDK handle the action if currentSession is a CastSession

Parameters
currentSession Session: The current Session.
intent Intent: The Intent of this action.

protected void onReceiveActionRewind (Session currentSession, long rewindStepMs)

Called when ACTION_REWIND is received. The default implementation rewinds the current playing item by rewindStepMs if currentSession is a CastSession. Subclass can override this method to change the behavior or handle other type of Session. Subclass should call through to super to let the SDK handle the action if currentSession is a CastSession

Parameters
currentSession Session: The current Session.
rewindStepMs long: Time to forward in milliseconds.

protected void onReceiveActionSkipNext (Session currentSession)

Called when ACTION_SKIP_NEXT is received. The default implementation plays the next item in the queue if currentSession is a CastSession and there is a next item. Subclass can override this method to change the behavior or handle other type of Session. Subclass should call through to super to let the SDK handle the action if currentSession is a CastSession

Parameters
currentSession Session: The current Session.

protected void onReceiveActionSkipPrev (Session currentSession)

Called when ACTION_SKIP_PREV is received. The default implementation plays the previous item in the queue if currentSession is a CastSession and there is a previous item. Subclass can override this method to change the behavior or handle other type of Session. Subclass should call through to super to let the SDK handle the action if currentSession is a CastSession

Parameters
currentSession Session: The current Session.

protected void onReceiveActionTogglePlayback (Session currentSession)

Called when ACTION_TOGGLE_PLAYBACK is received. The default implementation toggles playback state if currentSession is a CastSession. Subclass can override this method to change the behavior or handle other type of Session. Subclass should call through to super to let the SDK handle the action if currentSession is a CastSession

Parameters
currentSession Session: The current Session.

protected void onReceiveOtherAction (String action, Intent intent)

Called when other type of actions are received. The default implementation does nothing.

Parameters
action String: The action.
intent Intent: The Intent of this action.