Set up the MediaPlayer

The MediaPlayer interface for Android encapsulates the functionality and behavior of a media player.

The PSDK library provides a single implementation of the MediaPlayer interface: the DefaultMediaPlayer class. When you need video-playback functionality, instantiate DefaultMediaPlayer.

Note: Interact with the DefaultMediaPlayer instance only with the methods exposed by the MediaPlayer interface.
  1. Instantiate a MediaPlayer using the public DefaultMediaPlayer.create factory method, passing a Java Android application context object:
    public static MediaPlayer create(Context context)
    
  2. Call MediaPlayer.getView to get a reference to the MediaPlayerView instance:
    MediaPlayerView getView() throws IllegalStateException;
    
  3. Place the MediaPlayerView instance inside a FrameLayout instance, effectively placing the video on the device's screen:
    FrameLayout playerFrame = (FrameLayout) view.findViewById(R.id.playerFrame);
    playerFrame.addView(mediaPlayer.getView());
    
The MediaPlayer instance is now available and properly configured to display video content on the device screen.