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

fix bug about volume and live

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