提交 c82b27d5 authored 作者: kongdywang's avatar kongdywang

1. The SuperPlayerPlugin has added setUserId and setLicenseFlexibleValid interfaces.

2. Fixed an issue where several buttons in the demo layer did not respond to clicks on newer Flutter versions.
上级 ae23cf02
...@@ -339,6 +339,18 @@ public class SuperPlayerPlugin implements FlutterPlugin, ActivityAware, ...@@ -339,6 +339,18 @@ public class SuperPlayerPlugin implements FlutterPlugin, ActivityAware,
return boolMsg; return boolMsg;
} }
@Override
public void setUserId(@NonNull StringMsg msg) {
TXLiveBase.setUserId(msg.getValue());
}
@Override
public void setLicenseFlexibleValid(@NonNull BoolMsg msg) {
if (null != msg.getValue()) {
TXPlayerGlobalSetting.setLicenseFlexibleValid(msg.getValue());
}
}
/******* native method call end *******/ /******* native method call end *******/
......
...@@ -3387,6 +3387,10 @@ public class FtxMessages { ...@@ -3387,6 +3387,10 @@ public class FtxMessages {
@NonNull @NonNull
BoolMsg startVideoOrientationService(); BoolMsg startVideoOrientationService();
void setUserId(@NonNull StringMsg msg);
void setLicenseFlexibleValid(@NonNull BoolMsg msg);
/** The codec used by TXFlutterSuperPlayerPluginAPI. */ /** The codec used by TXFlutterSuperPlayerPluginAPI. */
static @NonNull MessageCodec<Object> getCodec() { static @NonNull MessageCodec<Object> getCodec() {
return TXFlutterSuperPlayerPluginAPICodec.INSTANCE; return TXFlutterSuperPlayerPluginAPICodec.INSTANCE;
...@@ -3685,6 +3689,54 @@ public class FtxMessages { ...@@ -3685,6 +3689,54 @@ public class FtxMessages {
BoolMsg output = api.startVideoOrientationService(); BoolMsg output = api.startVideoOrientationService();
wrapped.add(0, output); wrapped.add(0, output);
} }
catch (Throwable exception) {
ArrayList<Object> wrappedError = wrapError(exception);
wrapped = wrappedError;
}
reply.reply(wrapped);
});
} else {
channel.setMessageHandler(null);
}
}
{
BasicMessageChannel<Object> channel =
new BasicMessageChannel<>(
binaryMessenger, "dev.flutter.pigeon.TXFlutterSuperPlayerPluginAPI.setUserId", getCodec());
if (api != null) {
channel.setMessageHandler(
(message, reply) -> {
ArrayList<Object> wrapped = new ArrayList<Object>();
ArrayList<Object> args = (ArrayList<Object>) message;
StringMsg msgArg = (StringMsg) args.get(0);
try {
api.setUserId(msgArg);
wrapped.add(0, null);
}
catch (Throwable exception) {
ArrayList<Object> wrappedError = wrapError(exception);
wrapped = wrappedError;
}
reply.reply(wrapped);
});
} else {
channel.setMessageHandler(null);
}
}
{
BasicMessageChannel<Object> channel =
new BasicMessageChannel<>(
binaryMessenger, "dev.flutter.pigeon.TXFlutterSuperPlayerPluginAPI.setLicenseFlexibleValid", getCodec());
if (api != null) {
channel.setMessageHandler(
(message, reply) -> {
ArrayList<Object> wrapped = new ArrayList<Object>();
ArrayList<Object> args = (ArrayList<Object>) message;
BoolMsg msgArg = (BoolMsg) args.get(0);
try {
api.setLicenseFlexibleValid(msgArg);
wrapped.add(0, null);
}
catch (Throwable exception) { catch (Throwable exception) {
ArrayList<Object> wrappedError = wrapError(exception); ArrayList<Object> wrappedError = wrapError(exception);
wrapped = wrappedError; wrapped = wrappedError;
......
...@@ -25,14 +25,14 @@ apply plugin: 'com.android.application' ...@@ -25,14 +25,14 @@ apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android { android {
compileSdkVersion 33 compileSdk 34
namespace="com.example.flutter.player" namespace="com.example.flutter.player"
defaultConfig { defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.tencent.liteav.demo" applicationId "com.tencent.liteav.demo"
minSdkVersion 19 minSdkVersion 19
targetSdkVersion 33 targetSdk 33
versionCode flutterVersionCode.toInteger() versionCode flutterVersionCode.toInteger()
versionName flutterVersionName versionName flutterVersionName
} }
......
...@@ -204,7 +204,9 @@ class _DemoTXLivelayerState extends State<DemoTXLivePlayer> with WidgetsBindingO ...@@ -204,7 +204,9 @@ class _DemoTXLivelayerState extends State<DemoTXLivePlayer> with WidgetsBindingO
_controller.setMute(_isMute); _controller.setMute(_isMute);
}); });
}), }),
_createItem(AppLocals.current.playerAdjustVolume, () => onClickVolume), _createItem(AppLocals.current.playerAdjustVolume, () {
onClickVolume();
}),
], ],
)), )),
Expanded( Expanded(
......
...@@ -195,12 +195,12 @@ class _DemoTXVodPlayerState extends State<DemoTXVodPlayer> with WidgetsBindingOb ...@@ -195,12 +195,12 @@ class _DemoTXVodPlayerState extends State<DemoTXVodPlayer> with WidgetsBindingOb
_isPlaying = false; _isPlaying = false;
_controller.pause(); _controller.pause();
}), }),
_createItem(AppLocals.current.playerVariableSpeedPlay, () => onClickSetRate), _createItem(AppLocals.current.playerVariableSpeedPlay, () {onClickSetRate();}),
_createItem(_isMute ? AppLocals.current.playerCancelMute : AppLocals.current.playerSetMute, () { _createItem(_isMute ? AppLocals.current.playerCancelMute : AppLocals.current.playerSetMute, () {
_isMute = !_isMute; _isMute = !_isMute;
_controller.setMute(_isMute); _controller.setMute(_isMute);
}), }),
_createItem(AppLocals.current.playerAdjustVolume, () => onClickVolume), _createItem(AppLocals.current.playerAdjustVolume, () {onClickVolume();}),
_createItem(AppLocals.current.playerSwitchBitrate, () { _createItem(AppLocals.current.playerSwitchBitrate, () {
if (_supportedBitrates.length > 1) { if (_supportedBitrates.length > 1) {
onClickBitrate(); onClickBitrate();
......
...@@ -335,6 +335,14 @@ SuperPlayerPlugin* instance; ...@@ -335,6 +335,14 @@ SuperPlayerPlugin* instance;
return [TXCommonUtil boolMsgWith:YES]; return [TXCommonUtil boolMsgWith:YES];
} }
- (void)setUserIdMsg:(StringMsg *)msg error:(FlutterError * _Nullable __autoreleasing *)error {
[TXLiveBase setUserId:msg.value];
}
- (void)setLicenseFlexibleValidMsg:(BoolMsg *)msg error:(FlutterError * _Nullable __autoreleasing *)error {
[TXPlayerGlobalSetting setLicenseFlexibleValid:msg.value];
}
#pragma mark nativeAPI #pragma mark nativeAPI
- (void)abandonAudioFocusWithError:(FlutterError * _Nullable __autoreleasing * _Nonnull)error { - (void)abandonAudioFocusWithError:(FlutterError * _Nullable __autoreleasing * _Nonnull)error {
......
...@@ -465,6 +465,8 @@ NSObject<FlutterMessageCodec> *TXFlutterSuperPlayerPluginAPIGetCodec(void); ...@@ -465,6 +465,8 @@ NSObject<FlutterMessageCodec> *TXFlutterSuperPlayerPluginAPIGetCodec(void);
/// ///
/// @return `nil` only when `error != nil`. /// @return `nil` only when `error != nil`.
- (nullable BoolMsg *)startVideoOrientationServiceWithError:(FlutterError *_Nullable *_Nonnull)error; - (nullable BoolMsg *)startVideoOrientationServiceWithError:(FlutterError *_Nullable *_Nonnull)error;
- (void)setUserIdMsg:(StringMsg *)msg error:(FlutterError *_Nullable *_Nonnull)error;
- (void)setLicenseFlexibleValidMsg:(BoolMsg *)msg error:(FlutterError *_Nullable *_Nonnull)error;
@end @end
extern void TXFlutterSuperPlayerPluginAPISetup(id<FlutterBinaryMessenger> binaryMessenger, NSObject<TXFlutterSuperPlayerPluginAPI> *_Nullable api); extern void TXFlutterSuperPlayerPluginAPISetup(id<FlutterBinaryMessenger> binaryMessenger, NSObject<TXFlutterSuperPlayerPluginAPI> *_Nullable api);
......
...@@ -1500,6 +1500,44 @@ void TXFlutterSuperPlayerPluginAPISetup(id<FlutterBinaryMessenger> binaryMesseng ...@@ -1500,6 +1500,44 @@ void TXFlutterSuperPlayerPluginAPISetup(id<FlutterBinaryMessenger> binaryMesseng
[channel setMessageHandler:nil]; [channel setMessageHandler:nil];
} }
} }
{
FlutterBasicMessageChannel *channel =
[[FlutterBasicMessageChannel alloc]
initWithName:@"dev.flutter.pigeon.TXFlutterSuperPlayerPluginAPI.setUserId"
binaryMessenger:binaryMessenger
codec:TXFlutterSuperPlayerPluginAPIGetCodec()];
if (api) {
NSCAssert([api respondsToSelector:@selector(setUserIdMsg:error:)], @"TXFlutterSuperPlayerPluginAPI api (%@) doesn't respond to @selector(setUserIdMsg:error:)", api);
[channel setMessageHandler:^(id _Nullable message, FlutterReply callback) {
NSArray *args = message;
StringMsg *arg_msg = GetNullableObjectAtIndex(args, 0);
FlutterError *error;
[api setUserIdMsg:arg_msg error:&error];
callback(wrapResult(nil, error));
}];
} else {
[channel setMessageHandler:nil];
}
}
{
FlutterBasicMessageChannel *channel =
[[FlutterBasicMessageChannel alloc]
initWithName:@"dev.flutter.pigeon.TXFlutterSuperPlayerPluginAPI.setLicenseFlexibleValid"
binaryMessenger:binaryMessenger
codec:TXFlutterSuperPlayerPluginAPIGetCodec()];
if (api) {
NSCAssert([api respondsToSelector:@selector(setLicenseFlexibleValidMsg:error:)], @"TXFlutterSuperPlayerPluginAPI api (%@) doesn't respond to @selector(setLicenseFlexibleValidMsg:error:)", api);
[channel setMessageHandler:^(id _Nullable message, FlutterReply callback) {
NSArray *args = message;
BoolMsg *arg_msg = GetNullableObjectAtIndex(args, 0);
FlutterError *error;
[api setLicenseFlexibleValidMsg:arg_msg error:&error];
callback(wrapResult(nil, error));
}];
} else {
[channel setMessageHandler:nil];
}
}
} }
@interface TXFlutterNativeAPICodecReader : FlutterStandardReader @interface TXFlutterNativeAPICodecReader : FlutterStandardReader
@end @end
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
/// pigeon原始原件,由此文件生成messages原生通信代码 /// pigeon原始原件,由此文件生成messages原生通信代码
/// 生成命令如下,使用生成命令的时候,需要实现注释掉以上两个import导入 /// 生成命令如下,使用生成命令的时候,需要实现注释掉以上两个import导入
/* /*
flutter pub run pigeon \ dart run pigeon \
--input lib/Core/pigeons/txplayer_message.dart \ --input lib/Core/pigeons/txplayer_message.dart \
--dart_out lib/Core/txplayer_messages.dart \ --dart_out lib/Core/txplayer_messages.dart \
--objc_header_out ios/Classes/messages/FtxMessages.h \ --objc_header_out ios/Classes/messages/FtxMessages.h \
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
--java_out ./android/src/main/java/com/tencent/vod/flutter/messages/FtxMessages.java \ --java_out ./android/src/main/java/com/tencent/vod/flutter/messages/FtxMessages.java \
--java_package "com.tencent.vod.flutter.messages" \ --java_package "com.tencent.vod.flutter.messages" \
--copyright_header lib/Core/pigeons/txplayer_copy_right.dart --copyright_header lib/Core/pigeons/txplayer_copy_right.dart
*/ */
class PlayerMsg { class PlayerMsg {
int? playerId; int? playerId;
...@@ -391,6 +392,10 @@ abstract class TXFlutterSuperPlayerPluginAPI { ...@@ -391,6 +392,10 @@ abstract class TXFlutterSuperPlayerPluginAPI {
/// @return true : 开启成功 /// @return true : 开启成功
/// false : 开启失败,如开启过早,还未等到上下文初始化、获取sensor失败等原因 /// false : 开启失败,如开启过早,还未等到上下文初始化、获取sensor失败等原因
BoolMsg startVideoOrientationService(); BoolMsg startVideoOrientationService();
void setUserId(StringMsg msg);
void setLicenseFlexibleValid(BoolMsg msg);
} }
@HostApi() @HostApi()
......
...@@ -308,4 +308,21 @@ class SuperPlayerPlugin { ...@@ -308,4 +308,21 @@ class SuperPlayerPlugin {
void setSDKListener({FTXLicenceLoadedListener? licenceLoadedListener}) { void setSDKListener({FTXLicenceLoadedListener? licenceLoadedListener}) {
_licenseLoadedListener = licenceLoadedListener; _licenseLoadedListener = licenceLoadedListener;
} }
///
/// 设置 userId,便于定位问题
///
/// Set the userId to facilitate problem localization.
static Future<void> setUserId(String userId) async {
await _playerPluginApi.setUserId(StringMsg(value: userId));
}
///
/// 开启播放器 License 柔性校验,开启后在播放器首次启动后前 2 次播放校验将默认通过
///
/// Enable flexible verification of player License; once enabled, the verification will pass by default for the
/// first two times after the player is launched for the first time.
static Future<void> setLicenseFlexibleValid(bool enabled) async {
await _playerPluginApi.setLicenseFlexibleValid(BoolMsg(value: enabled));
}
} }
// Copyright (c) 2022 Tencent. All rights reserved. // Copyright (c) 2022 Tencent. All rights reserved.
part of SuperPlayer;
// Autogenerated from Pigeon (v9.2.5), do not edit directly. // Autogenerated from Pigeon (v9.2.5), do not edit directly.
// See also: https://pub.dev/packages/pigeon // See also: https://pub.dev/packages/pigeon
// ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import // ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import
part of SuperPlayer;
/// Pigeon original component, used to generate native communication code for `messages`. /// Pigeon original component, used to generate native communication code for `messages`.
/// The generation command is as follows. When using the generation command, /// The generation command is as follows. When using the generation command,
...@@ -1503,6 +1503,50 @@ class TXFlutterSuperPlayerPluginAPI { ...@@ -1503,6 +1503,50 @@ class TXFlutterSuperPlayerPluginAPI {
return (replyList[0] as BoolMsg?)!; return (replyList[0] as BoolMsg?)!;
} }
} }
Future<void> setUserId(StringMsg arg_msg) async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.TXFlutterSuperPlayerPluginAPI.setUserId', codec,
binaryMessenger: _binaryMessenger);
final List<Object?>? replyList =
await channel.send(<Object?>[arg_msg]) as List<Object?>?;
if (replyList == null) {
throw PlatformException(
code: 'channel-error',
message: 'Unable to establish connection on channel.',
);
} else if (replyList.length > 1) {
throw PlatformException(
code: replyList[0]! as String,
message: replyList[1] as String?,
details: replyList[2],
);
} else {
return;
}
}
Future<void> setLicenseFlexibleValid(BoolMsg arg_msg) async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.TXFlutterSuperPlayerPluginAPI.setLicenseFlexibleValid', codec,
binaryMessenger: _binaryMessenger);
final List<Object?>? replyList =
await channel.send(<Object?>[arg_msg]) as List<Object?>?;
if (replyList == null) {
throw PlatformException(
code: 'channel-error',
message: 'Unable to establish connection on channel.',
);
} else if (replyList.length > 1) {
throw PlatformException(
code: replyList[0]! as String,
message: replyList[1] as String?,
details: replyList[2],
);
} else {
return;
}
}
} }
class _TXFlutterNativeAPICodec extends StandardMessageCodec { class _TXFlutterNativeAPICodec extends StandardMessageCodec {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论