提交 960dc748 authored 作者: dokieyang's avatar dokieyang

1、fix bug: play with fileId & psign

2、update sdk version to latest(10.2)
上级 83a8f6a8
.idea/
.dart_tool/
.packages
\ No newline at end of file
.packages
pubspec.lock
\ No newline at end of file
差异被折叠。
## 腾讯云播放器SDK Flutter插件
简体中文| [English](./README-EN.md)
## 工程目录结构说明
本目录包含腾讯云播放器SDK Flutter 插件 和 Demo 源代码,主要演示接口如何调用以及最基本的功能。
......
......@@ -24,32 +24,11 @@ apply plugin: 'com.android.library'
android {
//获取local.properties配置文件
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
//获取flutter的sdk路径
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
compileSdkVersion rootProject.ext.compileSdkVersion
defaultConfig {
minSdkVersion rootProject.ext.minSdkVersion
}
dependencies {
compileOnly 'androidx.annotation:annotation:1.2.0'
//此处仅处理因插件项目内报红显示的处理方式
//compileOnly files("$flutterRoot/bin/cache/artifacts/engine/android-arm/flutter.jar")
}
}
......
......@@ -10,9 +10,4 @@ rootProject.ext {
*/
liteavSdk="com.tencent.liteav:LiteAVSDK_Player:latest.release"
// liteavSdk="com.tencent.liteav:LiteAVSDK_Professional:latest.release"
imSdk = 'com.tencent.imsdk:imsdk:4.9.1'
versionCode = 1
versionName = "v1.0"
ndkAbi = 'armeabi'//,'armeabi-v7a', 'arm64-v8a'
aekit_version = '1.0.10-cloud'
}
\ No newline at end of file
......@@ -13,6 +13,7 @@ import com.tencent.rtmp.ITXVodPlayListener;
import com.tencent.rtmp.TXBitrateItem;
import com.tencent.rtmp.TXLiveConstants;
import com.tencent.rtmp.TXLivePlayer;
import com.tencent.rtmp.TXPlayInfoParams;
import com.tencent.rtmp.TXPlayerAuthBuilder;
import com.tencent.rtmp.TXVodPlayConfig;
import com.tencent.rtmp.TXVodPlayer;
......@@ -183,8 +184,8 @@ public class FTXVodPlayer extends FTXBasePlayer implements MethodChannel.MethodC
int r = startPlay(url);
result.success(r);
} else if (call.method.equals("startPlayWithParams")) {
int r = startPlayWithParams(call);
result.success(r);
startPlayWithParams(call);
result.success(null);
} else if (call.method.equals("stop")) {
Boolean isNeedClear = call.argument("isNeedClear");
int r = stopPlay(isNeedClear);
......@@ -328,37 +329,14 @@ public class FTXVodPlayer extends FTXBasePlayer implements MethodChannel.MethodC
return Uninitialized;
}
int startPlayWithParams(MethodCall call) {
void startPlayWithParams(MethodCall call) {
if (mVodPlayer != null) {
TXPlayerAuthBuilder builder = new TXPlayerAuthBuilder();
int appId = call.argument("appId");
builder.setAppId(appId);
String fileId = call.argument("fileId");
builder.setFileId(fileId);
String timeout = call.argument("timeout");
if (!timeout.isEmpty()) {
builder.setTimeout(timeout);
}
int exper = call.argument("exper");
builder.setExper(exper);
String us = call.argument("us");
if (!us.isEmpty()) {
builder.setUs(us);
}
String sign = call.argument("sign");
if (!sign.isEmpty()) {
builder.setSign(sign);
}
boolean https = call.argument("https");
builder.setHttps(https);
return mVodPlayer.startPlay(builder);
String psign = call.argument("psign");
TXPlayInfoParams playInfoParams = new TXPlayInfoParams(appId, fileId, psign);
mVodPlayer.startPlay(playInfoParams);
}
return Uninitialized;
}
int stopPlay(boolean isNeedClearLastImg) {
......
差异被折叠。
简体中文| [English](./点播播放器-EN.md)
## SDK 下载
腾讯云视立方 Flutter 超级播放器项目的地址是 [SuperPlayer Flutter](https://github.com/LiteAVSDK/Player_Flutter/tree/main/Flutter)
......@@ -734,7 +736,7 @@ _controller.onPlayerState.listen((val) { });
这就是视频播放中无缝切换的背后技术支撑,您可以使用 TXVodPlayerController 中的 isAutoPlay 开关来实现这个功能,具体做法如下:
![](https://mc.qcloudimg.com/static/img/7331417ebbdfe6306fe96f4b76c8d0ad/image.jpg)
![](https://qcloudimg.tencent-cloud.cn/raw/f43ea6105d9f80c4162241ca0605b8f0.png)
```dart
// 播放视频 A: 如果将 isAutoPlay 设置为 true, 那么 startPlay 调用会立刻开始视频的加载和播放
......
差异被折叠。
简体中文| [English](./直播播放器-EN.md)
## 基础知识
本文主要介绍视频云 SDK 的直播播放功能,在此之前,先了解如下一些基本知识会大有裨益:
- **直播和点播**
......
差异被折叠。
简体中文| [English](./超级播放器-EN.md)
## SDK 下载
腾讯云视立方 Flutter 超级播放器项目的地址是 [SuperPlayer Flutter](https://github.com/LiteAVSDK/Player_Flutter/tree/main/Flutter)
......
......@@ -155,16 +155,6 @@ class _DemoSuperplayerState extends State<DemoSuperplayer> {
model.playAction = playAction;
models.add(model);
model = SuperPlayerModel();
model.appId = 1254432039;
model.title = "为什么贫穷(fileId+psign播放)";
model.videoId = new SuperPlayerVideoId();
model.videoId!.fileId = '5285890816303742312';
model.videoId!.psign =
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcHBJZCI6MTI1NDQzMjAzOSwiZmlsZUlkIjoiNTI4NTg5MDgxNjMwMzc0MjMxMiIsImN1cnJlbnRUaW1lU3RhbXAiOjE2MTcyNTc0ODMsInBjZmciOiJiYXNpY0RybVByZXNldCIsInVybEFjY2Vzc0luZm8iOnt9LCJkcm1MaWNlbnNlSW5mbyI6e319.2H1t9dKPpdA41a8t1WwI631OWC18HGl60ccBDLylCKE';
model.playAction = playAction;
models.add(model);
model = SuperPlayerModel();
model.appId = 1252463788;
model.videoId = new SuperPlayerVideoId();
......
......@@ -53,6 +53,8 @@ class _DemoTXVodlayerState extends State<DemoTXVodPlayer>
double videoDuration = event[TXVodPlayEvent.EVT_PLAY_DURATION].toDouble(); // 总播放时长,转换后的单位 秒
progressSliderKey.currentState?.updatePorgess(_currentProgress / videoDuration, videoDuration);
} else if (event["event"] == TXVodPlayEvent.PLAY_EVT_GET_PLAYINFO_SUCC) {
String? playUrl = event[TXVodPlayEvent.EVT_PLAY_URL]?.toString();
}
});
......@@ -390,12 +392,11 @@ class _DemoTXVodlayerState extends State<DemoTXVodPlayer>
if (url.isNotEmpty) {
_controller.startPlay(url);
} else if (appId != 0 && fileId.isNotEmpty) {
TXPlayerAuthParams params = TXPlayerAuthParams();
params.appId = appId;
params.fileId = fileId;
TXPlayInfoParams params = TXPlayInfoParams(appId: _appId,
fileId: _fileId, psign: pSign != null ? pSign : "");
_controller.startPlayWithParams(params);
}
});
}, needPisgn: true);
});
}
......
......@@ -138,6 +138,11 @@ class PlayInfoProtocol {
String? getDRMType() {
return null == _playInfoParser ? null : _playInfoParser?.drmType;
}
static String? getV4ErrorCodeDescription(int errorCode) {
return GETPLAYINFOV4_ERROR_CODE_MAP[errorCode];
}
// getplayinfo/v4错误码
// http状态码 200 403
// 403一般鉴权信息不通过或者请求不合法
......
......@@ -33,7 +33,7 @@ class SuperVodDataLoader {
int code = root['code'];
String message = root['message'];
String warning = root['warning'];
LogUtils.d(TAG, "_getVodListData,code=($code, ${PlayInfoProtocol.GETPLAYINFOV4_ERROR_CODE_MAP[code]}),message=$message,warning=$warning");
LogUtils.d(TAG, "_getVodListData,code=($code, ${PlayInfoProtocol.getV4ErrorCodeDescription(code)}),message=$message,warning=$warning");
if (code != 0) {
return;
}
......
......@@ -149,7 +149,7 @@ class _DemoInputDialogState extends State<DemoInputDialog> {
decoration: InputDecoration(
enabledBorder: OutlineInputBorder(borderRadius: BorderRadius.all(Radius.circular(10.0)), borderSide: BorderSide(color: Colors.green.withOpacity(0.4), width: 3.0)),
focusedBorder: OutlineInputBorder(borderRadius: BorderRadius.all(Radius.circular(10.0)), borderSide: BorderSide(color: Colors.green, width: 4.0)),
labelText:"请输入pSign", labelStyle: TextStyle(color: Colors.grey),
labelText:"请输入pSign(加密视频必填)", labelStyle: TextStyle(color: Colors.grey),
suffixIcon: IconButton(
icon: Icon(Icons.close),
onPressed: () {
......
......@@ -104,7 +104,7 @@ static const int uninitialized = -1;
if (_txLivePlayer != nil) {
TXLivePlayConfig *config = [TXLivePlayConfig new];
[config setPlayerPixelFormatType:kCVPixelFormatType_32BGRA];
[config setPlayerPixelFormatType:kCVPixelFormatType_420YpCbCr8BiPlanarFullRange];
[_txLivePlayer setConfig:config];
[_txLivePlayer setVideoProcessDelegate:self];
}
......
......@@ -146,32 +146,17 @@ BOOL volatile isStop = false;
return uninitialized;
}
- (int)startPlayWithParams:(NSDictionary *)params
{
if (_txVodPlayer != nil) {
TXPlayerAuthParams *p = [TXPlayerAuthParams new];
NSString *timeout = params[@"timeout"];
NSString *us = params[@"us"];
NSString *sign = params[@"sign"];
int exper = [params[@"exper"] intValue];
p.appId = [params[@"appId"] unsignedIntValue];
p.fileId = params[@"fileId"];
if (timeout.length > 0) {
p.timeout = timeout;
}
if (exper != 0) {
p.exper = exper;
NSString *psign = params[@"psign"];
if (psign.length > 0) {
p.sign = params[@"psign"];
}
if (us.length > 0) {
p.us = us;
}
if (sign.length > 0) {
p.sign = params[@"sign"];
}
p.https = [params[@"https"] boolValue];
return [_txVodPlayer startPlayWithParams:p];
}
return uninitialized;
......
......@@ -16,7 +16,8 @@ player plugin.
s.source_files = 'Classes/**/*'
s.public_header_files = 'Classes/**/*.h'
s.dependency 'Flutter'
s.dependency 'TXLiteAVSDK_Player','9.5.29040'
s.dependency 'TXLiteAVSDK_Player'
s.ios.framework = ['MobileCoreServices']
s.platform = :ios, '9.0'
s.static_framework = true
......
......@@ -81,7 +81,9 @@ abstract class TXVodPlayEvent {
static const EVT_PLAY_DURATION = "EVT_PLAY_DURATION"; // 播放总长
static const EVT_PLAYABLE_DURATION_MS = "EVT_PLAYABLE_DURATION_MS"; // 点播可播放时长(毫秒)
static const EVT_PLAYABLE_RATE = "EVT_PLAYABLE_RATE"; //播放速率
static const String EVT_IMAGESPRIT_WEBVTTURL = "EVT_IMAGESPRIT_WEBVTTURL"; // 雪碧图web vtt描述文件下载URL
static const String EVT_IMAGESPRIT_IMAGEURL_LIST = "EVT_IMAGESPRIT_IMAGEURL_LIST"; // 雪碧图图片下载URL
static const String EVT_DRM_TYPE = "EVT_DRM_TYPE"; // 加密类型
/// superplayer plugin volume evnet
static const EVENT_VOLUME_CHANGED = 0x01; // 音量变化
......@@ -149,25 +151,21 @@ class TXLogLevel {
static const int LOG_LEVEL_NULL = 6; // 不输出任何sdk log
}
class TXPlayerAuthParams {
int appId = 0;
String fileId = "";
String timeout = "";
int exper = 0;
String us = "";
String sign = "";
bool https = false;
class TXPlayInfoParams {
final int appId; // Tencent Cloud video appId, required
final String fileId; // Tencent Cloud video fileId, required
final String? psign; // encent cloud video encryption signature, required for encrypted video
const TXPlayInfoParams(
{required this.appId,
required this.fileId,
this.psign});
Map<String, dynamic> toJson() {
Map<String, dynamic> json = {};
json["appId"] = appId;
json["fileId"] = fileId;
json["timeout"] = timeout;
json["exper"] = exper;
json["us"] = us;
json["sign"] = sign;
json["https"] = https;
json["psign"] = psign;
return json;
}
}
}
\ No newline at end of file
......@@ -9,8 +9,8 @@ class FTXVodPlayConfig {
int connectRetryInterval = 3;
// 播放器连接超时时间
int timeout = 10;
// 播放器类型,0 点播,1 直播,2 直播回看
int playerType = 0;
// 仅iOS平台生效 [PlayerType]
int playerType = PlayerType.THUMB_PLAYER;
// 自定义http headers
Map<String, String> headers = {};
// 是否精确seek,默认true
......@@ -68,4 +68,10 @@ class FTXVodPlayConfig {
json["preferredResolution"] = preferredResolution.toString();
return json;
}
}
/// 仅iOS平台有效
class PlayerType {
static const int AVPLAYER = 0; // 系统播放
static const int THUMB_PLAYER = 1; // ThumbPlayer播放器
}
\ No newline at end of file
......@@ -147,15 +147,14 @@ class TXVodPlayerController extends ChangeNotifier implements ValueListenable<TX
}
/// 通过fileld播放视频
/// @params : TXPlayerAuthParams
/// @params : 见[TXPlayInfoParams]
/// return 是否播放成功
Future<bool> startPlayWithParams(TXPlayerAuthParams params) async {
Future<void> startPlayWithParams(TXPlayInfoParams params) async {
await _initPlayer.future;
await _createTexture.future;
_changeState(TXPlayerState.buffering);
final result = await _channel.invokeMethod("startPlayWithParams", params.toJson());
return result == 0;
await _channel.invokeMethod("startPlayWithParams", params.toJson());
}
/// 共享纹理id,原生层的纹理准备好之后,会将纹理id传递回来。
......
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
async:
dependency: transitive
description:
name: async
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.8.2"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.1.0"
characters:
dependency: transitive
description:
name: characters
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.2.0"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.3.1"
clock:
dependency: transitive
description:
name: clock
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.1.0"
collection:
dependency: transitive
description:
name: collection
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.15.0"
fake_async:
dependency: transitive
description:
name: fake_async
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.2.0"
flutter:
dependency: "direct main"
description: flutter
source: sdk
version: "0.0.0"
flutter_test:
dependency: "direct dev"
description: flutter
source: sdk
version: "0.0.0"
matcher:
dependency: transitive
description:
name: matcher
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.12.11"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.7.0"
path:
dependency: transitive
description:
name: path
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.8.0"
sky_engine:
dependency: transitive
description: flutter
source: sdk
version: "0.0.99"
source_span:
dependency: transitive
description:
name: source_span
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.8.1"
stack_trace:
dependency: transitive
description:
name: stack_trace
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.10.0"
stream_channel:
dependency: transitive
description:
name: stream_channel
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.1.0"
string_scanner:
dependency: transitive
description:
name: string_scanner
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.1.0"
term_glyph:
dependency: transitive
description:
name: term_glyph
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.2.0"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.4.3"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.3.0"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.1.1"
sdks:
dart: ">=2.14.0 <3.0.0"
flutter: ">=1.20.0"
English| [简体中文](./README.md)
#### Composition of Player SDK for Flutter plugin
- VOD player SDK
- Live player SDK
- Superplayer component
\ No newline at end of file
简体中文| [English](./README-EN.md)
#### 腾讯云播放器SDK Flutter插件,包括:
- 点播播放器 SDK
- 直播播放器 SDK
- 超级播放器组件
\ No newline at end of file
- 超级播放器组件
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论