MediaSource
Information and playback settings of the media file to be played.
export class MediaSource {
url?: string;
uri?: string;
startPos?: number;
autoPlay?: boolean;
enableCache?: boolean;
isAgoraSource?: boolean;
isLiveSource?: boolean;
}
Properties
- url
- URL of the media resource to be played.
- 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:Whether to enable real-time caching for this playback:
- The SDK currently supports caching for on-demand streams, but not for on-demand streams transmitted via HLS protocol.
- Before caching, pass a value to
uri, otherwise the player uses the media file'surlas the cache index. - When real-time caching is enabled, the player pre-caches part of the media file being played to local storage. The next time you play the file, the player loads data from the cache, saving network traffic. The statistics of the cached media file are updated every second after playback starts. See CacheStatistics.
- true: Enable real-time caching.
- false: (default) Disable real-time caching.
- enableMultiAudioTrack
- Whether to allow selecting different audio tracks during this playback:
- true: Allow selecting different audio tracks.
- false: (default) Do not allow selecting different audio tracks.
- isAgoraSource
-
Note: If the media resource to be opened is a live or on-demand stream distributed via Agora Fusion CDN, pass the stream URL toWhether the media resource opened is a live or on-demand stream distributed via Agora Fusion CDN:
urland setisAgoraSourceto true. Otherwise, you do not need to setisAgoraSource.- true: The media resource is distributed via Agora Fusion CDN.
- false: (default) The media resource is not distributed via Agora Fusion CDN.
- isLiveSource
-
Note:Whether the media resource opened is a live stream:
isLiveSourceshould be set to true only when the media resource is a live stream to accelerate the opening speed.- true: Live stream.
- false: (default) Not a live stream.