BBASMVideoHandleDelegate.h
6.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
//
// BBASMVideoHandleDelegate.h
// SWAN
//
// Created by baidu on 2018/9/27.
// Copyright © 2018年 baidu. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
typedef NS_ENUM(NSInteger, BBASMPlayerBarrageComponent) {
BBASMPlayerBarrageComponent_Unknown = 0,
BBASMPlayerBarrageComponent_Switch, // 弹幕开关
BBASMPlayerBarrageComponent_Displayer, // 弹幕展示组件
BBASMPlayerBarrageComponent_Publisher, // 弹幕发布组件
};
/**
* @brief 播放器类型:
*
*/
typedef enum : NSUInteger {
BBASMPlayerModeFull = 1, //全屏
BBASMPlayerModeMini = 2, //小窗播放器,内置maxsize及minsize
BBASMPlayerModeCustom = 3, //自定义大小,页内播放
BBASMPlayerModeNone = 0 //当前没有定义播放器
} BBASMPlayerMode;
/**
* @brief 视频播放状态
*/
typedef NS_ENUM(NSInteger, BBASMPlayerStatus) {
BBASMPlayerStatusUnknown = 0,
BBASMPlayerStatusLoading,
BBASMPlayerStatusPlaying,
BBASMPlayerStatusPaused,
BBASMPlayerStatusCompleted,
BBASMPlayerStatusClosed,
BBASMPlayerStatusPlayFailed,
BBASMPlayerStatusNonWifiTip,
BBASMPlayerStatusPostVideoAD,
BBASMPlayerStatusAdTailFrame
};
typedef NS_ENUM(NSInteger, BBASMPlayerFullScreenDirection) {
BBASMPlayerFullScreenDirection_None = 0, // 默认随系统方向转屏
BBASMPlayerFullScreenDirection_0, // 竖全屏
BBASMPlayerFullScreenDirection_90, // 顺时针90度
BBASMPlayerFullScreenDirection_Ne90, // 逆时针90度
BBASMPlayerFullScreenDirection_180, // 顺时针180度(暂不支持)
};
@protocol BBASMVideoHandleDelegate <NSObject>
// 获取视频元数据回调
- (void)playerLoadMetadata:(NSDictionary *)metadata
videoId:(NSString *)videoId;
// 加载元视频失败回调
- (void)playerLoadMetadataFail:(NSString *)errMsg
videoId:(NSString *)videoId;
// 当播放器开始缓冲 事件回调
- (void)playerBufferEmpty:(NSString *)videoId;
// 当开始/继续播放时触发play事件回调
- (void)playerDidPlay:(NSString *)videoId;
// 播放器播放成功回调
- (void)playerDidPlaySuccess:(NSString *)videoId;
// 当播放到末尾时触发 ended 事件回调
- (void)playerDidPause:(NSString *)videoId;
// 当播放到末尾时触发 ended 事件回调
- (void)playerDidEnd:(NSString *)videoId;
// 播放器转屏回调
- (void)playerScreenChangeToNewMode:(BBASMPlayerMode)newMode
oldModel:(BBASMPlayerMode)oldModel
videoId:(NSString *)videoId
frame:(CGRect)newFrame;
// 弹幕开关状态更改回调
- (void)playerBarrageBtnChange:(BOOL)barrageBtnEnabled videoId:(NSString *)videoId;
//player更新播放进度
- (void)videoPlayerUpdateTimeProgress:(double)currentTime
duration:(double)duration
videoId:(NSString *)videoId;
/**
全屏下播放器发送弹幕回调
@param content 输入的内容
@param playAtTime 发送的时间
*/
- (void)playerSendBarrage:(NSString *)content
playAtTime:(NSString *)playAtTime
videoId:(NSString *)videoId;
///小程序播放器是否安装弹幕组件
- (BOOL)playerShouldShowBarrageComponent:(BBASMPlayerBarrageComponent)cmp
withPlayerMode:(BBASMPlayerMode)playerMode;
// 播放器弹幕是否需要根据视频播放进度从服务端动态拉取弹幕数据
- (BOOL)isNeedUpdateBarrageListFromServer;
/// 是否需要在点击发送按钮后清除草稿(无论弹幕发送成功与否)
- (BOOL)isNeedClearDraftAfterSendClick;
/// 播放器视图被添加到父视图
- (void)playerViewDidAddedToSurperView:(UIView *)playerView vid:(NSString *)vid;
/// 播放器视图从父视图里移除.
- (void)playerViewDidRemovedFromSurperView:(UIView *)playerView vid:(NSString *)vid;
/// 播放器delegate将要改变
- (void)playerDelegateWillChanged:(id<BBASMVideoHandleDelegate>)newDelegate vid:(NSString *)vid;
///播放器 vid将要改变
- (void)playerVidWillChanged:(NSString *)oldVid;
/**
* @brief 全屏按钮点击是否由小程序框架控制半屏 全屏切换逻辑
*
* @return YES 小程序框架控制
*/
- (BOOL)isPlayerCustomSwitchToFullScreenMode;
/**
* @brief 进入全屏事件
* @param isUserTransformPlayer 点击页面上的全屏按钮触发video转屏,videoId video唯一标识,customEnterExitFullScreen 开发者是否自定义转屏模式
*/
- (void)playerCustomSwitchToFullScreenMode:(BOOL)isUserTransformPlayer videoId:(NSString *)videoId isCustomEnterExitFullScreen:(BOOL)customEnterExitFullScreen;
/**
* @brief 退出全屏事件
* @param isUserTransformPlayer 点击页面上的全屏按钮触发video转屏,videoId video唯一标识,customEnterExitFullScreen 开发者是否自定义转屏模式
*/
- (void)playerExitCustomFullScreenMode:(BOOL)isUserTransformPlayer videoId:(NSString *)videoId isCustomEnterExitFullScreen:(BOOL)customEnterExitFullScreen;
/**
* @brief 播放器是否可以根据屏幕方向 切换半屏 全屏
*
* @return YES 自动切换
*/
- (BOOL)playerShouldAutorotate;
/**
* @brief 小程序播放器静音状态更改事件回调
* @param muted 当前静音状态
* @param videoId video唯一标识
*/
- (void)playerChangeMutedStatus:(BOOL)muted videoId:(NSString *)videoId;
/// 切换横竖全屏模式事件回调
/// @param direction 当前全屏的方向
/// @param videoId video唯一标识
- (void)toggleFullscreenMode:(NSString *)direction videoId:(NSString *)videoId;
// Generally, all responders which do custom touch handling should override all four of these methods.
// Your responder will receive either touchesEnded:withEvent: or touchesCancelled:withEvent: for each
// touch it is handling (those touches it received in touchesBegan:withEvent:).
// *** You must handle cancelled touches to ensure correct behavior in your application. Failure to
// do so is very likely to lead to incorrect behavior or crashes.
- (void)videoPlayerGestureView:(UIView *)gestureView
touchesBegan:(NSSet<UITouch *> *)touches
event:(UIEvent *)event;
- (void)videoPlayerGestureView:(UIView *)gestureView
touchesMoved:(NSSet<UITouch *> *)touches
event:(UIEvent *)event;
- (void)videoPlayerGestureView:(UIView *)gestureView
touchesEnded:(NSSet<UITouch *> *)touches
event:(UIEvent *)event;
- (void)videoPlayerGestureView:(UIView *)gestureView
touchesCancelled:(NSSet<UITouch *> *)touches
event:(UIEvent *)event;
@end