PLVLivePlayer
Objective-C
@interface PLVLivePlayer : PLVPlayer <PLVLivePlayerPictureInPictureProtocol>
Swift
class PLVLivePlayer : PLVPlayer, PLVLivePlayerPictureInPictureProtocol
直播播放器
Note
若您希望了解 播放器基础功能 相关属性方法,可查看父类 PLVPlayer.h; 若您希望了解 直播业务 相关属性方法,可查看 PLVLivePlayer.h;// 使用演示
PLVLivePlayer * livePlayer = [[PLVLivePlayer alloc] initWithPLVAccountUserId:accountUserId channelId:channelId];
livePlayer.delegate = self;
livePlayer.liveDelegate = self;
[livePlayer setupDisplaySuperview:displaySuperview];
-
直播播放器 liveDelegate
Note
父类 PLVPlayer 的 delegate 也有播放器基础功能的回调,详情可见 PLVPlayer.hDeclaration
Objective-C
@property (nonatomic, weak) id<PLVLivePlayerDelegate> _Nullable liveDelegate;
Swift
weak var liveDelegate: PLVLivePlayerDelegate? { get set }
-
是否观看无延迟直播 默认值 NO;
Declaration
Objective-C
@property (nonatomic) BOOL channelWatchNoDelay;
Swift
var channelWatchNoDelay: Bool { get set }
-
是否观看快直播 默认值 NO;
Declaration
Objective-C
@property (nonatomic) BOOL channelWatchQuickLive;
Swift
var channelWatchQuickLive: Bool { get set }
-
是否观看公共流 默认值 NO;
Declaration
Objective-C
@property (nonatomic) BOOL channelWatchPublicStream;
Swift
var channelWatchPublicStream: Bool { get set }
-
是否开启追帧 默认值 NO;
Declaration
Objective-C
@property (nonatomic) BOOL chaseFrame;
Swift
var chaseFrame: Bool { get set }
-
视频解码是否使用“硬解码”
Note
硬解码效率更高,而软解码兼容性更好; YES:使用硬解码 NO:使用软解码; 默认值 YES;Declaration
Objective-C
@property (nonatomic) BOOL videoToolBox;
Swift
var videoToolBox: Bool { get set }
-
是否允许展示暖场内容
Note
暖场内容有’视频‘、’图片‘两种类型;后者将通过回调 告知外部,外部可自行展示; 默认值 YES; ‘暖场’ 有别于 ’广告‘,具体业务区别可见PLV后台配置;Declaration
Objective-C
@property (nonatomic) BOOL allowShowWarmUpContent;
Swift
var allowShowWarmUpContent: Bool { get set }
-
后台统计参数数据模型
Note
播放器发送 ViewLog 日志所需要的数据模型,详见 PLVViewLogCustomParam.h 参考可配置的统计参数Declaration
Objective-C
@property (nonatomic, strong) PLVViewLogCustomParam *_Nonnull customParam;
Swift
var customParam: PLVViewLogCustomParam { get set }
-
频道信息数据模型
Declaration
Objective-C
@property (nonatomic, strong, readonly) PLVChannelInfoModel *_Nonnull channelInfo;
Swift
var channelInfo: PLVChannelInfoModel { get }
-
当前频道号
Declaration
Objective-C
@property (nonatomic, copy, readonly) NSString *_Nonnull channelId;
Swift
var channelId: String { get }
-
直播播放器ID
Declaration
Objective-C
@property (nonatomic, copy, readonly) NSString *_Nonnull livePlayerId;
Swift
var livePlayerId: String { get }
-
用户观看时长 (单位:秒;播放器暂停则不认为“观看”;不包含连麦;包含无延迟观看)
Declaration
Objective-C
@property (nonatomic, readonly) NSInteger watchDuration;
Swift
var watchDuration: Int { get }
-
用户总观看时长 (单位:秒;播放器暂停则不认为“观看”;包含连麦;包含无延迟观看)
Declaration
Objective-C
@property (nonatomic, readonly) NSInteger totalWatchDuration;
Swift
var totalWatchDuration: Int { get }
-
用户停留时长 (单位:秒)
Declaration
Objective-C
@property (nonatomic, readonly) NSInteger stayDuration;
Swift
var stayDuration: Int { get }
-
当前直播播放器 ‘加载状态’
Declaration
Objective-C
@property (nonatomic, readonly) PLVLivePlayerLoadState loadState;
Swift
var loadState: PLVLivePlayerLoadState { get }
-
当前频道的 ‘直播流状态’
Note
枚举类型详见 PLVLiveDefine.hDeclaration
Objective-C
@property (nonatomic, readonly) PLVChannelLiveStreamState currentStreamState;
Swift
var currentStreamState: PLVChannelLiveStreamState { get }
-
当前是否为 ‘音频模式’
Declaration
Objective-C
@property (nonatomic, readonly) BOOL audioMode;
Swift
var audioMode: Bool { get }
-
播放器是否正在播放暖场视频 (有别于 ’广告‘,详情可见PLV后台配置)
Declaration
Objective-C
@property (nonatomic, readonly) BOOL playingWarmUpVideo;
Swift
var playingWarmUpVideo: Bool { get }
-
播放器当前是否为无延迟观看模式(无延迟直播、快直播、公共流)
Declaration
Objective-C
@property (nonatomic, readonly) BOOL noDelayWatchMode;
Swift
var noDelayWatchMode: Bool { get }
-
播放器当前是否正在播放无延迟直播
Declaration
Objective-C
@property (nonatomic, readonly) BOOL noDelayLiveWatching;
Swift
var noDelayLiveWatching: Bool { get }
-
播放器当前是否正在播放快直播
Declaration
Objective-C
@property (nonatomic, readonly) BOOL quickLiveWatching;
Swift
var quickLiveWatching: Bool { get }
-
播放器当前是否正在播放公共流
Declaration
Objective-C
@property (nonatomic, readonly) BOOL publicStreamWatching;
Swift
var publicStreamWatching: Bool { get }
-
Deprecated
Please use initWithPLVAccountUserId:
创建 直播播放器
Note
创建后需调用父类方法 [setupDisplaySuperview:] 进行画面添加,才可正常显示播放内容
Declaration
Objective-C
- (nonnull instancetype) initWithPolyvAccountUserId:(nonnull NSString *)accountUserId channelId:(nonnull NSString *)channelId;
Swift
init(polyvAccountUserId accountUserId: String, channelId: String)
Parameters
accountUserId
PLV账户Id
channelId
频道号Id
-
Undocumented
Declaration
Objective-C
- (instancetype)initWithPLVAccountUserId:(NSString *)accountUserId channelId:(NSString *)channelId;
Swift
init(plvAccountUserId accountUserId: String, channelId: String)
-
重新加载直播 (或暂停后的恢复直播)
Declaration
Objective-C
- (void)reloadLivePlayer;
Swift
func reload()
-
切换 ’当前线路‘ 或 ’当前码率‘
Note
传入的 targetLineIndex、targetCodeRate 不一定就是最终的选定值。因为内部将判断传入值是否合法; 最终播放的选定值,可读取 channelInfo 的 currentLineIndex、currentDefinition 属性;
Declaration
Objective-C
- (void)switchToLineIndex:(NSInteger)targetLineIndex codeRate:(nonnull NSString *)targetCodeRate;
Swift
func `switch`(toLineIndex targetLineIndex: Int, codeRate targetCodeRate: String)
Parameters
targetLineIndex
目标线路 (由 0 起始;比如切至线路1,则传入 0)
targetCodeRate
目标码率/清晰度 (对应字符串,可在代理方法 [plvLivePlayer:codeRateOptions:currentCodeRate:lineNum:currentLineIndex:] 中取得)
-
开启或退出 音频模式
Declaration
Objective-C
- (void)switchToAudioMode:(BOOL)audioMode;
Swift
func `switch`(toAudioMode audioMode: Bool)
Parameters
audioMode
是否开启音频模式
-
开启或退出 无延迟观看模式
Note
该方法只支持无延迟、快直播、公共流频道(即 [channelWatchNoDelay]为YES时 、 [channelWatchQuickLive]为YES时或[channelWatchPublicStream]为YES时); 该方法将改变 [noDelayWatchMode] 值;
Declaration
Objective-C
- (void)switchToNoDelayWatchMode:(BOOL)noDelayWatchMode;
Swift
func `switch`(toNoDelayWatchMode noDelayWatchMode: Bool)
Parameters
noDelayWatchMode
是否开启无延迟观看模式