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.

  1. Create a MediaResource by passing information about the media to the MediaResource constructor.

    Constructor Parameter Description

    url

    A string that represents the URL of the manifest/playlist of the media.

    type

    One of the following members of the MediaResource.Type enumeration that corresponds to the indicated file type:

    • HLS - M3U8

    metadata

    An instance of the Metadata class, which might contain custom information about the content to be loaded.

    Examples of content are alternate or ad content to place inside the main content. If using advertising, set up AuditudeSettings . For more information, see Ad Insertion Metadata .

    IMPORTANT

    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:

    try { 
        // create a MediaResource instance pointing to some HLS content 
        Metadata metadata = //TODO: create metadata  
        MediaResource mediaResource = MediaResource.createFromUrl( 
          "https://www.example.com/video/some-video.m3u8",  
          MediaResource.Type.HLS,  
          metadata); 
    } catch(IllegalArgumentException ex) { 
        // this exception is thrown if the URL does not point  
        // to a valid url. 
    } 
    
    
    TIP

    At this point, you can use MediaResource accessors (getters) to examine the resource’s type, URL, and metadata.

  2. Load the media resource by using the following:

    IMPORTANT

    Do not load the media resource on a background thread. Most TVSDK operations need to be run on the main thread, and running them on a background thread can cause the operation to throw an error and exit.

On this page

Adobe Summit Banner

A virtual event April 27-28.

Expand your skills and get inspired.

Register for free
Adobe Summit Banner

A virtual event April 27-28.

Expand your skills and get inspired.

Register for free
Adobe Maker Awards Banner

Time to shine!

Apply now for the 2021 Adobe Experience Maker Awards.

Apply now
Adobe Maker Awards Banner

Time to shine!

Apply now for the 2021 Adobe Experience Maker Awards.

Apply now