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

1. fix license donwload error when ios app first start

2. fix ios predownload path error
上级 ae72a6d8
// Copyright (c) 2022 Tencent. All rights reserved.
// The obtained license URL
const LICENSE_URL = "";
// The obtained license key
const LICENSE_KEY = "";
\ No newline at end of file
......@@ -38,6 +38,7 @@ class _DemoTXVodPlayerState extends State<DemoTXVodPlayer> with WidgetsBindingOb
Future<void> init() async {
if (!mounted) return;
await SuperPlayerPlugin.setConsoleEnabled(true);
_controller = TXVodPlayerController();
_controller.onPlayerState.listen((val) {
debugPrint("Playback status ${val?.name}");
......@@ -80,7 +81,6 @@ class _DemoTXVodPlayerState extends State<DemoTXVodPlayer> with WidgetsBindingOb
});
}
});
await SuperPlayerPlugin.setConsoleEnabled(true);
await _controller.initialize();
await _controller.setLoop(true);
......@@ -91,6 +91,16 @@ class _DemoTXVodPlayerState extends State<DemoTXVodPlayer> with WidgetsBindingOb
await _controller.startVodPlay(_url);
}
void startPlay() async {
await _controller.startVodPlayWithParams(TXPlayInfoParams(appId: 1500005830, fileId: "243791578431393746",
psign: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcHBJZCI6MTUwMDAwNTgzMCwiZmlsZUlkIjoiMjQzNzkxNTc4NDMxMzkzNzQ2IiwiY"
"3VycmVudFRpbWVTdGFtcCI6MTY3MzQyNjIyNywiY29udGVudEluZm8iOnsiYXVkaW9WaWRlb1R5cGUiOiJQcm90ZWN0ZWRBZGFwdGl"
"2ZSIsImRybUFkYXB0aXZlSW5mbyI6eyJwcml2YXRlRW5jcnlwdGlvbkRlZmluaXRpb24iOjEyfX0sInVybEFjY2Vzc0luZm8iOnsiZ"
"G9tYWluIjoiMTUwMDAwNTgzMC52b2QyLm15cWNsb3VkLmNvbSIsInNjaGVtZSI6IkhUVFBTIn19.q34pq7Bl0ryKDwUHGyzfXKP-C"
"DI8vrm0k_y-IaxgF_U"));
}
void _resizeVideo(Map<dynamic, dynamic> event) {
int? videoWidth = event[TXVodPlayEvent.EVT_PARAM1];
int? videoHeight = event[TXVodPlayEvent.EVT_PARAM2];
......
......@@ -6,6 +6,7 @@ import 'package:flutter/services.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:super_player/super_player.dart';
import 'package:super_player_example/common/demo_config.dart';
import 'package:super_player_example/demo_superplayer.dart';
import 'package:super_player_example/res/app_localization_delegate.dart';
import 'package:super_player_example/res/app_localizations.dart';
......@@ -40,9 +41,7 @@ class _MyAppState extends State<MyApp> {
/// set player license
Future<void> initPlayerLicense() async {
String licenceURL = ""; // The obtained license URL
String licenceKey = ""; // The obtained license key
await SuperPlayerPlugin.setGlobalLicense(licenceURL, licenceKey);
await SuperPlayerPlugin.setGlobalLicense(LICENSE_URL, LICENSE_KEY);
}
// Platform messages are asynchronous, so we initialize in an async method.
......
......@@ -2,10 +2,12 @@
import 'dart:math';
import 'package:flutter/material.dart';
import 'package:super_player_example/common/demo_config.dart';
import 'package:super_player_example/demo_superplayer.dart';
import 'package:super_player_example/demo_txLiveplayer.dart';
import 'package:super_player_example/demo_txvodplayer.dart';
import 'package:super_player_example/res/app_localizations.dart';
import 'package:super_player/super_player.dart';
import '../demo_short_video_player.dart';
import 'demo_define.dart';
......@@ -28,11 +30,16 @@ class _TreePageState extends State<TreePage> {
Icons.ac_unit,
Icons.lightbulb_outline,
];
/// set player license
Future<void> initPlayerLicense() async {
await SuperPlayerPlugin.setGlobalLicense(LICENSE_URL, LICENSE_KEY);
}
@override
void initState() {
super.initState();
// license add to here, prevent first launch due to license loading failure caused by no network
initPlayerLicense();
_scrollController.addListener(() {
// Current position = maximum sliding range means that it has already been scrolled to the bottom.
if (_scrollController.position.pixels ==
......
......@@ -32,10 +32,6 @@
_eventChannel = [FlutterEventChannel eventChannelWithName:@"cloud.tencent.com/txvodplayer/download/event" binaryMessenger:[registrar messenger]];
[_eventChannel setStreamHandler:self];
[[TXVodDownloadManager shareInstance] setDelegate:self];
// Set the download storage path.
NSString *cachesDir = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) firstObject];
NSString *path = [NSString stringWithFormat:@"%@/videoCache",cachesDir];
[[TXVodDownloadManager shareInstance] setDownloadPath:path];
self.mPreloadQueue = dispatch_queue_create(@"cloud.tencent.com.preload", NULL);
self.delegateArray = [[NSMutableArray alloc] init];
}
......
......@@ -273,11 +273,9 @@ SuperPlayerPlugin* instance;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentDirectory = [[paths objectAtIndex:0] stringByAppendingString:@"/"];
NSString *preloadDataPath = [documentDirectory stringByAppendingPathComponent:postfixPathStr];
if (![[NSFileManager defaultManager] fileExistsAtPath:preloadDataPath]) {
NSError *error = nil;
[[NSFileManager defaultManager] createDirectoryAtPath:preloadDataPath withIntermediateDirectories:NO attributes:nil error:&error];
[TXPlayerGlobalSetting setCacheFolderPath:preloadDataPath];
}
return [CommonUtil boolMsgWith:YES];
} else {
return [CommonUtil boolMsgWith:NO];
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论