Agora RTC Objective-C API Reference Refactor

Properties
AgoraMediaSource Class Reference

Inherits <NSObject>.

## Properties
NSString *_Nullable | url
NSString *_Nullable | uri
NSUInteger | startPos
BOOL | autoPlay
BOOL | enableCache
BOOL | enableMultiAudioTrack
BOOL | isAgoraSource
BOOL | isLiveSource
AgoraRtcMediaPlayerCustomSourceOnReadCallback _Nonnull | playerOnReadCallback
AgoraRtcMediaPlayerCustomSourceOnSeekCallback _Nonnull | playerOnSeekCallback

## Property Documentation

## ◆ url

- (NSString* _Nullable) url
| read write nonatomic copy

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 `playerOnReadCallback` and `playerOnSeekCallback`. Agora recommends that you do not pass in values to all these parameters in one call; otherwise, this call may fail.

## ◆ uri

- (NSString* _Nullable) uri
| read write nonatomic copy

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

## ◆ startPos

- (NSUInteger) startPos
| read write nonatomic assign

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

## ◆ autoPlay

- (BOOL) autoPlay
| read write nonatomic assign

Whether to enable autoplay once the media file is opened:

- `YES`: (Default) Yes.
- `NO`: 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
| read write nonatomic assign

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

- `YES`: Enables caching.
- `NO`: (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 `AgoraMediaPlayerCacheStatistics`.

## ◆ enableMultiAudioTrack

- (BOOL) enableMultiAudioTrack
| read write nonatomic assign

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

- `YES`: Allow to select different audio tracks.
- `NO`: (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 `YES`, and then call the `selectMultiAudioTrack:publishTrackIndex:` method to select the audio track.

## ◆ isAgoraSource

- (BOOL) isAgoraSource
| read write nonatomic assign

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

- `YES`: The media resource to be played is a live or on-demand video distributed through Media Broadcast service.
- `NO`: (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 `YES`; otherwise, you don't need to set the `isAgoraSource` parameter.

## ◆ isLiveSource

- (BOOL) isLiveSource
| read write nonatomic assign

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

- `YES`: The media resource is a live stream.
- `NO`: (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 `YES` 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 `YES`, the media resource is not to be loaded more quickly.

## ◆ playerOnReadCallback

- (AgoraRtcMediaPlayerCustomSourceOnReadCallback _Nonnull) playerOnReadCallback
| read write nonatomic copy

Occurs when the SDK reads the media resource data. See `AgoraRtcMediaPlayerCustomSourceOnReadCallback`.

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 `playerOnReadCallback` and `playerOnSeekCallback`. Agora recommends that you do not pass in values to all these parameters in one call; otherwise, this call may fail.

## ◆ playerOnSeekCallback

- (AgoraRtcMediaPlayerCustomSourceOnSeekCallback _Nonnull) playerOnSeekCallback
| read write nonatomic copy

Occurs when the SDK seeks the media resource data. See `AgoraRtcMediaPlayerCustomSourceOnSeekCallback`.

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 `playerOnReadCallback` and `playerOnSeekCallback`. Agora recommends that you do not pass in values to all these parameters in one call; otherwise, this call may fail.