Create a media resource
For each new video content, initialize a MediaResource instance with information about the video content and load the media resource.
The MediaResource class represents the content to be loaded by the MediaPlayer instance.
- Create a MediaResource by passing information about the media to the MediaResource constructor.The MediaResource constructor requires the following parameters:
Constructor Parameter Description url A string representing the URL of the manifest/playlist of the media. type One of the following members of the MediaResource.Type enum, corresponding to the indicated file type:
- HLS - M3U8
- ISOBMFF - ISO base media file format (MP4)
- DASH - MPEG-DASH media presentation description (MPD)
metadata An instance of the Metadata class (a dictionary-like structure), which might contain additional information about the content that is about to be loaded, such as alternate or ad content to place inside the main content. If using advertising, set up AuditudeSettings before using this constructor (see href=Ad insertion metadata](../../android-3.5-advertising/ad-insertion/ad-insertion-metadata/android-3.5-ad-insertion-metadata.md).TVSDK supports playback for only specific types of content. If you attempt to load any other type of content, TVSDK dispatches an error event.For MP4 video-on-demand (VOD) content, TVSDK does not support trick play, adaptive bit rate (ABR) streaming, ad insertion, closed captions, or DRM.The following code creates a MediaResource instance: >
// To do: Create metadata here MediaResource res = new MediaResource( "https://www.example.com/video/some-video.m3u8", MediaResource.Type.HLS, metadata);At any time after this step, you can use MediaResource accessors (getters) to examine the resource's type, URL, and metadata.
- Load the media resource using one of the following options:
Do not load the media resource on a background thread. Most TVSDK operations need to run on the main thread, and running them on a background thread can cause the operation to throw an error and exit.
- The MediaPlayer instance.
- MediaPlayerItemLoader For more information, see Load a media resource using MediaPlayerItemLoader .