BBASMAudioFocusAdapterProtocol.h
2.63 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
//
// BBASMAudioFocusAdapterProtocol.h
// BBAMNP
//
// Created by baidu on 2019/8/21.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
typedef NS_ENUM(NSInteger, BBASMAppType) {
BBASMAppTypeSMWorkBox, // 小程序
BBASMAppTypeGame, // 小游戏
BBASMAppTypeUnKnown // 未知
};
typedef NS_OPTIONS(NSUInteger, BBASMAudioFocusStreamType) {
BBASMAudioFocusStreamTypeNone = 0,
BBASMAudioFocusStreamTypeInput = 1 << 1,
BBASMAudioFocusStreamTypeOutput = 1 << 2,
BBASMAudioFocusStreamTypeInputAndOutput = (BBASMAudioFocusStreamTypeInput | BBASMAudioFocusStreamTypeOutput),
BBASMAudioFocusStreamTypeOutputOptionUsingSingletonTTSPlayer __attribute__((deprecated("当前TTSPlayer为单例播放器,严重依赖业务层通知去打断,后续优化"))) = 1 << 3,
};
typedef NS_ENUM(NSInteger, BBASMAudioFocusGainType) {
// Used to indicate a request of audio focus, of unknown duration.
BBASMAudioFocusGain = 1,
// Used to indicate a temporary gain or request of audio focus, anticipated to last a short amount of time. Examples of temporary changes are the playback of driving directions, or an event notification.
BBASMAudioFocusGainTransient = 2,
};
typedef NS_ENUM(NSUInteger, BBASMAudioFocusRequestResult) {
// A successful focus change request.
BBASMAudioFocusRequestGranted,
// A failed focus change request.
BBASMAudioFocusRequestFailed,
// A focus change request whose granting is delayed: the request was successful, but the requester will only be granted audio focus once the condition that prevented immediate granting has ended.
BBASMAudioFocusRequestDelayed,
};
/**
* private(手百私有方法):小程序使用手百音乐插件及音频统一管理
*/
@protocol BBASMAudioFocusAdapterProtocol <NSObject>
#pragma mark - AudioFocus
+ (instancetype)sharedInstance;
/**
* @brief 申请AudioFocus
*
* @param focusGain focusGainType
* @param streamType streamType
* @param appType appType
* @param audioFocusLossedBlock 音频焦点变化回调
* @return 申请成功与否
*/
- (BBASMAudioFocusRequestResult)requestAudioFocusWithFocusGainType:(BBASMAudioFocusGainType)focusGain
streamType:(BBASMAudioFocusStreamType)streamType
appType:(BBASMAppType)appType
audioFocusLossedBlock:(void (^)(BOOL focusLossed))audioFocusLossedBlock;
/**
* @brief 移除AudioFocus
*/
- (void)abandonAudioFocus;
@end
NS_ASSUME_NONNULL_END