Example usage for android.media MediaPlayer setSurface

List of usage examples for android.media MediaPlayer setSurface

Introduction

In this page you can find the example usage for android.media MediaPlayer setSurface.

Prototype

public void setSurface(Surface surface) 

Source Link

Document

Sets the Surface to be used as the sink for the video portion of the media.

Usage

From source file:nuclei.media.playback.FallbackPlayback.java

/**
 * Called when media player is done preparing.
 *
 * @see OnPreparedListener//from   w  ww.  j  a  va2 s .  com
 */
@Override
public void onPrepared(MediaPlayer player) {
    mPrepared = true;
    // The media player is done preparing. That means we can start playing if we
    // have audio focus.
    if (mSurface != null && mSurface.isValid())
        player.setSurface(mSurface);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        if (mPlaybackParams != null)
            player.setPlaybackParams(mPlaybackParams);
    }

    if (mMediaPlayer != null && mMetadata != null
            && mMetadata.getLong(MediaMetadataCompat.METADATA_KEY_DURATION) != mMediaPlayer.getDuration()) {
        mMetadata.setDuration(getDuration());
        if (mCallback != null)
            mCallback.onMetadataChanged(mMetadata);
    }

    configMediaPlayerState();
}