Agora RTC Objective-C API Reference Refactor

Data Fields
MediaSource Struct Reference

## Data Fields
const char * | url
const char * | uri
int64_t | startPos
bool | autoPlay
bool | enableCache
bool | enableMultiAudioTrack
Optional< bool > | isAgoraSource
Optional< bool > | isLiveSource
IMediaPlayerCustomDataProvider * | provider

## Constructor & Destructor Documentation

## ◆ MediaSource()

MediaSource | ( |  | ) |
| inline

## Field Documentation

## ◆ url

const char* url

The URL of the media file to be played.

Note
  If you open a common media resource, pass in the value to `url`. If you open a custom media resource, pass in the value to `provider`. Agora recommends that you do not pass in values to both parameters in one call; otherwise, this call may fail.

## ◆ uri

const char* uri

The URI (Uniform Resource Identifier) of the media file.

## ◆ startPos

int64_t startPos

The starting position (ms) for playback. The default value is 0.

## ◆ autoPlay

bool autoPlay

Whether to enable autoplay once the media file is opened:

- `true`: (Default) Yes.
- `false`: No.
  Note
    If autoplay is disabled, you need to call the `play` method to play a media file after it is opened.

## ◆ enableCache

bool enableCache

Whether to cache the media file when it is being played:

- `true`:Enables caching.
- `false`: (Default) Disables caching.
  Note
- Agora only supports caching on-demand audio and video streams that are not transmitted in HLS protocol.
- If you need to enable caching, pass in a value to `uri`; otherwise, caching is based on the `url` of the media file.
- If you enable this function, the Media Player caches part of the media file being played on your local device, and you can play the cached media file without internet connection. The statistics about the media file being cached are updated every second after the media file is played. See `CacheStatistics`.

## ◆ enableMultiAudioTrack

bool enableMultiAudioTrack

Whether to allow the selection of different audio tracks when playing this media file:

- `true`: Allow to select different audio tracks.
- `false`: (Default) Do not allow to select different audio tracks. If you need to set different audio tracks for local playback and publishing to the channel, you need to set this parameter to `true`, and then call the `selectMultiAudioTrack` method to select the audio track.

## ◆ isAgoraSource

Optional<bool> isAgoraSource

Whether the media resource to be opened is a live stream or on-demand video distributed through Media Broadcast service:

- `true`: The media resource to be played is a live or on-demand video distributed through Media Broadcast service.
- `false`: (Default) The media resource is not a live stream or on-demand video distributed through Media Broadcast service.
  Note
    If you need to open a live stream or on-demand video distributed through Broadcast Streaming service, pass in the URL of the media resource to `url`, and set `isAgoraSource` as `true`; otherwise, you don't need to set the `isAgoraSource` parameter.

## ◆ isLiveSource

Optional<bool> isLiveSource

Whether the media resource to be opened is a live stream:

- `true`: The media resource is a live stream.
- `false`: (Default) The media resource is not a live stream. If the media resource you want to open is a live stream, Agora recommends that you set this parameter as `true` so that the live stream can be loaded more quickly.
  Note
    If the media resource you open is not a live stream, but you set `isLiveSource` as `true`, the media resource is not to be loaded more quickly.

## ◆ provider

IMediaPlayerCustomDataProvider* provider

The callback for custom media resource files. See `IMediaPlayerCustomDataProvider`.

Note
  If you open a custom media resource, pass in the value to `provider`. If you open a common media resource, pass in the value to `url`. Agora recommends that you do not pass in values to both `url` and `provider` in one call; otherwise, this call may fail.