|
@@ -10,7 +10,9 @@
|
|
|
#import "webRtcPlayerBottomContrView.h"
|
|
|
|
|
|
@interface webRtcPlayerViewController ()<MediaStreamClientEventsDelegate>
|
|
|
-
|
|
|
+{
|
|
|
+ BOOL outputVolumeKVO;/*标记声音监听通知*/
|
|
|
+}
|
|
|
@property (nonatomic, copy) NSTimer *playerSecondTimer; // 定时器-控制按钮
|
|
|
@property (nonatomic, assign) NSInteger concentTime; // 拉流数据 渲染更新时间戳 /**30s后 渲染时间戳无更新 自动断开链接*/
|
|
|
@property(nonatomic,strong)webRtcPlayerBottomContrView *bottomContrView;//底部按钮 选项 home 返回
|
|
@@ -43,6 +45,7 @@
|
|
|
{
|
|
|
[super viewDidAppear:animated];
|
|
|
[self noEnablePanRightBack];
|
|
|
+ [self addKVOObserverFun];
|
|
|
}
|
|
|
|
|
|
- (void)viewDidDisappear:(BOOL)animated{
|
|
@@ -50,6 +53,7 @@
|
|
|
|
|
|
[_mediaStream disconnect];
|
|
|
[self enablePanRightBack];
|
|
|
+ [self removeKVOObserverFun];
|
|
|
}
|
|
|
|
|
|
- (void)setWebRtcMsgMod:(webRtcMsgModel *)webRtcMsgMod
|
|
@@ -216,7 +220,45 @@
|
|
|
[_mediaStream sendKey:keyType];
|
|
|
}
|
|
|
|
|
|
+#pragma mark -- /*通知添加与移除*/
|
|
|
+- (void)addKVOObserverFun
|
|
|
+{
|
|
|
+ outputVolumeKVO = YES;
|
|
|
+ [[AVAudioSession sharedInstance] addObserver:self forKeyPath:@"outputVolume" options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context:(void *)[AVAudioSession sharedInstance]];
|
|
|
+
|
|
|
+}
|
|
|
|
|
|
+- (void)removeKVOObserverFun
|
|
|
+{
|
|
|
+ if (outputVolumeKVO)
|
|
|
+ {
|
|
|
+ [[AVAudioSession sharedInstance] removeObserver:self forKeyPath:@"outputVolume" context:(void *)[AVAudioSession sharedInstance]];
|
|
|
+ outputVolumeKVO = NO;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+#pragma mark 系统音量键监听
|
|
|
+- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context{
|
|
|
+
|
|
|
+ if(context == (__bridge void *)[AVAudioSession sharedInstance])
|
|
|
+ {
|
|
|
+ /*音量开关打开时 允许发送指令 否则直接返回*/
|
|
|
+ float newValue = [[change objectForKey:@"new"] floatValue];
|
|
|
+ float oldValue = [[change objectForKey:@"old"] floatValue];
|
|
|
+ //HLog(@"音量 --old: %f ---new: %f",oldValue,newValue)
|
|
|
+ if (newValue > oldValue)
|
|
|
+ {
|
|
|
+ HLog(@"\n-----音量增加");
|
|
|
+ [self didClickKeyEventFunBy:24];
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ HLog(@"\n-----音量降低");
|
|
|
+ [self didClickKeyEventFunBy:25];
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
#pragma mark WebRTC 回调 MediaStreamClientEventsDelegate
|
|
|
#pragma mark - 宽高变化
|