PLVPlayer

Objective-C

@interface PLVPlayer : NSObject

Swift

class PLVPlayer : NSObject

裸播放器

Note

支持直接使用 URL 进行播放;此类不具备业务逻辑,也不依赖其他业务类;

可配置项

  • delegate

    Declaration

    Objective-C

    @property (nonatomic, weak) id<PLVPlayerDelegate> _Nullable delegate;

    Swift

    weak var delegate: PLVPlayerDelegate? { get set }
  • App进入后台时,是否暂停 主播放器 播放

    Note

    若需支持‘后台播放’,则需同时在 TARGETS - Capability - Background Modes 中勾选 “Audio, AirPlay, and Picture in Picture”; YES:关闭后台播放 NO:开启后台播放;默认值 NO; 从后台进入前台时,主播放器不会自动恢复播放。请根据业务需要,自行调用恢复播放方法;

    Declaration

    Objective-C

    @property (nonatomic) BOOL pauseMainPlayerInBackground;

    Swift

    var pauseMainPlayerInBackground: Bool { get set }
  • App进入后台时,是否暂停 副播放器 播放

    Note

    若需支持‘后台播放’,则需同时在 TARGETS - Capability - Background Modes 中勾选 “Audio, AirPlay, and Picture in Picture”; YES:关闭后台播放 NO:开启后台播放;默认值 NO; 从后台进入前台时,副播放器会自动恢复播放。若业务所需,可自行调用暂停播放方法;

    Declaration

    Objective-C

    @property (nonatomic) BOOL pauseSubPlayerInBackground;

    Swift

    var pauseSubPlayerInBackground: Bool { get set }

数据

  • 当前帧时间戳信息

    Declaration

    Objective-C

    @property (nonatomic, readonly) long curFrameAUserTC;

    Swift

    var curFrameAUserTC: Int { get }
  • 视频缓存时长

    Declaration

    Objective-C

    @property (nonatomic, readonly) int64_t videoCacheDuration;

    Swift

    var videoCacheDuration: Int64 { get }
  • 视频下载速率

    Declaration

    Objective-C

    @property (nonatomic, readonly) int64_t originalTcpSpeed;

    Swift

    var originalTcpSpeed: Int64 { get }
  • 视频下载速率字符串 (示例 “100KB/s”)

    Declaration

    Objective-C

    @property (nonatomic, readonly) NSString *_Nonnull tcpSpeed;

    Swift

    var tcpSpeed: String { get }
  • 视频大小

    Declaration

    Objective-C

    @property (nonatomic, readonly) CGSize naturalSize;

    Swift

    var naturalSize: CGSize { get }
  • 当前播放时间点 (单位:秒;仅非直播场景下有值)

    Declaration

    Objective-C

    @property (nonatomic, readonly) NSTimeInterval currentPlaybackTime;

    Swift

    var currentPlaybackTime: TimeInterval { get }
  • 视频总时长 (仅非直播场景下有值)

    Declaration

    Objective-C

    @property (nonatomic, readonly) NSTimeInterval duration;

    Swift

    var duration: TimeInterval { get }
  • 当前已缓存时长 (仅非直播场景下有值)

    Declaration

    Objective-C

    @property (nonatomic, readonly) NSTimeInterval playableDuration;

    Swift

    var playableDuration: TimeInterval { get }
  • 当前倍速 (仅非直播场景下有值)

    Declaration

    Objective-C

    @property (nonatomic, readonly) CGFloat currentSpeed;

    Swift

    var currentSpeed: Double { get }

状态

  • Undocumented

    Declaration

    Objective-C

    @property (nonatomic, readonly) IJKMPMoviePlaybackState mainPlayerPlaybackState

    Swift

    var mainPlayerPlaybackState: Int32 { get }
  • Undocumented

    Declaration

    Objective-C

    @property (nonatomic, readonly) IJKMPMovieLoadState mainPlayerLoadState

    Swift

    var mainPlayerLoadState: Int32 { get }
  • 播放器的缩放模式,默认为IJKMPMovieScalingModeAspectFit

    Declaration

    Objective-C

    @property (nonatomic, readonly) int scalingMode;

    Swift

    var scalingMode: Int32 { get }
  • Undocumented

    Declaration

    Objective-C

    @property (nonatomic, readonly) BOOL mainPlayerExist

    Swift

    var mainPlayerExist: Bool { get }
  • Undocumented

    Declaration

    Objective-C

    @property (nonatomic, readonly) BOOL subPlayerExist

    Swift

    var subPlayerExist: Bool { get }
  • 是否正在播放中

    Declaration

    Objective-C

    @property (nonatomic, readonly) BOOL playing;

    Swift

    var playing: Bool { get }
  • 主播放器 是否将暂停

    Declaration

    Objective-C

    @property (nonatomic, readonly) BOOL willPaused;

    Swift

    var willPaused: Bool { get }
  • 是否正在展示内容

    Note

    ’正在展示内容‘ 指 ’内容加载中‘、’播放内容中‘

    Declaration

    Objective-C

    @property (nonatomic) BOOL showingContent;

    Swift

    var showingContent: Bool { get set }

功能对象

  • 由外部传入的,负责承载播放器画面的父视图

    Note

    需调用 [setupDisplaySuperview:] 方法来设置

    Declaration

    Objective-C

    @property (nonatomic, strong, readonly) UIView * displaySuperview

通用

  • 播放主体内容

    Note

    主体内容将由 主播放器 负责加载、播放; 相比 副播放器,主播放器对外部的回调更丰富; 内部不会因 副播放器 的创建,而自动销毁 主播放器,有需要请自行销毁;

    Declaration

    Objective-C

    - (void)loadMainContentToPlayWithContentURL:(nonnull NSURL *)contentURL
                                    withOptions:(id)options;

    Swift

    func loadMainContentToPlay(withContentURL contentURL: URL, withOptions options: Any!)

    Parameters

    contentURL

    主体内容的媒体地址

    options

    播放器配置选项

  • 播放其他内容

    Note

    其他内容将由 副播放器 负责加载、播放; 相比 主播放器,副播放器对外部的回调更精简; 内部不会因 主播放器 的创建,而自动销毁 副播放器,有需要请自行销毁;

    Declaration

    Objective-C

    - (void)loadSubContentToPlayWithContentURL:(nonnull NSURL *)contentURL
                                   withOptions:(id)options;

    Swift

    func loadSubContentToPlay(withContentURL contentURL: URL, withOptions options: Any!)

    Parameters

    contentURL

    其他内容的媒体地址

    options

    播放器配置选项

  • 设置 承载播放器画面 的父视图

    Declaration

    Objective-C

    - (void)setupDisplaySuperview:(id)displayeSuperview;

    Swift

    func setupDisplaySuperview(_ displayeSuperview: Any!)

    Parameters

    displayeSuperview

    承载播放器画面的父视图

  • 设置 播放器 的缩放模式

    Declaration

    Objective-C

    - (void)setupScalingMode:(id)scalingMode;

    Swift

    func setupScalingMode(_ scalingMode: Any!)

    Parameters

    scalingMode

    缩放模式,默认为IJKMPMovieScalingModeAspectFit

  • 清理 主播放器

    Declaration

    Objective-C

    - (void)clearMainPlayer;

    Swift

    func clearMainPlayer()
  • 清理 副播放器

    Declaration

    Objective-C

    - (void)clearSubPlayer;

    Swift

    func clearSubPlayer()
  • 清理 全部播放器

    Declaration

    Objective-C

    - (void)clearAllPlayer;

    Swift

    func clearAllPlayer()
  • 暂停 主播放器 播放

    Declaration

    Objective-C

    - (void)pause;

    Swift

    func pause()
  • 暂停 副播放器 播放

    Declaration

    Objective-C

    - (void)subPlayerPause;

    Swift

    func subPlayerPause()
  • 静音 主播放器

    Declaration

    Objective-C

    - (void)mute;

    Swift

    func mute()
  • 取消静音 主播放器

    Declaration

    Objective-C

    - (void)cancelMute;

    Swift

    func cancelMute()
  • 静音 副播放器

    Declaration

    Objective-C

    - (void)subPlayerMute;

    Swift

    func subPlayerMute()
  • 取消静音 副播放器

    Declaration

    Objective-C

    - (void)subPlayerCancleMute;

    Swift

    func subPlayerCancleMute()

快直播相关

  • 获取快直播下的包重传次数

    Declaration

    Objective-C

    - (int64_t)getWebrtcNackCount;

    Swift

    func getWebrtcNackCount() -> Int64
  • 获取快直播下的视频包接收个数

    Declaration

    Objective-C

    - (int64_t)getWebrtcVideoPacketReceive;

    Swift

    func getWebrtcVideoPacketReceive() -> Int64

非直播相关

  • 开始 主播放器 播放

    Declaration

    Objective-C

    - (void)play;

    Swift

    func play()
  • 开始 副播放器 播放

    Declaration

    Objective-C

    - (void)subPlayerPlay;

    Swift

    func subPlayerPlay()
  • 主播放器 视频跳至某个时间点

    Declaration

    Objective-C

    - (void)seekToTime:(NSTimeInterval)toTime;

    Swift

    func seek(toTime: TimeInterval)
  • 主播放器 切换倍速 (范围值 0.0~2.0)

    Declaration

    Objective-C

    - (void)switchSpeedRate:(CGFloat)toSpeed;

    Swift

    func switchSpeedRate(_ toSpeed: Double)