The MediaPlayer interface for Android encapsulates the functionality and behavior of a media player.
TVSDK provides one implementation of the MediaPlayer
interface, the DefaultMediaPlayer
class. When you need video playback functionality, instantiate DefaultMediaPlayer
.
Interact with the DefaultMediaPlayer
instance only with the methods that are exposed by the MediaPlayer
interface.
Instantiate a MediaPlayer using the public DefaultMediaPlayer.create
factory method, passing a Java Android application context object.
public static MediaPlayer create(Context context)
Call MediaPlayer.getView
to get a reference to the MediaPlayerView
instance.
MediaPlayerView getView() throws IllegalStateException;
Place the MediaPlayerView
instance in a FrameLayout
instance, which places 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.