Skip to content

SNMediaPlayer

Ju Liaoyuan edited this page Dec 20, 2022 · 1 revision

SNMediaPlayer Protocol Reference

  Conforms to NSObject
  Declared in SNMediaPlayer.h

Overview

多媒体播放器, 支持aac, mp3, m4a, mp4

Tasks

– playWithPath:isRepeat: required method

– playVideoWithPath:isRepeat:inView: required method

– stop required method

– pause required method

– resume required method

– setVolume: required method

– volume required method

– duration required method

– duration: required method

– seekTo: required method

– onPlayProgress required method

– onPlayBegin required method

– onPlayEnd required method

– onBufferBegin required method

– onBufferEnd required method

– onPlayError required method

– playerIdentifier required method

– setView: required method

– getAudioStreamCount required method

– setAudioStream: required method

– destroy required method

Instance Methods

destroy

- (void)destroy

Declared In

  • SNMediaPlayer.h

duration

获取当前长度

- (RACSignal *)duration

Return Value

bgm 时长,单位毫秒

Discussion

获取当前长度

Declared In

  • SNMediaPlayer.h

duration:

获取指定路径长度

- (RACSignal *)duration:(NSString *)*path*

Return Value

bgm 时长,单位毫秒

Discussion

获取指定路径长度

Declared In

  • SNMediaPlayer.h

getAudioStreamCount

获取音轨数量

- (NSInteger)getAudioStreamCount

Discussion

获取音轨数量

Declared In

  • SNMediaPlayer.h

onBufferBegin

开始缓冲回调

- (RACSubject *)onBufferBegin

Discussion

开始缓冲回调

Declared In

  • SNMediaPlayer.h

onBufferEnd

结束缓冲回调

- (RACSubject *)onBufferEnd

Discussion

结束缓冲回调

Declared In

  • SNMediaPlayer.h

onPlayBegin

播放开始

- (RACSubject *)onPlayBegin

Discussion

播放开始

Declared In

  • SNMediaPlayer.h

onPlayEnd

播放结束

- (RACSubject *)onPlayEnd

Discussion

播放结束

Declared In

  • SNMediaPlayer.h

onPlayError

播放失败回调

- (RACSubject *)onPlayError

Discussion

播放失败回调

Declared In

  • SNMediaPlayer.h

onPlayProgress

播放进度回调,回调的频率默认是 1000ms。 注意:回调不在主线程,涉及到UI请自行切换到主线程

- (RACSubject *)onPlayProgress

Discussion

播放进度回调,回调的频率默认是 1000ms。 注意:回调不在主线程,涉及到UI请自行切换到主线程

Declared In

  • SNMediaPlayer.h

pause

暂停播放

- (RACSignal *)pause

Return Value

完成回调

Discussion

暂停播放

Declared In

  • SNMediaPlayer.h

playVideoWithPath:isRepeat:inView:

播放视频

- (RACSignal *)playVideoWithPath:(NSString *)*path* isRepeat:(BOOL)*isRepeat* inView:(nullable UIView *)*view*

Parameters

path
   路径

isRepeat
   是否重复播放

view
   用于展示视频的 view

Return Value

开始播放回调

Discussion

播放视频

Declared In

  • SNMediaPlayer.h

playWithPath:isRepeat:

播放

- (RACSignal *)playWithPath:(NSString *)*path* isRepeat:(BOOL)*isRepeat*

Parameters

path
   路径

isRepeat
   是否重复播放

Return Value

开始播放回调

Discussion

播放

Declared In

  • SNMediaPlayer.h

playerIdentifier

- (NSInteger)playerIdentifier

Declared In

  • SNMediaPlayer.h

resume

继续播放

- (RACSignal *)resume

Return Value

完成回调

Discussion

继续播放

Declared In

  • SNMediaPlayer.h

seekTo:

设置当前播放位置, 单位毫秒

- (RACSignal *)seekTo:(NSInteger)*position*

Return Value

完成回调,包含的值为seek的最终值(会和position有偏差)

Discussion

设置当前播放位置, 单位毫秒

Declared In

  • SNMediaPlayer.h

setAudioStream:

设置播放音轨

- (BOOL)setAudioStream:(SNPlayerAudioStreamIndex)*index*

Parameters

index
   音轨下标,@see SNPlayerAudioStreamIndex, default is SNPlayerAudioStreamIndexOri

Discussion

设置播放音轨

Declared In

  • SNMediaPlayer.h

setView:

设置(更新)播放器播放的 view

- (void)setView:(nullable UIView *)*view*

Discussion

设置(更新)播放器播放的 view

Declared In

  • SNMediaPlayer.h

setVolume:

设置音量, 音量大小,100为正常音量,取值范围为0 - 200;默认值:100

- (void)setVolume:(NSInteger)*volume*

Discussion

设置音量, 音量大小,100为正常音量,取值范围为0 - 200;默认值:100

Declared In

  • SNMediaPlayer.h

stop

停止播放

- (RACSignal *)stop

Return Value

完成回调

Discussion

停止播放

Declared In

  • SNMediaPlayer.h

volume

获取音量大小,范围为0-200

- (NSInteger)volume

Discussion

获取音量大小,范围为0-200

Declared In

  • SNMediaPlayer.h
Clone this wiki locally