MediaSource
Information and playback settings for the media file to be played.
class MediaSource {
const MediaSource(
{this.url,
this.uri,
this.startPos,
this.autoPlay,
this.enableCache,
this.isAgoraSource,
this.isLiveSource});
@JsonKey(name: 'url')
final String? url;
@JsonKey(name: 'uri')
final String? uri;
@JsonKey(name: 'startPos')
final int? startPos;
@JsonKey(name: 'autoPlay')
final bool? autoPlay;
@JsonKey(name: 'enableCache')
final bool? enableCache;
@JsonKey(name: 'isAgoraSource')
final bool? isAgoraSource;
@JsonKey(name: 'isLiveSource')
final bool? isLiveSource;
factory MediaSource.fromJson(Map<String, dynamic> json) =>
_$MediaSourceFromJson(json);
Map<String, dynamic> toJson() => _$MediaSourceToJson(this);
}
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 autoplay, call the play method to play the media file after opening it.Whether to enable autoplay after opening the media file:
- true: (default) Enable autoplay.
- false: Disable autoplay.
- 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 protocol.
- Before caching, assign a value to
uri, otherwise the player uses the media file'surlas the cache index. - After enabling real-time caching, the player pre-caches part of the currently playing media file locally. When you play the file again, the player loads data from the cache, saving network traffic. The statistics of the currently 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 for 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 opened media resource 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 a live or on-demand stream distributed via Agora Fusion CDN.
- false: (default) The media resource is not distributed via Agora Fusion 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 opening the media resource.- true: Live stream.
- false: (default) Not a live stream.