提交 3d3018b5 authored 作者: kongdywang's avatar kongdywang

1. fix live playerType

2. SuperPlayerPlugin add setGlobalCacheFolderCustomPath api
上级 ebe1b934
......@@ -31,6 +31,7 @@ import com.tencent.rtmp.TXLiveBaseListener;
import com.tencent.rtmp.TXPlayerGlobalSetting;
import com.tencent.vod.flutter.messages.FTXLivePlayerDispatcher;
import com.tencent.vod.flutter.messages.FTXVodPlayerDispatcher;
import com.tencent.vod.flutter.messages.FtxMessages;
import com.tencent.vod.flutter.messages.FtxMessages.BoolMsg;
import com.tencent.vod.flutter.messages.FtxMessages.DoubleMsg;
import com.tencent.vod.flutter.messages.FtxMessages.IntMsg;
......@@ -274,6 +275,7 @@ public class SuperPlayerPlugin implements FlutterPlugin, ActivityAware,
if (!TextUtils.isEmpty(postfixPath.getValue())) {
File sdcardDir = mFlutterPluginBinding.getApplicationContext().getExternalFilesDir(null);
if (null != sdcardDir) {
LiteavLog.v(TAG, "setGlobalCacheFolderPath:" + postfixPath.getValue());
TXPlayerGlobalSetting.setCacheFolderPath(sdcardDir.getPath() + File.separator + postfixPath.getValue());
configResult = true;
}
......@@ -283,6 +285,21 @@ public class SuperPlayerPlugin implements FlutterPlugin, ActivityAware,
return boolMsg;
}
@NonNull
@Override
public BoolMsg setGlobalCacheFolderCustomPath(@NonNull FtxMessages.CachePathMsg cacheMsg) {
boolean configResult = false;
final String cachePath = cacheMsg.getAndroidAbsolutePath();
if (!TextUtils.isEmpty(cachePath)) {
LiteavLog.v(TAG, "setGlobalCacheFolderCustomPath:" + cachePath);
TXPlayerGlobalSetting.setCacheFolderPath(cachePath);
configResult = true;
}
BoolMsg boolMsg = new BoolMsg();
boolMsg.setValue(configResult);
return boolMsg;
}
@Override
public void setGlobalLicense(@NonNull LicenseMsg licenseMsg) {
TXLiveBase.getInstance().setLicence(mFlutterPluginBinding.getApplicationContext(), licenseMsg.getLicenseUrl(),
......
......@@ -2347,6 +2347,70 @@ public class FtxMessages {
}
}
/** Generated class from Pigeon that represents data sent in messages. */
public static final class CachePathMsg {
private @Nullable String androidAbsolutePath;
public @Nullable String getAndroidAbsolutePath() {
return androidAbsolutePath;
}
public void setAndroidAbsolutePath(@Nullable String setterArg) {
this.androidAbsolutePath = setterArg;
}
private @Nullable String iOSAbsolutePath;
public @Nullable String getIOSAbsolutePath() {
return iOSAbsolutePath;
}
public void setIOSAbsolutePath(@Nullable String setterArg) {
this.iOSAbsolutePath = setterArg;
}
public static final class Builder {
private @Nullable String androidAbsolutePath;
public @NonNull Builder setAndroidAbsolutePath(@Nullable String setterArg) {
this.androidAbsolutePath = setterArg;
return this;
}
private @Nullable String iOSAbsolutePath;
public @NonNull Builder setIOSAbsolutePath(@Nullable String setterArg) {
this.iOSAbsolutePath = setterArg;
return this;
}
public @NonNull CachePathMsg build() {
CachePathMsg pigeonReturn = new CachePathMsg();
pigeonReturn.setAndroidAbsolutePath(androidAbsolutePath);
pigeonReturn.setIOSAbsolutePath(iOSAbsolutePath);
return pigeonReturn;
}
}
@NonNull
ArrayList<Object> toList() {
ArrayList<Object> toListResult = new ArrayList<Object>(2);
toListResult.add(androidAbsolutePath);
toListResult.add(iOSAbsolutePath);
return toListResult;
}
static @NonNull CachePathMsg fromList(@NonNull ArrayList<Object> list) {
CachePathMsg pigeonResult = new CachePathMsg();
Object androidAbsolutePath = list.get(0);
pigeonResult.setAndroidAbsolutePath((String) androidAbsolutePath);
Object iOSAbsolutePath = list.get(1);
pigeonResult.setIOSAbsolutePath((String) iOSAbsolutePath);
return pigeonResult;
}
}
/** Generated class from Pigeon that represents data sent in messages. */
public static final class DoubleMsg {
private @Nullable Double value;
......@@ -3214,12 +3278,14 @@ public class FtxMessages {
case (byte) 128:
return BoolMsg.fromList((ArrayList<Object>) readValue(buffer));
case (byte) 129:
return IntMsg.fromList((ArrayList<Object>) readValue(buffer));
return CachePathMsg.fromList((ArrayList<Object>) readValue(buffer));
case (byte) 130:
return LicenseMsg.fromList((ArrayList<Object>) readValue(buffer));
return IntMsg.fromList((ArrayList<Object>) readValue(buffer));
case (byte) 131:
return PlayerMsg.fromList((ArrayList<Object>) readValue(buffer));
return LicenseMsg.fromList((ArrayList<Object>) readValue(buffer));
case (byte) 132:
return PlayerMsg.fromList((ArrayList<Object>) readValue(buffer));
case (byte) 133:
return StringMsg.fromList((ArrayList<Object>) readValue(buffer));
default:
return super.readValueOfType(type, buffer);
......@@ -3231,17 +3297,20 @@ public class FtxMessages {
if (value instanceof BoolMsg) {
stream.write(128);
writeValue(stream, ((BoolMsg) value).toList());
} else if (value instanceof IntMsg) {
} else if (value instanceof CachePathMsg) {
stream.write(129);
writeValue(stream, ((CachePathMsg) value).toList());
} else if (value instanceof IntMsg) {
stream.write(130);
writeValue(stream, ((IntMsg) value).toList());
} else if (value instanceof LicenseMsg) {
stream.write(130);
stream.write(131);
writeValue(stream, ((LicenseMsg) value).toList());
} else if (value instanceof PlayerMsg) {
stream.write(131);
stream.write(132);
writeValue(stream, ((PlayerMsg) value).toList());
} else if (value instanceof StringMsg) {
stream.write(132);
stream.write(133);
writeValue(stream, ((StringMsg) value).toList());
} else {
super.writeValue(stream, value);
......@@ -3284,6 +3353,9 @@ public class FtxMessages {
*/
@NonNull
BoolMsg setGlobalCacheFolderPath(@NonNull StringMsg postfixPath);
/** 设置播放器资源缓存目录绝对路径,该方法会与 setGlobalCacheFolderPath(String postfixPath) 相互覆盖,调用其中一个即可 */
@NonNull
BoolMsg setGlobalCacheFolderCustomPath(@NonNull CachePathMsg cacheMsg);
/** 设置全局license */
void setGlobalLicense(@NonNull LicenseMsg licenseMsg);
/** 设置log输出级别 [TXLogLevel] */
......@@ -3473,6 +3545,30 @@ public class FtxMessages {
BoolMsg output = api.setGlobalCacheFolderPath(postfixPathArg);
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.setGlobalCacheFolderCustomPath", getCodec());
if (api != null) {
channel.setMessageHandler(
(message, reply) -> {
ArrayList<Object> wrapped = new ArrayList<Object>();
ArrayList<Object> args = (ArrayList<Object>) message;
CachePathMsg cacheMsgArg = (CachePathMsg) args.get(0);
try {
BoolMsg output = api.setGlobalCacheFolderCustomPath(cacheMsgArg);
wrapped.add(0, output);
}
catch (Throwable exception) {
ArrayList<Object> wrappedError = wrapError(exception);
wrapped = wrappedError;
......
......@@ -289,12 +289,25 @@ SuperPlayerPlugin* instance;
NSString *preloadDataPath = [documentDirectory stringByAppendingPathComponent:postfixPathStr];
NSError *error = nil;
[[NSFileManager defaultManager] createDirectoryAtPath:preloadDataPath withIntermediateDirectories:NO attributes:nil error:&error];
FTXLOGV(@"setGlobalCacheFolderPathPostfixPath:%@", preloadDataPath);
[TXPlayerGlobalSetting setCacheFolderPath:preloadDataPath];
return [TXCommonUtil boolMsgWith:YES];
} else {
return [TXCommonUtil boolMsgWith:NO];
}
}
- (BoolMsg *)setGlobalCacheFolderCustomPathCacheMsg:(CachePathMsg *)cacheMsg error:(FlutterError * _Nullable __autoreleasing *)error {
NSString* cachePath = cacheMsg.iOSAbsolutePath;
if (cachePath && cachePath.length > 0) {
NSError *error = nil;
[[NSFileManager defaultManager] createDirectoryAtPath:cachePath withIntermediateDirectories:NO attributes:nil error:&error];
FTXLOGV(@"setGlobalCacheFolderCustomPathCacheMsg:%@", cachePath);
[TXPlayerGlobalSetting setCacheFolderPath:cachePath];
return [TXCommonUtil boolMsgWith:YES];
} else {
return [TXCommonUtil boolMsgWith:NO];
}
}
- (nullable IntMsg *)setGlobalEnvEnvConfig:(nonnull StringMsg *)envConfig error:(FlutterError * _Nullable __autoreleasing * _Nonnull)error {
......
......@@ -31,6 +31,7 @@ NS_ASSUME_NONNULL_BEGIN
@class BoolMsg;
@class IntMsg;
@class StringMsg;
@class CachePathMsg;
@class DoubleMsg;
@class PreLoadMsg;
@class PreLoadInfoMsg;
......@@ -300,6 +301,13 @@ NS_ASSUME_NONNULL_BEGIN
@property(nonatomic, copy, nullable) NSString * value;
@end
@interface CachePathMsg : NSObject
+ (instancetype)makeWithAndroidAbsolutePath:(nullable NSString *)androidAbsolutePath
iOSAbsolutePath:(nullable NSString *)iOSAbsolutePath;
@property(nonatomic, copy, nullable) NSString * androidAbsolutePath;
@property(nonatomic, copy, nullable) NSString * iOSAbsolutePath;
@end
@interface DoubleMsg : NSObject
+ (instancetype)makeWithValue:(nullable NSNumber *)value;
@property(nonatomic, strong, nullable) NSNumber * value;
......@@ -424,6 +432,10 @@ NSObject<FlutterMessageCodec> *TXFlutterSuperPlayerPluginAPIGetCodec(void);
///
/// @return `nil` only when `error != nil`.
- (nullable BoolMsg *)setGlobalCacheFolderPathPostfixPath:(StringMsg *)postfixPath error:(FlutterError *_Nullable *_Nonnull)error;
/// 设置播放器资源缓存目录绝对路径,该方法会与 setGlobalCacheFolderPath(String postfixPath) 相互覆盖,调用其中一个即可
///
/// @return `nil` only when `error != nil`.
- (nullable BoolMsg *)setGlobalCacheFolderCustomPathCacheMsg:(CachePathMsg *)cacheMsg error:(FlutterError *_Nullable *_Nonnull)error;
/// 设置全局license
- (void)setGlobalLicenseLicenseMsg:(LicenseMsg *)licenseMsg error:(FlutterError *_Nullable *_Nonnull)error;
/// 设置log输出级别 [TXLogLevel]
......
......@@ -142,6 +142,12 @@ static id GetNullableObjectAtIndex(NSArray *array, NSInteger key) {
- (NSArray *)toList;
@end
@interface CachePathMsg ()
+ (CachePathMsg *)fromList:(NSArray *)list;
+ (nullable CachePathMsg *)nullableFromList:(NSArray *)list;
- (NSArray *)toList;
@end
@interface DoubleMsg ()
+ (DoubleMsg *)fromList:(NSArray *)list;
+ (nullable DoubleMsg *)nullableFromList:(NSArray *)list;
......@@ -870,6 +876,31 @@ static id GetNullableObjectAtIndex(NSArray *array, NSInteger key) {
}
@end
@implementation CachePathMsg
+ (instancetype)makeWithAndroidAbsolutePath:(nullable NSString *)androidAbsolutePath
iOSAbsolutePath:(nullable NSString *)iOSAbsolutePath {
CachePathMsg* pigeonResult = [[CachePathMsg alloc] init];
pigeonResult.androidAbsolutePath = androidAbsolutePath;
pigeonResult.iOSAbsolutePath = iOSAbsolutePath;
return pigeonResult;
}
+ (CachePathMsg *)fromList:(NSArray *)list {
CachePathMsg *pigeonResult = [[CachePathMsg alloc] init];
pigeonResult.androidAbsolutePath = GetNullableObjectAtIndex(list, 0);
pigeonResult.iOSAbsolutePath = GetNullableObjectAtIndex(list, 1);
return pigeonResult;
}
+ (nullable CachePathMsg *)nullableFromList:(NSArray *)list {
return (list) ? [CachePathMsg fromList:list] : nil;
}
- (NSArray *)toList {
return @[
(self.androidAbsolutePath ?: [NSNull null]),
(self.iOSAbsolutePath ?: [NSNull null]),
];
}
@end
@implementation DoubleMsg
+ (instancetype)makeWithValue:(nullable NSNumber *)value {
DoubleMsg* pigeonResult = [[DoubleMsg alloc] init];
......@@ -1131,12 +1162,14 @@ static id GetNullableObjectAtIndex(NSArray *array, NSInteger key) {
case 128:
return [BoolMsg fromList:[self readValue]];
case 129:
return [IntMsg fromList:[self readValue]];
return [CachePathMsg fromList:[self readValue]];
case 130:
return [LicenseMsg fromList:[self readValue]];
return [IntMsg fromList:[self readValue]];
case 131:
return [PlayerMsg fromList:[self readValue]];
return [LicenseMsg fromList:[self readValue]];
case 132:
return [PlayerMsg fromList:[self readValue]];
case 133:
return [StringMsg fromList:[self readValue]];
default:
return [super readValueOfType:type];
......@@ -1151,18 +1184,21 @@ static id GetNullableObjectAtIndex(NSArray *array, NSInteger key) {
if ([value isKindOfClass:[BoolMsg class]]) {
[self writeByte:128];
[self writeValue:[value toList]];
} else if ([value isKindOfClass:[IntMsg class]]) {
} else if ([value isKindOfClass:[CachePathMsg class]]) {
[self writeByte:129];
[self writeValue:[value toList]];
} else if ([value isKindOfClass:[LicenseMsg class]]) {
} else if ([value isKindOfClass:[IntMsg class]]) {
[self writeByte:130];
[self writeValue:[value toList]];
} else if ([value isKindOfClass:[PlayerMsg class]]) {
} else if ([value isKindOfClass:[LicenseMsg class]]) {
[self writeByte:131];
[self writeValue:[value toList]];
} else if ([value isKindOfClass:[StringMsg class]]) {
} else if ([value isKindOfClass:[PlayerMsg class]]) {
[self writeByte:132];
[self writeValue:[value toList]];
} else if ([value isKindOfClass:[StringMsg class]]) {
[self writeByte:133];
[self writeValue:[value toList]];
} else {
[super writeValue:value];
}
......@@ -1335,6 +1371,26 @@ void TXFlutterSuperPlayerPluginAPISetup(id<FlutterBinaryMessenger> binaryMesseng
[channel setMessageHandler:nil];
}
}
/// 设置播放器资源缓存目录绝对路径,该方法会与 setGlobalCacheFolderPath(String postfixPath) 相互覆盖,调用其中一个即可
{
FlutterBasicMessageChannel *channel =
[[FlutterBasicMessageChannel alloc]
initWithName:@"dev.flutter.pigeon.TXFlutterSuperPlayerPluginAPI.setGlobalCacheFolderCustomPath"
binaryMessenger:binaryMessenger
codec:TXFlutterSuperPlayerPluginAPIGetCodec()];
if (api) {
NSCAssert([api respondsToSelector:@selector(setGlobalCacheFolderCustomPathCacheMsg:error:)], @"TXFlutterSuperPlayerPluginAPI api (%@) doesn't respond to @selector(setGlobalCacheFolderCustomPathCacheMsg:error:)", api);
[channel setMessageHandler:^(id _Nullable message, FlutterReply callback) {
NSArray *args = message;
CachePathMsg *arg_cacheMsg = GetNullableObjectAtIndex(args, 0);
FlutterError *error;
BoolMsg *output = [api setGlobalCacheFolderCustomPathCacheMsg:arg_cacheMsg error:&error];
callback(wrapResult(output, error));
}];
} else {
[channel setMessageHandler:nil];
}
}
/// 设置全局license
{
FlutterBasicMessageChannel *channel =
......
// Copyright (c) 2022 Tencent. All rights reserved.
// import 'package:pigeon/pigeon.dart';
// import 'package:super_player/super_player.dart';
/// Pigeon original component, used to generate native communication code for `messages`.
/// The generation command is as follows. When using the generation command,
/// the two import statements above need to be implemented or commented out.
......@@ -269,6 +267,11 @@ class StringMsg {
String? value;
}
class CachePathMsg {
String? androidAbsolutePath;
String? iOSAbsolutePath;
}
class DoubleMsg {
double? value;
}
......@@ -358,6 +361,9 @@ abstract class TXFlutterSuperPlayerPluginAPI {
/// @return true 设置成功 false 设置失败
BoolMsg setGlobalCacheFolderPath(StringMsg postfixPath);
/// 设置播放器资源缓存目录绝对路径,该方法会与 setGlobalCacheFolderPath(String postfixPath) 相互覆盖,调用其中一个即可
BoolMsg setGlobalCacheFolderCustomPath(CachePathMsg cacheMsg);
/// 设置全局license
void setGlobalLicense(LicenseMsg licenseMsg);
......
......@@ -137,6 +137,25 @@ class SuperPlayerPlugin {
BoolMsg boolMsg = await _playerPluginApi.setGlobalCacheFolderPath(StringMsg()..value = postfixPath);
return boolMsg.value;
}
///
/// Set the absolute path of the player resource cache directory. This method will override each other with
/// setGlobalCacheFolderPath(String postfixPath), and you only need to call one of them.
///
/// @param androidAbsolutePath Android side absolute path
/// iOSAbsolutePath Android side absolute path
/// @return true if the setting is successful, false otherwise
///
/// 设置播放器资源缓存目录绝对路径,该方法会与 setGlobalCacheFolderPath(String postfixPath) 相互覆盖,调用其中一个即可。
///
/// @param androidAbsolutePath 安卓侧绝对路径
/// iOSAbsolutePath 安卓侧绝对路径
/// @return true 设置成功 false 设置失败
static Future<bool?> setGlobalCacheFolderCustomPath({String? androidAbsolutePath, String? iOSAbsolutePath}) async {
BoolMsg boolMsg = await _playerPluginApi.setGlobalCacheFolderCustomPath(CachePathMsg()
..androidAbsolutePath = androidAbsolutePath
..iOSAbsolutePath = iOSAbsolutePath);
return boolMsg.value;
}
/// Setting the global license
/// 设置全局license
......
......@@ -53,7 +53,8 @@ abstract class TXPlayType {
static const LIVE_RTMP = 0;
static const LIVE_FLV = 1;
static const LIVE_RTMP_ACC = 5;
static const VOD_HLS = 3;
/// must depend on professional sdk
static const VOD_HLS = 7;
}
abstract class TXVodPlayEvent {
......
// Copyright (c) 2022 Tencent. All rights reserved.
part of SuperPlayer;
// Autogenerated from Pigeon (v9.2.5), do not edit directly.
// 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
part of SuperPlayer;
/// Pigeon original component, used to generate native communication code for `messages`.
/// The generation command is as follows. When using the generation command,
......@@ -781,6 +781,32 @@ class StringMsg {
}
}
class CachePathMsg {
CachePathMsg({
this.androidAbsolutePath,
this.iOSAbsolutePath,
});
String? androidAbsolutePath;
String? iOSAbsolutePath;
Object encode() {
return <Object?>[
androidAbsolutePath,
iOSAbsolutePath,
];
}
static CachePathMsg decode(Object result) {
result as List<Object?>;
return CachePathMsg(
androidAbsolutePath: result[0] as String?,
iOSAbsolutePath: result[1] as String?,
);
}
}
class DoubleMsg {
DoubleMsg({
this.value,
......@@ -1065,18 +1091,21 @@ class _TXFlutterSuperPlayerPluginAPICodec extends StandardMessageCodec {
if (value is BoolMsg) {
buffer.putUint8(128);
writeValue(buffer, value.encode());
} else if (value is IntMsg) {
} else if (value is CachePathMsg) {
buffer.putUint8(129);
writeValue(buffer, value.encode());
} else if (value is LicenseMsg) {
} else if (value is IntMsg) {
buffer.putUint8(130);
writeValue(buffer, value.encode());
} else if (value is PlayerMsg) {
} else if (value is LicenseMsg) {
buffer.putUint8(131);
writeValue(buffer, value.encode());
} else if (value is StringMsg) {
} else if (value is PlayerMsg) {
buffer.putUint8(132);
writeValue(buffer, value.encode());
} else if (value is StringMsg) {
buffer.putUint8(133);
writeValue(buffer, value.encode());
} else {
super.writeValue(buffer, value);
}
......@@ -1088,12 +1117,14 @@ class _TXFlutterSuperPlayerPluginAPICodec extends StandardMessageCodec {
case 128:
return BoolMsg.decode(readValue(buffer)!);
case 129:
return IntMsg.decode(readValue(buffer)!);
return CachePathMsg.decode(readValue(buffer)!);
case 130:
return LicenseMsg.decode(readValue(buffer)!);
return IntMsg.decode(readValue(buffer)!);
case 131:
return PlayerMsg.decode(readValue(buffer)!);
return LicenseMsg.decode(readValue(buffer)!);
case 132:
return PlayerMsg.decode(readValue(buffer)!);
case 133:
return StringMsg.decode(readValue(buffer)!);
default:
return super.readValueOfType(type, buffer);
......@@ -1302,6 +1333,34 @@ class TXFlutterSuperPlayerPluginAPI {
}
}
/// 设置播放器资源缓存目录绝对路径,该方法会与 setGlobalCacheFolderPath(String postfixPath) 相互覆盖,调用其中一个即可
Future<BoolMsg> setGlobalCacheFolderCustomPath(CachePathMsg arg_cacheMsg) async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
'dev.flutter.pigeon.TXFlutterSuperPlayerPluginAPI.setGlobalCacheFolderCustomPath', codec,
binaryMessenger: _binaryMessenger);
final List<Object?>? replyList =
await channel.send(<Object?>[arg_cacheMsg]) 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 if (replyList[0] == null) {
throw PlatformException(
code: 'null-error',
message: 'Host platform returned null value for non-null return value.',
);
} else {
return (replyList[0] as BoolMsg?)!;
}
}
/// 设置全局license
Future<void> setGlobalLicense(LicenseMsg arg_licenseMsg) async {
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论