ZegoMediaPlayer Class Reference

Inherits from NSObject
Declared in zego-api-mediaplayer-oc.h

Overview

播放器

– initWithPlayerType:

初始化

- (instancetype)initWithPlayerType:(MediaPlayerType)type

Parameters

type

@see MediaPlayerType

Return Value

播放器对象

Discussion

Note: sdk提供多个播放器实例,通过index可以指定获取的是哪个播放器实例,没有指定index时,取到的就是 ZegoMediaPlayerIndexIndexFirst 播放器

Declared In

zego-api-mediaplayer-oc.h

– initWithPlayerType:playerIndex:

初始化

- (instancetype)initWithPlayerType:(MediaPlayerType)type playerIndex:(ZegoMediaPlayerIndex)index

Parameters

type

@see MediaPlayerType

index

sdk提供多个播放器实例,通过index可以指定获取的是哪个播放器实例 @see ZegoMediaPlayerIndex

Return Value

播放器对象

Declared In

zego-api-mediaplayer-oc.h

– uninit

释放播放器

- (void)uninit

Declared In

zego-api-mediaplayer-oc.h

– setDelegate:

设置播放器事件回调

- (void)setDelegate:(id<ZegoMediaPlayerEventDelegate>)delegate

Parameters

delegate

回调

Declared In

zego-api-mediaplayer-oc.h

– setVideoPlayDelegate:format:

设置视频帧数据回调

- (void)setVideoPlayDelegate:(id<ZegoMediaPlayerVideoPlayDelegate>)delegate format:(ZegoMediaPlayerVideoPixelFormat)format

Parameters

delegate

回调

format

需要返回的视频帧数据格式,@see ZegoMediaPlayerVideoPixelFormat

Declared In

zego-api-mediaplayer-oc.h

– setEventWithIndexDelegate:

设置播放器事件回调

- (void)setEventWithIndexDelegate:(id<ZegoMediaPlayerEventWithIndexDelegate>)delegate

Parameters

delegate

回调

Declared In

zego-api-mediaplayer-oc.h

– setVideoPlayWithIndexDelegate:format:

设置视频帧数据回调

- (void)setVideoPlayWithIndexDelegate:(id<ZegoMediaPlayerVideoPlayWithIndexDelegate>)delegate format:(ZegoMediaPlayerVideoPixelFormat)format

Parameters

delegate

回调

format

需要返回的视频帧数据格式,@see ZegoMediaPlayerVideoPixelFormat

Declared In

zego-api-mediaplayer-oc.h

– setAudioPlayDelegate:

设置音频数据回调

- (void)setAudioPlayDelegate:(id<ZegoMediaPlayerAudioPlayDelegate>)delegate

Parameters

delegate

回调

Declared In

zego-api-mediaplayer-oc.h

– start:repeat:

开始播放

- (void)start:(NSString *)path repeat:(BOOL)repeat

Parameters

path

媒体文件的路径

repeat

是否重复播放

Declared In

zego-api-mediaplayer-oc.h

– stop

停止播放

- (void)stop

Declared In

zego-api-mediaplayer-oc.h

– pause

暂停播放

- (void)pause

Declared In

zego-api-mediaplayer-oc.h

– resume

恢复播放

- (void)resume

Declared In

zego-api-mediaplayer-oc.h

– seekTo:

设置指定的进度进行播放

- (void)seekTo:(long)millisecond

Parameters

millisecond

指定的进度,单位毫秒

Declared In

zego-api-mediaplayer-oc.h

– getDuration

获取整个文件的播放时长

- (long)getDuration

Return Value

文件的播放时长,单位毫秒

Declared In

zego-api-mediaplayer-oc.h

– getCurrentDuration

获取当前播放的进度

- (long)getCurrentDuration

Return Value

当前播放进度,单位毫秒

Declared In

zego-api-mediaplayer-oc.h

– muteLocal:

设置本地静默播放

- (void)muteLocal:(BOOL)mute

Parameters

mute

是否静默播放

Discussion

Warning: 如果设置 MediaPlayerTypeAux 模式,推出的流是有声音的

Declared In

zego-api-mediaplayer-oc.h

– load:

预加载资源

- (void)load:(NSString *)path

Parameters

path

媒体文件的路径

Declared In

zego-api-mediaplayer-oc.h

– setView:

设置显示视频的view

- (void)setView:(UIView *)view

Parameters

view

播放的控件

Declared In

zego-api-mediaplayer-oc.h

– setVolume:

设置音量

- (void)setVolume:(int)volume

Parameters

volume

音量,范围在0到100,默认值是50

Declared In

zego-api-mediaplayer-oc.h

– setAudioStream:

设置播放文件的音轨

- (long)setAudioStream:(long)streamIndex

Parameters

streamIndex

音轨序号,可以通过 getAudioStreamCount 接口获取音轨个数

Declared In

zego-api-mediaplayer-oc.h

– setPlayerType:

设置播放器类型

- (void)setPlayerType:(MediaPlayerType)type

Parameters

type

@see MediaPlayerType

Declared In

zego-api-mediaplayer-oc.h

– takeSnapshot

获取当前播放视频的截图

- (void)takeSnapshot

Discussion

Note: 只有在调用 setView 设置了显示控件,以及播放状态的情况下,才能正常截图。

Declared In

zego-api-mediaplayer-oc.h

– getAudioStreamCount

获取音轨个数

- (long)getAudioStreamCount

Return Value

音轨个数

Declared In

zego-api-mediaplayer-oc.h

– enableRepeatMode:

设置是否重复播放

- (void)enableRepeatMode:(BOOL)enable

Parameters

enable

YES:重复播放,NO:不重复播放

Declared In

zego-api-mediaplayer-oc.h

– setProcessInterval:

设置播放进度回调间隔。

- (BOOL)setProcessInterval:(long)interval

Parameters

interval

回调间隔,单位毫秒。有效值为大于等于 0。默认值为 0。

Discussion

Note: 设置 interval 大于 0 时,就会收到 OnPlaybackProgress 回调。interval = 0 时,停止回调。

Note: 回调不会严格按照设定的回调间隔值返回,而是以处理音频帧或者视频帧的频率来判断是否需要回调。

Declared In

zego-api-mediaplayer-oc.h

– requireHWDecoder

设置使用硬件解码

- (BOOL)requireHWDecoder

Return Value

设置是否成功

Discussion

Note: 当前只支持 iOS 系统

Note: 需要在加载媒体资源之前设置,即在 start 或者 load 之前

Note: 即使设置了使用硬件解码,引擎也会根据当前硬件情况决定是否使用

Note: 多次调用没有影响

Declared In

zego-api-mediaplayer-oc.h

– setViewMode:

设置播放器播放控件的显示模式

- (void)setViewMode:(ZegoVideoViewMode)mode

Parameters

mode

显示模式,详见 ZegoVideoViewMode,默认为 ZegoVideoViewModeScaleAspectFit

Declared In

zego-api-mediaplayer-oc.h

– setBackgroundColor:

设置播放的背景颜色

- (void)setBackgroundColor:(int)color

Parameters

color

颜色,取值为0x00RRGGBB

Declared In

zego-api-mediaplayer-oc.h

– clearView

清除播放控件播放结束后, 在控件上保留的最后一帧画面

- (void)clearView

Declared In

zego-api-mediaplayer-oc.h