ZegoMediaPlayer Class Reference

Inherits from NSObject
Declared in ZegoExpressDefines.h

– setEventHandler:

Event callback handler for media player

- (void)setEventHandler:(nullable id<ZegoMediaPlayerEventHandler>)handler

Parameters

handler

Event callback handler for media player

Declared In

ZegoExpressDefines.h

– setVideoHandler:format:type:

Video data callback handler for media player

- (void)setVideoHandler:(nullable id<ZegoMediaPlayerVideoHandler>)handler format:(ZegoVideoFrameFormat)format type:(ZegoVideoBufferType)type

Parameters

handler

Video data callback handler for media player

format

Video frame format for video data

type

Buffer type for video data

Declared In

ZegoExpressDefines.h

– setAudioHandler:

Audio data callback handler for media player

- (void)setAudioHandler:(nullable id<ZegoMediaPlayerAudioHandler>)handler

Parameters

handler

Audio data callback handler for media player

Declared In

ZegoExpressDefines.h

– setBlockDataHandler:blockSize:

The media resource block data callback handler of the media player.

- (void)setBlockDataHandler:(nullable id<ZegoMediaPlayerBlockDataHandler>)handler blockSize:(unsigned int)blockSize

Parameters

handler

The media resource block data callback handler of the media player.

blockSize

The size of the encrypted data block. The bufferSize in the OnBlockData callback is an integer multiple of blockSize.

Declared In

ZegoExpressDefines.h

– loadResource:callback:

The absolute resource path or the URL of the network resource and cannot be nil or “”. Android can set this path string with Uri.

- (void)loadResource:(NSString *)path callback:(nullable ZegoMediaPlayerLoadResourceCallback)callback

Parameters

path

The absolute resource path or the URL of the network resource and cannot be nil or “”. Android can set this path string with Uri.

callback

Notification of resource loading results

Declared In

ZegoExpressDefines.h

– loadResourceWithPosition:startPosition:callback:

The absolute resource path or the URL of the network resource and cannot be nil or “”. Android can set this path string with Uri.

- (void)loadResourceWithPosition:(NSString *)path startPosition:(long)startPosition callback:(nullable ZegoMediaPlayerLoadResourceCallback)callback

Parameters

path

The absolute resource path or the URL of the network resource and cannot be nil or “”. Android can set this path string with Uri.

startPosition

The progress at which the playback started.

callback

Notification of resource loading results

Declared In

ZegoExpressDefines.h

– loadResourceFromMediaData:startPosition:callback:

Binary audio data.

- (void)loadResourceFromMediaData:(NSData *)mediaData startPosition:(long)startPosition callback:(nullable ZegoMediaPlayerLoadResourceCallback)callback

Parameters

mediaData

Binary audio data.

startPosition

Position of starting playback, in milliseconds.

callback

Notification of resource loading results.

Declared In

ZegoExpressDefines.h

– loadCopyrightedMusicResourceWithPosition:startPosition:callback:

The resource ID obtained from the copyrighted music module.

- (void)loadCopyrightedMusicResourceWithPosition:(NSString *)resourceID startPosition:(long)startPosition callback:(nullable ZegoMediaPlayerLoadResourceCallback)callback

Parameters

resourceID

The resource ID obtained from the copyrighted music module.

startPosition

The progress at which the playback started.

callback

Notification of resource loading results

Declared In

ZegoExpressDefines.h

– loadResourceWithConfig:callback:

Multimedia resources that need to be loaded.

- (void)loadResourceWithConfig:(ZegoMediaPlayerResource *)resource callback:(nullable ZegoMediaPlayerLoadResourceCallback)callback

Parameters

resource

Multimedia resources that need to be loaded.

callback

Notification of resource loading results

Declared In

ZegoExpressDefines.h

– start

You need to load resources before playing

- (void)start

Declared In

ZegoExpressDefines.h

– stop

Stop playing.

- (void)stop

Declared In

ZegoExpressDefines.h

– pause

Pause playing.

- (void)pause

Declared In

ZegoExpressDefines.h

– resume

Resume playing.

- (void)resume

Declared In

ZegoExpressDefines.h

– seekTo:callback:

Point in time of specified playback progress

- (void)seekTo:(unsigned long long)millisecond callback:(nullable ZegoMediaPlayerSeekToCallback)callback

Parameters

millisecond

Point in time of specified playback progress

callback

The result notification of set the specified playback progress

Declared In

ZegoExpressDefines.h

– enableRepeat:

repeat playback flag. The default is NO.

- (void)enableRepeat:(BOOL)enable

Parameters

enable

repeat playback flag. The default is NO.

Declared In

ZegoExpressDefines.h

– setPlaySpeed:

The speed of play. The range is 0.5 ~ 4.0. The default is 1.0.

- (void)setPlaySpeed:(float)speed

Parameters

speed

The speed of play. The range is 0.5 ~ 4.0. The default is 1.0.

Declared In

ZegoExpressDefines.h

– enableAux:

Aux audio flag. The default is NO.

- (void)enableAux:(BOOL)enable

Parameters

enable

Aux audio flag. The default is NO.

Declared In

ZegoExpressDefines.h

– muteLocal:

Mute local audio flag, The default is NO.

- (void)muteLocal:(BOOL)mute

Parameters

mute

Mute local audio flag, The default is NO.

Declared In

ZegoExpressDefines.h

– setPlayerCanvas:

Video rendered canvas object

- (void)setPlayerCanvas:(nullable ZegoCanvas *)canvas

Parameters

canvas

Video rendered canvas object

Declared In

ZegoExpressDefines.h

– setVolume:

The range is 0 ~ 200. The default is 60.

- (void)setVolume:(int)volume

Parameters

volume

The range is 0 ~ 200. The default is 60.

Declared In

ZegoExpressDefines.h

– setPlayVolume:

The range is 0 ~ 200. The default is 60.

- (void)setPlayVolume:(int)volume

Parameters

volume

The range is 0 ~ 200. The default is 60.

Declared In

ZegoExpressDefines.h

– setPublishVolume:

The range is 0 ~ 200. The default is 60.

- (void)setPublishVolume:(int)volume

Parameters

volume

The range is 0 ~ 200. The default is 60.

Declared In

ZegoExpressDefines.h

– setProgressInterval:

Interval of playback progress callback in milliseconds

- (void)setProgressInterval:(unsigned long long)millisecond

Parameters

millisecond

Interval of playback progress callback in milliseconds

Declared In

ZegoExpressDefines.h

– playVolume

current volume

- (int)playVolume

Return Value

current volume

Declared In

ZegoExpressDefines.h

– publishVolume

current volume

- (int)publishVolume

Return Value

current volume

Declared In

ZegoExpressDefines.h

– totalDuration

Unit is millisecond

- (unsigned long long)totalDuration

Return Value

Unit is millisecond

Declared In

ZegoExpressDefines.h

– currentProgress

current progress

- (unsigned long long)currentProgress

Return Value

current progress

Declared In

ZegoExpressDefines.h

– currentRenderingProgress

current rendering progress

- (unsigned long long)currentRenderingProgress

Return Value

current rendering progress

Declared In

ZegoExpressDefines.h

– audioTrackCount

Number of audio tracks

- (unsigned int)audioTrackCount

Return Value

Number of audio tracks

Declared In

ZegoExpressDefines.h

– setAudioTrackIndex:

Audio track index, the number of audio tracks can be obtained through the [getAudioTrackCount] function.

- (void)setAudioTrackIndex:(unsigned int)index

Parameters

index

Audio track index, the number of audio tracks can be obtained through the [getAudioTrackCount] function.

Declared In

ZegoExpressDefines.h

– setAudioTrackMode:

Audio track mode.

- (void)setAudioTrackMode:(ZegoMediaPlayerAudioTrackMode)mode

Parameters

mode

Audio track mode.

Declared In

ZegoExpressDefines.h

– setAudioTrackPublishIndex:

Audio track index, the number of audio tracks can be obtained through the [getAudioTrackCount] function.

- (void)setAudioTrackPublishIndex:(unsigned int)index

Parameters

index

Audio track index, the number of audio tracks can be obtained through the [getAudioTrackCount] function.

Declared In

ZegoExpressDefines.h

– setVoiceChangerParam:audioChannel:

Voice changer parameters

- (void)setVoiceChangerParam:(ZegoVoiceChangerParam *)param audioChannel:(ZegoMediaPlayerAudioChannel)audioChannel

Parameters

param

Voice changer parameters

audioChannel

The audio channel to be voice changed

Declared In

ZegoExpressDefines.h

– currentState

current state

- (ZegoMediaPlayerState)currentState

Return Value

current state

Declared In

ZegoExpressDefines.h

– index

Media player index.

- (NSNumber *)index

Return Value

Media player index.

Declared In

ZegoExpressDefines.h

– takeSnapshot:

The callback of the screenshot of the media player playing screen

- (void)takeSnapshot:(ZegoMediaPlayerTakeSnapshotCallback)callback

Parameters

callback

The callback of the screenshot of the media player playing screen

Declared In

ZegoExpressDefines.h

– enableAccurateSeek:config:

Whether to enable accurate seek

- (void)enableAccurateSeek:(BOOL)enable config:(ZegoAccurateSeekConfig *)config

Parameters

enable

Whether to enable accurate seek

config

The property setting of accurate seek, only valid when enable is YES.

Declared In

ZegoExpressDefines.h

– setNetWorkResourceMaxCache:size:

The maximum length of the cache time, in ms, the SDK internal default is 5000; the effective value is greater than or equal to 2000; if you fill in 0, it means no limit.

- (void)setNetWorkResourceMaxCache:(unsigned int)time size:(unsigned int)size

Parameters

time

The maximum length of the cache time, in ms, the SDK internal default is 5000; the effective value is greater than or equal to 2000; if you fill in 0, it means no limit.

size

The maximum size of the cache, the unit is byte, the internal default size of the SDK is 1510241024 byte; the effective value is greater than or equal to 5000000, if you fill in 0, it means no limit.

Declared In

ZegoExpressDefines.h

– getNetWorkResourceCache

Returns the current cached information, including the length of time the data can be played and the size of the cached data.

- (ZegoNetWorkResourceCache *)getNetWorkResourceCache

Return Value

Returns the current cached information, including the length of time the data can be played and the size of the cached data.

Declared In

ZegoExpressDefines.h

– setNetWorkBufferThreshold:

Threshold that needs to be reached to resume playback, unit ms.

- (void)setNetWorkBufferThreshold:(unsigned int)threshold

Parameters

threshold

Threshold that needs to be reached to resume playback, unit ms.

Declared In

ZegoExpressDefines.h

– enableSoundLevelMonitor:millisecond:

Whether to enable monitoring, YES is enabled, NO is disabled.

- (void)enableSoundLevelMonitor:(BOOL)enable millisecond:(unsigned int)millisecond

Parameters

enable

Whether to enable monitoring, YES is enabled, NO is disabled.

millisecond

Monitoring time period of the sound level, in milliseconds, has a value range of [100, 3000].

Declared In

ZegoExpressDefines.h

– enableFrequencySpectrumMonitor:millisecond:

Whether to enable monitoring, YES is enabled, NO is disabled.

- (void)enableFrequencySpectrumMonitor:(BOOL)enable millisecond:(unsigned int)millisecond

Parameters

enable

Whether to enable monitoring, YES is enabled, NO is disabled.

millisecond

Monitoring time period of the frequency spectrum, in milliseconds, has a value range of [100, 3000].

Declared In

ZegoExpressDefines.h

– setActiveAudioChannel:

Playback channel, the default is ZegoMediaPlayerAudioChannelAll.

- (void)setActiveAudioChannel:(ZegoMediaPlayerAudioChannel)audioChannel

Parameters

audioChannel

Playback channel, the default is ZegoMediaPlayerAudioChannelAll.

Declared In

ZegoExpressDefines.h

– clearView

Available since: 2.20.0 Description: Clears the last frame of the playback control that remains on the control after playback ends. When to call: It can be called after the engine by [createEngine] has been initialized and the media player has been created by [createMediaPlayer]. Restrictions: The interface call takes effect only when the media player ends playing.

- (void)clearView

Declared In

ZegoExpressDefines.h

– getMediaInfo

Available since: 3.6.0 Description: Get meida information such as video resolution from media file. When to call: It can be called after the engine by [createEngine] has been initialized and the media player has been created by [createMediaPlayer]. Restrictions: None.

- (ZegoMediaPlayerMediaInfo *)getMediaInfo

Declared In

ZegoExpressDefines.h

– updatePosition:

The unit vector of the front axis of its own coordinate system. The parameter is a float array with a length of 3.

- (void)updatePosition:(const float [ _Nonnull 3 ])position

Parameters

position

The unit vector of the front axis of its own coordinate system. The parameter is a float array with a length of 3.

Declared In

ZegoExpressDefines.h

– setHttpHeader:

Headers info.

- (void)setHttpHeader:(NSDictionary<NSString*,NSString*> *)headers

Parameters

headers

Headers info.

Declared In

ZegoExpressDefines.h

– setPlayMediaStreamType:

Stream type.

- (void)setPlayMediaStreamType:(ZegoMediaStreamType)streamType

Parameters

streamType

Stream type.

Declared In

ZegoExpressDefines.h

– enableLiveAudioEffect:mode:

Whether to enable live audio effect.

- (void)enableLiveAudioEffect:(BOOL)enable mode:(ZegoLiveAudioEffectMode)mode

Parameters

enable

Whether to enable live audio effect.

mode

Live audio effect mode.

Declared In

ZegoExpressDefines.h

– enableLocalCache:cacheDir:

Whether to enable local caching.

- (void)enableLocalCache:(BOOL)enable cacheDir:(NSString *)cacheDir

Parameters

enable

Whether to enable local caching.

cacheDir

Cache dir. If left blank, the directory specified internally by SDK will be used.

Declared In

ZegoExpressDefines.h

– enableViewMirror:

Whether to enable view mirror.

- (void)enableViewMirror:(BOOL)enable

Parameters

enable

Whether to enable view mirror.

Declared In

ZegoExpressDefines.h

– getPlaybackStatistics

Available since: 3.12.0 Description: Get current playback statistics to monitor whether decoding and rendering anomalies occur in the player. Use cases: Typically used in cloud-based media player scenarios. When to call: Invoke after the [loadResource] callback succeeds.

- (ZegoMediaPlayerStatisticsInfo *)getPlaybackStatistics

Declared In

ZegoExpressDefines.h

+ new

Please use the [createMediaPlayer] function in ZegoExpressEngine class instead.

+ (instancetype)new

Declared In

ZegoExpressDefines.h

– init

Please use the [createMediaPlayer] function in ZegoExpressEngine class instead.

- (instancetype)init

Declared In

ZegoExpressDefines.h