提交 01c1909d authored 作者: kongdywang's avatar kongdywang

fix bug about volume and live

上级 efb9316d
...@@ -12,10 +12,8 @@ ...@@ -12,10 +12,8 @@
- (void)setVolumeUIVisible:(BOOL)volumeUIVisible; - (void)setVolumeUIVisible:(BOOL)volumeUIVisible;
- (void)registerVolumeChangeListener:(_Nonnull id)observer selector:(_Nonnull SEL)aSelector - (void)registerVolumeChangeListener:(_Nonnull id)observer;
name:(nullable NSNotificationName)aName object:(nullable id)anObject;
- (void)destory:(_Nonnull id)observer name:(nullable NSNotificationName)aName - (void)destory:(_Nonnull id)observer;
object:(nullable id)anObject;
@end @end
...@@ -5,7 +5,10 @@ ...@@ -5,7 +5,10 @@
@implementation FTXAudioManager @implementation FTXAudioManager
UISlider *_volumeSlider; UISlider *_volumeSlider;
MPVolumeView *volumeView; MPVolumeView *volumeView;
AVAudioSession *audioSession;
NSString *const LOW_VERSION_NOTIFCATION_NAME = @"AVSystemController_SystemVolumeDidChangeNotification";
NSString *const NOTIFCATION_NAME = @"SystemVolumeDidChange";
- (instancetype)init - (instancetype)init
{ {
...@@ -24,6 +27,9 @@ ...@@ -24,6 +27,9 @@
break; break;
} }
} }
audioSession = [AVAudioSession sharedInstance];
[audioSession setActive:true error:nil];
} }
return self; return self;
}; };
...@@ -48,17 +54,18 @@ ...@@ -48,17 +54,18 @@
volumeView.hidden = !volumeUIVisible; volumeView.hidden = !volumeUIVisible;
} }
- (void)registerVolumeChangeListener:(id)observer selector:(SEL)aSelector name:(NSNotificationName)aName object:(id)anObject - (void)registerVolumeChangeListener:(id)observer
{ {
[[NSNotificationCenter defaultCenter] addObserver:observer selector:aSelector name:aName object:anObject]; // destory volume observer
[audioSession addObserver:observer forKeyPath:@"outputVolume" options: NSKeyValueObservingOptionNew|NSKeyValueObservingOptionOld context:nil];
} }
- (void)destory:(id)observer name:(NSNotificationName)aName object:(id)anObject - (void)destory:(id)observer
{ {
// destory volume view // destory volume view
[volumeView removeFromSuperview]; [volumeView removeFromSuperview];
// destory volume observer // destory volume observer
[[NSNotificationCenter defaultCenter] removeObserver:observer name:aName object:anObject]; [audioSession removeObserver:observer forKeyPath:@"outputVolume" context:nil];
} }
@end @end
...@@ -62,7 +62,11 @@ ...@@ -62,7 +62,11 @@
playConfig.enableAEC = [args[@"config"][@"enableAec"] boolValue]; playConfig.enableAEC = [args[@"config"][@"enableAec"] boolValue];
playConfig.enableMessage = [args[@"config"][@"enableMessage"] intValue]; playConfig.enableMessage = [args[@"config"][@"enableMessage"] intValue];
playConfig.enableMetaData = [args[@"config"][@"enableMetaData"] intValue]; playConfig.enableMetaData = [args[@"config"][@"enableMetaData"] intValue];
playConfig.flvSessionKey = [args[@"config"][@"flvSessionKey"] stringValue]; NSString *flvSessionKey = args[@"config"][@"flvSessionKey"];
if(flvSessionKey != nil && flvSessionKey.length > 0) {
playConfig.flvSessionKey = flvSessionKey;
}
return playConfig; return playConfig;
} }
......
...@@ -67,7 +67,7 @@ SuperPlayerPlugin* instance; ...@@ -67,7 +67,7 @@ SuperPlayerPlugin* instance;
[_eventChannel setStreamHandler:self]; [_eventChannel setStreamHandler:self];
[_pipEventChannel setStreamHandler:self]; [_pipEventChannel setStreamHandler:self];
[audioManager registerVolumeChangeListener:self selector:@selector(systemVolumeDidChangeNoti:) name:@"AVSystemController_SystemVolumeDidChangeNotification" object:nil]; [audioManager registerVolumeChangeListener:self];
_FTXDownloadManager = [[FTXDownloadManager alloc] initWithRegistrar:registrar]; _FTXDownloadManager = [[FTXDownloadManager alloc] initWithRegistrar:registrar];
// orientation // orientation
mCurrentOrientation = ORIENTATION_PORTRAIT_UP; mCurrentOrientation = ORIENTATION_PORTRAIT_UP;
...@@ -79,7 +79,8 @@ SuperPlayerPlugin* instance; ...@@ -79,7 +79,8 @@ SuperPlayerPlugin* instance;
return self; return self;
} }
-(void)systemVolumeDidChangeNoti:(NSNotification* )noti{ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSKeyValueChangeKey,id> *)change context:(void *)context
{
[_eventSink success:[SuperPlayerPlugin getParamsWithEvent:EVENT_VOLUME_CHANGED withParams:@{}]]; [_eventSink success:[SuperPlayerPlugin getParamsWithEvent:EVENT_VOLUME_CHANGED withParams:@{}]];
} }
...@@ -207,7 +208,7 @@ SuperPlayerPlugin* instance; ...@@ -207,7 +208,7 @@ SuperPlayerPlugin* instance;
-(void) destory -(void) destory
{ {
[audioManager destory:self name:@"AVSystemController_SystemVolumeDidChangeNotification" object:nil]; [audioManager destory:self];
} }
#pragma mark - FlutterStreamHandler #pragma mark - FlutterStreamHandler
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论