The MediaResource class represents the content that is about to be loaded by the MediaPlayer class.
| Parameter | Description |
|---|---|
| URL | Required. The location of the manifest/playlist for the content to be loaded. |
| Metadata | Required when using the MediaResource with the createFromUrl method. Otherwise, pass null. An instance of the Metadata class (a dictionary-like structure). This structure might contain additional information about the content that is about to be loaded, such as information about alternate or ad content to place inside the main content. |
try {
// create a MediaResource instance pointing to some HLS content
Metadata metadata = //TODO: create metadata
MediaResource mediaResource =
MediaResource.createFromUrl("http://www.example.com/video/some-video.m3u8", metadata);
} catch(IllegalArgumentException ex) {
// this exception is thrown if the URL does not point to a valid url.
}
| Method | Returns |
|---|---|
| getType | The type of the content to be loaded. Usually you can detect the type of the resource from the URL, but sometimes when custom naming schemes are involved, this is not possible. This is a simple enumeration, MediaResource.Type, which defines the types of content that can be loaded by the MediaPlayer. This enumeration defines two values: HLS and HDS. Each value is associated with the string representing the file extensions commonly used: "m3u8" for HLS and "f4m" for HDS, respectively. |
| getUrl | The URL of the location of the manifest/playlist for the content to be loaded. |
| getMetadata | An instance of the Metadata class (a dictionary-like structure). This structure contains additional optional information about the content that is about to be loaded. |
Load it directly inside the MediaPlayer
Load it using MediaPlayerItemLoader