MediaSource

Information and playback settings for the media file to be played.

public class MediaSource : OptionalJsonParse
    {
        public string url { set; get; }
        public string uri { set; get; }
        public int64_t startPos { set; get; }
        public bool autoPlay { set; get; }
        public bool enableCache { set; get; }
        public Optional<bool> isAgoraSource = new Optional<bool>();
        public Optional<bool> isLiveSource = new Optional<bool>();
        public IMediaPlayerCustomDataProvider provider { set; get; }

        public MediaSource()
        {
            url = "";
            uri = "";
            startPos = 0;
            autoPlay = true;
            enableCache = false;
            provider = null;
        }
    }

Properties

url
URL of the media resource to be played.
Note: If you are opening a regular media resource, assign a value to url; if you are opening a custom media resource, assign a value to provider. Assigning values to both will cause the method call to fail.
uri
URI (Uniform Resource Identifier) of the media file, used to identify the media file.
startPos
Start playback position in milliseconds. Default is 0.
autoPlay
Note: If you disable auto-play, call the Play method after opening the media file to start playback.
Whether to enable auto-play after opening the media file:
  • true: (Default) Enable auto-play.
  • false: Disable auto-play.
enableCache
Note:
  • The SDK currently supports caching for on-demand streams, but not for on-demand streams delivered via HLS protocol.
  • Before caching, assign a value to uri, otherwise the player will use the media file's url as the cache index.
  • When real-time caching is enabled, the player preloads part of the currently playing media file to local storage. The next time you play the file, the player loads data directly from the cache, saving network traffic. Statistics for the cached media file are updated every second after playback starts. See CacheStatistics.
Whether to enable real-time caching for this playback:
  • true: Enable real-time caching.
  • false: (Default) Disable real-time caching.
enableMultiAudioTrack
Whether to allow selecting different audio tracks for this playback:
  • true: Allow selecting different audio tracks.
  • false: (Default) Do not allow selecting different audio tracks.
If you need to set different audio tracks for local playback and publishing to remote, set this parameter to true and then call the SelectMultiAudioTrack method to configure audio tracks.
isAgoraSource
Note: If the media resource to be opened is a live or on-demand stream delivered via Agora Fusion CDN, assign the stream URL to url and set isAgoraSource to true. Otherwise, there is no need to set isAgoraSource.
Whether the media resource is a live or on-demand stream delivered via Agora Fusion CDN:
  • true: The media resource is delivered via Agora Fusion CDN.
  • false: (Default) The media resource is not delivered via Agora Fusion CDN.
isLiveSource
Note: Only when the media resource is a live stream, setting isLiveSource to true can speed up the opening of the media resource.
Whether the media resource is a live stream:
  • true: Live stream.
  • false: (Default) Not a live stream.
If the media resource is a live stream, it is recommended to set this parameter to true to speed up the opening of the live stream.
provider
Callback for custom media resource files. See IMediaPlayerCustomDataProvider.
Note: If you are opening a custom media resource, assign a value to provider only. If you are opening a regular media resource, assign a value to url. Assigning values to both url and provider will cause the method call to fail.