MediaSource
Information and playback settings for 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 only supports caching for on-demand streams, not for on-demand streams transmitted via HLS.
- Set a value for
uribefore enabling caching; otherwise, the player uses the media file'surlas the cache index. - When real-time caching is enabled, the player preloads part of the media file to local storage. When you play the file again, the player loads data from the cache to save bandwidth. The statistics of the cached media file update 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 for this playback:
- true: Allow selecting different audio tracks.
- false: (Default) Do not allow selecting different audio tracks.
- isAgoraSource
-
Note: If the media resource you want to open is a live or on-demand stream distributed via Agora's CDN, pass the stream URL toWhether the opened media resource is a live or on-demand stream distributed via Agora's CDN:
urland setisAgoraSourceto true. Otherwise, you do not need to setisAgoraSource.- true: The media resource is distributed via Agora's CDN.
- false: (Default) The media resource is not distributed via Agora's CDN.
- isLiveSource
-
Note: Only when the media resource is a live stream, settingWhether the opened media resource is a live stream:
isLiveSourceto true can speed up the opening of the media resource.- true: Live stream.
- false: (Default) Not a live stream.