提交 1e28cabf authored 作者: kongdywang's avatar kongdywang

fix bug about volume and live

上级 a3fbe87c
......@@ -81,15 +81,16 @@ class _DemoTXLivelayerState extends State<DemoTXLivePlayer> with WidgetsBindingO
await SuperPlayerPlugin.setConsoleEnabled(true);
await _controller.initialize();
await _controller.setConfig(FTXLivePlayConfig());
// 安卓需要设置hls格式才可正常播放
await _controller.play(_url, playType: TXPlayType.LIVE_FLV);
await _controller.startPlay(_url, playType: TXPlayType.LIVE_FLV);
}
@override
void initState() {
super.initState();
init();
WidgetsBinding.instance?.addObserver(this);
WidgetsBinding.instance.addObserver(this);
EasyLoading.show(status: 'loading...');
}
......@@ -207,7 +208,7 @@ class _DemoTXLivelayerState extends State<DemoTXLivePlayer> with WidgetsBindingO
),
new GestureDetector(
onTap: () async {
_controller.play(_url, playType: TXPlayType.LIVE_FLV);
_controller.startPlay(_url, playType: TXPlayType.LIVE_FLV);
},
child: Container(
color: Colors.transparent,
......@@ -290,7 +291,7 @@ class _DemoTXLivelayerState extends State<DemoTXLivePlayer> with WidgetsBindingO
playNetEventSubscription?.cancel();
_controller.dispose();
super.dispose();
WidgetsBinding.instance?.removeObserver(this);
WidgetsBinding.instance.removeObserver(this);
EasyLoading.dismiss();
}
......@@ -302,7 +303,7 @@ class _DemoTXLivelayerState extends State<DemoTXLivePlayer> with WidgetsBindingO
_url = url;
_controller.stop();
if (url.isNotEmpty) {
_controller.play(url);
_controller.startPlay(url);
}
}, showFileEdited: false);
});
......
......@@ -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
{
......
......@@ -4,7 +4,7 @@
@implementation FTXTransformation
+ (TXVodPlayConfig *)transformToConfig:(NSDictionary *)args
+ (TXVodPlayConfig *)transformToVodConfig:(NSDictionary *)args
{
TXVodPlayConfig *playConfig = [[TXVodPlayConfig alloc] init];
playConfig.connectRetryCount = [args[@"config"][@"connectRetryCount"] intValue];
......@@ -48,6 +48,29 @@
return playConfig;
}
+ (TXLivePlayConfig *)transformToLiveConfig:(NSDictionary *)args
{
TXLivePlayConfig *playConfig = [[TXLivePlayConfig alloc] init];
playConfig.cacheTime = [args[@"config"][@"cacheTime"] floatValue];
playConfig.maxAutoAdjustCacheTime = [args[@"config"][@"maxAutoAdjustCacheTime"] floatValue];
playConfig.minAutoAdjustCacheTime = [args[@"config"][@"minAutoAdjustCacheTime"] floatValue];
playConfig.videoBlockThreshold = [args[@"config"][@"videoBlockThreshold"] intValue];
playConfig.connectRetryCount = [args[@"config"][@"connectRetryCount"] intValue];
playConfig.connectRetryInterval = [args[@"config"][@"connectRetryInterval"] intValue];
playConfig.bAutoAdjustCacheTime = [args[@"config"][@"autoAdjustCacheTime"] boolValue];
playConfig.enableAEC = [args[@"config"][@"enableAec"] boolValue];
playConfig.enableMessage = [args[@"config"][@"enableMessage"] intValue];
playConfig.enableMetaData = [args[@"config"][@"enableMetaData"] intValue];
NSString *flvSessionKey = args[@"config"][@"flvSessionKey"];
if(flvSessionKey != nil && flvSessionKey.length > 0) {
playConfig.flvSessionKey = flvSessionKey;
}
return playConfig;
}
@end
......@@ -5,8 +5,9 @@
#import "FTXTransformation.h"
#import "FTXPlayerEventSinkQueue.h"
#import "FTXEvent.h"
#import "FTXAudioManager.h"
#import <MediaPlayer/MediaPlayer.h>
#import <TXLiteAVSDK_Player/TXLiteAVSDK.h>
#import "FTXAudioManager.h"
#import "FTXDownloadManager.h"
@interface SuperPlayerPlugin ()<FlutterStreamHandler,FTXVodPlayerDelegate>
......@@ -64,10 +65,9 @@ SuperPlayerPlugin* instance;
_eventChannel = [FlutterEventChannel eventChannelWithName:@"cloud.tencent.com/playerPlugin/event" binaryMessenger:[registrar messenger]];
_pipEventChannel = [FlutterEventChannel eventChannelWithName:@"cloud.tencent.com/playerPlugin/pipEvent" binaryMessenger:[registrar messenger]];
[_eventChannel setStreamHandler:self];
[audioManager registerVolumeChangeListener:self selector:@selector(systemVolumeDidChangeNoti:) name:@"AVSystemController_SystemVolumeDidChangeNotification" object:nil];
// pip
[_pipEventChannel setStreamHandler:self];
// download
[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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论