TencentNavKit

TNKAudioPlayerProtocol.h
Go to the documentation of this file.
1//
2// TNKAudioPlayerProtocol.h
3// TencentNavKit
4//
5// Created by mol on 2022/11/18.
6// Copyright © 2022 Tencent. All rights reserved.
7//
8
9#import <Foundation/Foundation.h>
10#import <TencentNavKit/TNKNavTTS.h>
11
12NS_ASSUME_NONNULL_BEGIN
13
14// 前置声明音频焦点策略枚举(在TNKAudioPlayer模块中定义)
15 typedef NS_ENUM(NSInteger, TNKAudioFocusPolicy);
16
17 typedef NS_ENUM(NSUInteger, TNKAudioPlayRateType) {
18 TNKAudioPlayRateNormal,
19 TNKAudioPlayRateFast,
20 TNKAudioPlayRateSlow
21};
22
23@class TNKAudioParam;
24@protocol TNKAudioPlayerProtocol;
25
29@protocol TNKAudioPlayerDelegate <NSObject>
30
35- (void)invokeAudioPlayerWillStartPlaying:(id<TNKAudioPlayerProtocol>)player;
36
41- (void)audioPlayerDidFinishPlaying:(id<TNKAudioPlayerProtocol>)player;
42
49- (void)audioPlayerDidFinishPlaying:(id<TNKAudioPlayerProtocol>)player text:(NSString *)text successfully:(BOOL)flag;
50
51@end
52
56@protocol TNKAudioPlayerProtocol <NSObject>
57
61@property (nonatomic, weak) id <TNKAudioPlayerDelegate> delegate;
62
66@property (nonatomic, readonly) BOOL isPlaying;
67
72@property (nonatomic, assign) float volume;
73
78@property (nonatomic, assign) int rate;
79
84- (void)playWithRate:(TNKAudioPlayRateType)type;
85
90- (void)playWithAudioParam:(TNKAudioParam *)audioParam;
91
96- (void)playWithNaviTTS:(TNKNavTTS *)naviTTS;
97
101- (void)stop;
102
106- (BOOL)stateInterruption;
107
111- (void)mutePlayer;
112
116- (void)unmutePlayer;
117
121- (BOOL)isPlayerMute;
122
123@optional
124
129- (void)setAudioFocusPolicy:(TNKAudioFocusPolicy)policy;
130
131@end
132
134@interface TNKAudioParam : NSObject
135
139@property (nonatomic, copy) NSString *text;
140
144@property (nonatomic, assign) int playOption;
145
146
147@end
148
149NS_ASSUME_NONNULL_END
NS_ENUM
NS_ASSUME_NONNULL_BEGIN typedef NS_ENUM(NSInteger, TNKAudioFocusPolicy)
TNKAudioParam
播报信息.
Definition: TNKAudioPlayerProtocol.h:135
TNKAudioParam::playOption
int playOption
播报策略。0为打断当前正在播报的内容，并播报改内容；1为排队，当前播报完毕后播报该内容
Definition: TNKAudioPlayerProtocol.h:144
TNKAudioParam::text
NSString * text
播报内容
Definition: TNKAudioPlayerProtocol.h:139
TNKAudioPlayerDelegate-p
内置语音播报器事件回调.
Definition: TNKAudioPlayerProtocol.h:29
TNKAudioPlayerProtocol-p
语音播报器协议
Definition: TNKAudioPlayerProtocol.h:56
-[TNKAudioPlayerProtocol-p unmutePlayer]
void unmutePlayer()
解除静音.
-[TNKAudioPlayerProtocol-p isPlayerMute]
BOOL isPlayerMute()
当前是否静音.
TNKAudioPlayerProtocol-p::isPlaying
BOOL isPlaying
语音播报器是否在播放状态.
Definition: TNKAudioPlayerProtocol.h:66
TNKAudioPlayerProtocol-p::delegate
id< TNKAudioPlayerDelegate > delegate
TNKAudioPlayer的回调. 用于接收播报状态等事件.
Definition: TNKAudioPlayerProtocol.h:61
-[TNKAudioPlayerProtocol-p stateInterruption]
BOOL stateInterruption()
当前播报中断态.
-[TNKAudioPlayerProtocol-p mutePlayer]
void mutePlayer()
设置成静音.
-[TNKAudioPlayerProtocol-p stop]
void stop()
停止当前播报内容.
TNKAudioPlayerProtocol-p::rate
int rate
控制语音播报速度，请在开始播报之前设置完成设置范围[20, 100],默认是50是正常速度（不设置该属性默认也是正常速度），最大支持100是双倍速度
Definition: TNKAudioPlayerProtocol.h:78
TNKAudioPlayerProtocol-p::volume
float volume
控制音量，设置范围[0, 1]T
Definition: TNKAudioPlayerProtocol.h:72