MediaPlayerSource
Used to configure the media file to be played and the playback scenario.
public class MediaPlayerSource {
String url;
String uri;
long startPos;
boolean autoPlay;
boolean enableCache;
boolean enableMultiAudioTrack;
Boolean isAgoraSource;
Boolean isLiveSource;
IMediaPlayerCustomDataProvider provider;
}
Properties
- url
- The URL of the media file to be played.
Note: If opening a regular media resource, pass in the value of
url; if opening a custom media resource, pass in the value ofprovider. Agora recommends not passing values for both parameters in a single call, as it may cause the call to fail. - uri
- The URI (Uniform Resource Identifier) of the media file.
- startPos
- The position (in milliseconds) from which to start playback. Default is 0.
- autoPlay
-
Note: If auto play is disabled, you need to manually call the play method after opening the media file.Whether to automatically play the media file after it is opened:
- true: (default) Automatically plays.
- false: Does not automatically play.
- enableCache
-
Note: Agora only supports caching on-demand audio and video streams that are not transmitted via the HLS protocol. To enable caching, assign a value toWhether to cache the media file during playback:
uri; otherwise, caching is based onurlby default. When this feature is enabled, the Media Player caches the portion of the audio and video file being played to the local device, allowing playback without a network connection. Cache statistics are updated once per second after playback starts. See CacheStatistics for details.- true: Enable caching.
- false: (default) Disable caching.
- enableMultiAudioTrack
-
Note: If you need to set different audio tracks for local playback and publishing to the channel, set this parameter to true, and then call the selectMultiAudioTrack method to select the audio track.Whether to allow selecting different audio tracks when playing media resources:
- true: Allows selecting different audio tracks.
- false: (default) Does not allow selecting different audio tracks.
- isAgoraSource
-
Note: If you need to play a live or on-demand video distributed via the Ultra Low Latency Live service, pass the media resource's URL toWhether the media resource is a live or on-demand video distributed via the Media Broadcast service:
url, and setisAgoraSourceto true; otherwise, you do not need to set this parameter.- true: Yes.
- false: (default) No.
- isLiveSource
-
Note: If opening a live stream, Agora recommends setting this parameter to true to enable faster loading of the live stream. If the media resource is not a live stream butWhether the media resource is a live stream:
isLiveSource=trueis set, it will not improve loading speed.- true: It is a live stream.
- false: (default) It is not a live stream.
- provider
- Callback for providing data of custom media resource files. See IMediaPlayerCustomDataProvider.
Note: If opening a custom media resource, pass in the value of
provider; if opening a regular media resource, pass in the value ofurl. Agora recommends not passing values for bothurlandproviderin a single call, as it may cause the call to fail.