Summary: Constants | Ctors | Methods | Protected Methods | Inherited Methods | [Expand All]
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
final void | abortBroadcast()
final void | clearAbortBroadcast()
final boolean | getAbortBroadcast()
final boolean | getDebugUnregister()
final int | getResultCode()
final String | getResultData()
final Bundle | getResultExtras(boolean arg0)
final BroadcastReceiver.PendingResult | goAsync()
final boolean | isInitialStickyBroadcast()
final boolean | isOrderedBroadcast()
abstract void | onReceive(Context arg0, Intent arg1)
IBinder | peekService(Context arg0, Intent arg1)
final void | setDebugUnregister(boolean arg0)
final void | setOrderedHint(boolean arg0)
final void | setResult(int arg0, String arg1, Bundle arg2)
final void | setResultCode(int arg0)
final void | setResultData(String arg0)
final void | setResultExtras(Bundle arg0)
From class java.lang.Object
Object | clone()
boolean | equals(Object arg0)
void | finalize()
final Class<?> | getClass()
int | hashCode()
final void | notify()
final void | notifyAll()
String | toString()
final void | wait(long arg0, int arg1)
final void | wait(long arg0)
final void | wait()

## 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)

## 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 | The current `Session`.
forwardStepMs | 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 | The current `Session`.
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 | The current `Session`.
rewindStepMs | 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 | 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 | 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 | 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 | The action.
intent | The Intent of this action.