Example usage for android.app Activity getMediaController

List of usage examples for android.app Activity getMediaController

Introduction

In this page you can find the example usage for android.app Activity getMediaController.

Prototype

public final MediaController getMediaController() 

Source Link

Document

Gets the controller which should be receiving media key and volume events while this activity is in the foreground.

Usage

From source file:com.example.android.tvleanback2.ui.PlaybackOverlayFragment.java

@Override
public void onAttach(Context context) {
    super.onAttach(context);

    Activity activity = (Activity) context;
    mMediaController = activity.getMediaController();
    Log.d(TAG, "register callback of mediaController");
    mMediaController.registerCallback(mMediaControllerCallback);
}

From source file:com.aengbee.android.leanback.ui.PlaybackOverlayCustomFragment.java

private int getPlaybackState() {
    Activity activity = getActivity();

    if (activity != null) {
        PlaybackState state = activity.getMediaController().getPlaybackState();
        if (state != null) {
            return state.getState();
        } else {/*ww w  .  jav a2  s . c o  m*/
            return PlaybackState.STATE_NONE;
        }
    }
    return PlaybackState.STATE_NONE;
}

From source file:org.mythtv.android.presentation.view.fragment.TvPlaybackOverlayFragment.java

private int getPlaybackState() {

    Activity activity = getActivity();

    if (activity != null) {

        PlaybackState state = activity.getMediaController().getPlaybackState();
        if (state != null) {

            return state.getState();
        } else {/*ww w.  java  2s . c om*/

            return PlaybackState.STATE_NONE;
        }
    }

    return PlaybackState.STATE_NONE;
}