提交 369da8b2 authored 作者: kongdywang's avatar kongdywang

1、update to 10.7.0

2、License api upgrade
上级 d260bfe2
......@@ -172,7 +172,7 @@ class _TestState extends State<Test> {
Future<void> initPlayer() async {
await _controller.initialize();
await _controller.startPlay(_url);
await _controller.startVodPlay(_url);
}
@override
......@@ -293,7 +293,7 @@ class _DemoSuperplayerState extends State<DemoSuperplayer> {
}
void playCurrentModel(SuperPlayerModel model) {
_controller.playWithModel(model);
_controller.playWithModelNeedLicence(model);
}
void initData() async {
......@@ -301,7 +301,7 @@ class _DemoSuperplayerState extends State<DemoSuperplayer> {
model.videoURL = "http://1500005830.vod2.myqcloud.com/6c9a5118vodcq1500005830/48d0f1f9387702299774251236/gZyqjgaZmnwA.m4v";
model.playAction = SuperPlayerModel.PLAY_ACTION_AUTO_PLAY;
model.title = "Tencent Cloud Audio/Video";
_controller.playWithModel(model);
_controller.playWithModelNeedLicence(model);
}
@override
......
......@@ -175,7 +175,7 @@ class _TestState extends State<Test> {
Future<void> initPlayer() async {
await _controller.initialize();
await _controller.setConfig(FTXVodPlayConfig());
await _controller.startPlay(_url);
await _controller.startVodPlay(_url);
}
@override
......@@ -303,7 +303,7 @@ class _DemoSuperplayerState extends State<DemoSuperplayer> {
}
void playCurrentModel(SuperPlayerModel model) {
_controller.playWithModel(model);
_controller.playWithModelNeedLicence(model);
}
void initData() async {
......@@ -311,7 +311,7 @@ class _DemoSuperplayerState extends State<DemoSuperplayer> {
model.videoURL = "http://1500005830.vod2.myqcloud.com/6c9a5118vodcq1500005830/48d0f1f9387702299774251236/gZyqjgaZmnwA.m4v";
model.playAction = SuperPlayerModel.PLAY_ACTION_AUTO_PLAY;
model.title = "腾讯云音视频";
_controller.playWithModel(model);
_controller.playWithModelNeedLicence(model);
}
@override
......
......@@ -184,10 +184,10 @@ public class FTXLivePlayer extends FTXBasePlayer implements MethodChannel.Method
boolean loop = call.argument("isAutoPlay");
setIsAutoPlay(loop);
result.success(null);
} else if (call.method.equals("play")) {
} else if (call.method.equals("startLivePlay")) {
String url = call.argument("url");
int type = call.argument("playType");
int r = startPlay(url, type);
int r = startLivePlay(url, type);
result.success(r);
} else if (call.method.equals("stop")) {
Boolean isNeedClear = call.argument("isNeedClear");
......@@ -270,8 +270,8 @@ public class FTXLivePlayer extends FTXBasePlayer implements MethodChannel.Method
private int mSurfaceWidth, mSurfaceHeight = 0;
int startPlay(String url, int type) {
Log.d(TAG, "startPlay:");
int startLivePlay(String url, int type) {
Log.d(TAG, "startLivePlay:");
if (mLivePlayer != null) {
mLivePlayer.setSurface(mSurface);
mLivePlayer.setPlayListener(this);
......@@ -292,7 +292,7 @@ public class FTXLivePlayer extends FTXBasePlayer implements MethodChannel.Method
}
}
}, null);
return mLivePlayer.startPlay(url, type);
return mLivePlayer.startLivePlay(url, type);
}
return Uninitialized;
}
......
......@@ -231,12 +231,12 @@ public class FTXVodPlayer extends FTXBasePlayer implements MethodChannel.MethodC
boolean loop = call.argument("isAutoPlay");
setIsAutoPlay(loop);
result.success(null);
} else if (call.method.equals("play")) {
} else if (call.method.equals("startVodPlay")) {
String url = call.argument("url");
int r = startPlay(url);
int r = startVodPlay(url);
result.success(r);
} else if (call.method.equals("startPlayWithParams")) {
startPlayWithParams(call);
} else if (call.method.equals("startVodPlayWithParams")) {
startVodPlayWithParams(call);
result.success(null);
} else if (call.method.equals("stop")) {
Boolean isNeedClear = call.argument("isNeedClear");
......@@ -385,20 +385,20 @@ public class FTXVodPlayer extends FTXBasePlayer implements MethodChannel.MethodC
}
}
int startPlay(String url) {
int startVodPlay(String url) {
if (mVodPlayer != null) {
return mVodPlayer.startPlay(url);
return mVodPlayer.startVodPlay(url);
}
return Uninitialized;
}
void startPlayWithParams(MethodCall call) {
void startVodPlayWithParams(MethodCall call) {
if (mVodPlayer != null) {
int appId = call.argument("appId");
String fileId = call.argument("fileId");
String psign = call.argument("psign");
TXPlayInfoParams playInfoParams = new TXPlayInfoParams(appId, fileId, psign);
mVodPlayer.startPlay(playInfoParams);
mVodPlayer.startVodPlay(playInfoParams);
}
}
......
......@@ -171,7 +171,7 @@ Future<bool> onWillPop() async {
```dart
SuperPlayerModel model = SuperPlayerModel();
model.videoURL = "http://1400329073.vod2.myqcloud.com/d62d88a7vodtranscq1400329073/59c68fe75285890800381567412/adp.10.m3u8";
_controller.playWithModel(model);
_controller.playWithModelNeedLicence(model);
```
:::
......@@ -181,7 +181,7 @@ SuperPlayerModel model = SuperPlayerModel();
model.appId = 1500005830;
model.videoId = new SuperPlayerVideoId();
model.videoId.fileId = "8602268011437356984";
_controller.playWithModel(model);
_controller.playWithModelNeedLicence(model);
```
Find the target video file in [Media Assets](https://console.cloud.tencent.com/vod/media), and you can view the `FileId` below the filename.
......@@ -192,7 +192,7 @@ Play back the video through the `FileId`, and the player will request the backen
### Step 8. Stop the playback[](id:step8)
**Remember to call the controller termination method** when stopping the playback, especially before the next call of `startPlay`. This can prevent memory leak and screen flashing issues, as well as ensure that playback is stopped when the page is exited.
**Remember to call the controller termination method** when stopping the playback, especially before the next call of `startVodPlay`. This can prevent memory leak and screen flashing issues, as well as ensure that playback is stopped when the page is exited.
```dart
@override
void dispose() {
......@@ -206,6 +206,10 @@ void dispose() {
#### Playing back video
**Notice**
Starting from version 10.7.0, the Licence needs to be set through {@link SuperPlayerPlugin#setGlobalLicense} before it can be played successfully, otherwise the playback will fail (black screen), and it can only be set once globally. Live Licence, UGC Licence, and Player Licence can all be used. If you have not obtained the above Licence, you can quickly apply for a beta Licence for free To play, the official licence needs to be [purchased](https://cloud.tencent.com/document/product/881/74588#.E8.B4.AD.E4.B9.B0.E5.B9.B6.E6.96 .B0.E5.BB.BA.E6.AD.A3.E5.BC.8F.E7.89.88-license).
**Description**
This API is used to start video playback.
......@@ -213,7 +217,7 @@ This API is used to start video playback.
**API**
```dart
_controller.playWithModel(model);
_controller.playWithModelNeedLicence(model);
```
**Parameter description**
......@@ -244,9 +248,9 @@ _controller.playWithModel(model);
3. playAction
* PLAY_ACTION_AUTO_PLAY: The video will be automatically played back after `playWithModel` is called.
* PLAY_ACTION_MANUAL_PLAY: The video needs to be played back manually after `playWithModel` is called. The player doesn't load the video and only displays the thumbnail image, which consumes no video playback resources compared with `PLAY_ACTION_PRELOAD`.
* PLAY_ACTION_PRELOAD: The player will display the thumbnail image and won't start the video playback after `playWithModel` is called, but the video will be loaded. This can start the playback faster than `PLAY_ACTION_MANUAL_PLAY`.
* PLAY_ACTION_AUTO_PLAY: The video will be automatically played back after `playWithModelNeedLicence` is called.
* PLAY_ACTION_MANUAL_PLAY: The video needs to be played back manually after `playWithModelNeedLicence` is called. The player doesn't load the video and only displays the thumbnail image, which consumes no video playback resources compared with `PLAY_ACTION_PRELOAD`.
* PLAY_ACTION_PRELOAD: The player will display the thumbnail image and won't start the video playback after `playWithModelNeedLicence` is called, but the video will be loaded. This can start the playback faster than `PLAY_ACTION_MANUAL_PLAY`.
#### Pausing playback
......@@ -529,7 +533,7 @@ model.title = "VOD";
SuperVodDataLoader loader = SuperVodDataLoader();
// Values of the required parameters in `model` are directly assigned in `SuperVodDataLoader`
loader.getVideoData(model, (resultModel) {
_controller.playWithModel(resultModel);
_controller.playWithModelNeedLicence(resultModel);
})
```
......
......@@ -172,7 +172,7 @@ Future<bool> onWillPop() async {
```dart
SuperPlayerModel model = SuperPlayerModel();
model.videoURL = "http://1400329073.vod2.myqcloud.com/d62d88a7vodtranscq1400329073/59c68fe75285890800381567412/adp.10.m3u8";
_controller.playWithModel(model);
_controller.playWithModelNeedLicence(model);
```
:::
......@@ -182,7 +182,7 @@ SuperPlayerModel model = SuperPlayerModel();
model.appId = 1500005830;
model.videoId = new SuperPlayerVideoId();
model.videoId.fileId = "8602268011437356984";
_controller.playWithModel(model);
_controller.playWithModelNeedLicence(model);
```
[媒资管理](https://console.cloud.tencent.com/vod/media) 找到对应的视频文件。在文件名下方可以看到 FileId。
......@@ -193,7 +193,7 @@ _controller.playWithModel(model);
### 步骤8:结束播放[](id:step8)
结束播放时**记得调用controller的销毁方法**,尤其是在下次 startPlay 之前,否则可能会产生大量的内存泄露以及闪屏问题。也确保在退出页面的时候,能够结束视频播放。
结束播放时**记得调用controller的销毁方法**,尤其是在下次 startVodPlay 之前,否则可能会产生大量的内存泄露以及闪屏问题。也确保在退出页面的时候,能够结束视频播放。
```dart
@override
void dispose() {
......@@ -207,14 +207,18 @@ void dispose() {
#### 视频播放
**注意**
10.7版本开始,startPlay变更为startVodPlay,需要通过 {@link SuperPlayerPlugin#setGlobalLicense} 设置 Licence 后方可成功播放, 否则将播放失败(黑屏),全局仅设置一次即可。直播 Licence、短视频 Licence 和视频播放 Licence 均可使用,若您暂未获取上述 Licence ,可[快速免费申请测试版 Licence](https://cloud.tencent.com/act/event/License) 以正常播放,正式版 License 需[购买](https://cloud.tencent.com/document/product/881/74588#.E8.B4.AD.E4.B9.B0.E5.B9.B6.E6.96.B0.E5.BB.BA.E6.AD.A3.E5.BC.8F.E7.89.88-license)
**说明**
开始播放视频
开始播放视频.
**接口**
```dart
_controller.playWithModel(model);
_controller.playWithModelNeedLicence(model);
```
**参数说明**
......@@ -557,7 +561,7 @@ model.title = "云点播";
SuperVodDataLoader loader = SuperVodDataLoader();
// model中的必要参数会在SuperVodDataLoader中直接赋值
loader.getVideoData(model, (resultModel) {
_controller.playWithModel(resultModel);
_controller.playWithModelNeedLicence(resultModel);
})
```
......
......@@ -184,12 +184,12 @@ await _controller.initialize();
### Step 6. Start the playback[](id:step6)
::: Playback via URL
`TXVodPlayerController` will internally recognize the playback protocol automatically. You only need to pass in your playback URL to the `startPlay` function.
`TXVodPlayerController` will internally recognize the playback protocol automatically. You only need to pass in your playback URL to the `startVodPlay` function.
```dart
// Play back the video resource
String _url =
"http://1400329073.vod2.myqcloud.com/d62d88a7vodtranscq1400329073/59c68fe75285890800381567412/adp.10.m3u8";
await _controller.startPlay(_url);
await _controller.startVodPlay(_url);
```
:::
::: Playback via `fileId`
......@@ -197,7 +197,7 @@ await _controller.startPlay(_url);
TXPlayerAuthParams authParams = TXPlayerAuthParams();
authParams.appId = 1252463788;
authParams.fileId = "4564972819220421305";
await _controller.startPlayWithParams(authParams);
await _controller.startVodPlayWithParams(authParams);
```
Find the target video file in [Media Assets](https://console.cloud.tencent.com/vod/media), and you can view the `FileId` below the filename.
......@@ -206,7 +206,7 @@ Play back the video through the `FileId`, and the player will request the backen
</dx-tabs>
### Step 7. Stop the playback[](id:step7)
**Remember to call the controller termination method** when stopping the playback, especially before the next call of `startPlay`. This can prevent memory leak and screen flashing issues.
**Remember to call the controller termination method** when stopping the playback, especially before the next call of `startVodPlay`. This can prevent memory leak and screen flashing issues.
```dart
@override
void dispose() {
......@@ -232,6 +232,10 @@ await _controller.initialize();
#### Playing back through URL
**Notice**
Starting from version 10.7.0, the Licence needs to be set through {@link SuperPlayerPlugin#setGlobalLicense} before it can be played successfully, otherwise the playback will fail (black screen), and it can only be set once globally. Live Licence, UGC Licence, and Player Licence can all be used. If you have not obtained the above Licence, you can quickly apply for a beta Licence for free To play, the official licence needs to be [purchased](https://cloud.tencent.com/document/product/881/74588#.E8.B4.AD.E4.B9.B0.E5.B9.B6.E6.96 .B0.E5.BB.BA.E6.AD.A3.E5.BC.8F.E7.89.88-license).
**Description**
This API is used to play back a video via URL.
......@@ -239,7 +243,7 @@ This API is used to play back a video via URL.
**API**
```dart
_controller.startPlay(url);
_controller.startVodPlay(url);
```
**Parameter description**
......@@ -250,6 +254,10 @@ _controller.startPlay(url);
#### Playing back via file ID
**Notice**
Starting from version 10.7.0, the Licence needs to be set through {@link SuperPlayerPlugin#setGlobalLicense} before it can be played successfully, otherwise the playback will fail (black screen), and it can only be set once globally. Live Licence, UGC Licence, and Player Licence can all be used. If you have not obtained the above Licence, you can quickly apply for a beta Licence for free To play, the official licence needs to be [purchased](https://cloud.tencent.com/document/product/881/74588#.E8.B4.AD.E4.B9.B0.E5.B9.B6.E6.96 .B0.E5.BB.BA.E6.AD.A3.E5.BC.8F.E7.89.88-license).
**Description**
This API is used to play back a video via `fileId`.
......@@ -260,7 +268,7 @@ This API is used to play back a video via `fileId`.
TXPlayerAuthParams params = TXPlayerAuthParams();
params.appId = 1252463788;
params.fileId = "4564972819220421305";
_controller.startPlayWithParams(params);
_controller.startVodPlayWithParams(params);
```
**Parameter description**
......@@ -320,7 +328,7 @@ _controller.stop();
**Description**
This API is used to set whether to automatically play back the video after calling `startPlay` to load the video URL.
This API is used to set whether to automatically play back the video after calling `startVodPlay` to load the video URL.
**API**
......@@ -739,15 +747,15 @@ This is how seamless switch works in video playback. You can use `isAutoPlay` in
![](https://mc.qcloudimg.com/static/img/7331417ebbdfe6306fe96f4b76c8d0ad/image.jpg)
```dart
// Play back video A: If `isAutoPlay` is set to `true`, the video will be immediately loaded and played back when `startPlay` is called
// Play back video A: If `isAutoPlay` is set to `true`, the video will be immediately loaded and played back when `startVodPlay` is called
String url_A = "http://1252463788.vod2.myqcloud.com/xxxxx/v.f10.mp4";
await _controller_A.setIsAutoPlay(isAutoPlay: true);
await _controller_A.play(url_A);
await _controller_A.startVodPlay(url_A);
// To preload video B when playing back video A, set `isAutoPlay` to `false`
String url_B = "http://1252463788.vod2.myqcloud.com/xxxxx/v.f20.mp4";
await _controller_B.setIsAutoPlay(isAutoPlay: false);
await _controller_B.play(url_B);
await _controller_B.startVodPlay(url_B);
```
After video A ends and video B is automatically or manually switched to, you can call the `resume` function to immediately play back video B.
......
......@@ -184,12 +184,12 @@ await _controller.initialize();
### 步骤6:启动播放[](id:step6)
::: 通过url方式
TXVodPlayerController 内部会自动识别播放协议,您只需要将您的播放 URL 传给 startPlay 函数即可。
TXVodPlayerController 内部会自动识别播放协议,您只需要将您的播放 URL 传给 startVodPlay 函数即可。
```dart
// 播放视频资源
String _url =
"http://1400329073.vod2.myqcloud.com/d62d88a7vodtranscq1400329073/59c68fe75285890800381567412/adp.10.m3u8";
await _controller.startPlay(_url);
await _controller.startVodPlay(_url);
```
:::
::: 通过field方式
......@@ -197,7 +197,7 @@ await _controller.startPlay(_url);
TXPlayerAuthParams authParams = TXPlayerAuthParams();
authParams.appId = 1252463788;
authParams.fileId = "4564972819220421305";
await _controller.startPlayWithParams(authParams);
await _controller.startVodPlayWithParams(authParams);
```
[媒资管理](https://console.cloud.tencent.com/vod/media) 找到对应的视频文件。在文件名下方可以看到 FileId。
......@@ -206,7 +206,7 @@ await _controller.startPlayWithParams(authParams);
</dx-tabs>
### 步骤7:结束播放[](id:step7)
结束播放时**记得调用controller的销毁方法**,尤其是在下次 startPlay 之前,否则可能会产生大量的内存泄露以及闪屏问题。
结束播放时**记得调用controller的销毁方法**,尤其是在下次 startVodPlay 之前,否则可能会产生大量的内存泄露以及闪屏问题。
```dart
@override
void dispose() {
......@@ -232,14 +232,18 @@ await _controller.initialize();
#### url播放
**注意**
10.7版本开始,startPlay变更为startVodPlay,需要通过 {@link SuperPlayerPlugin#setGlobalLicense} 设置 Licence 后方可成功播放, 否则将播放失败(黑屏),全局仅设置一次即可。直播 Licence、短视频 Licence 和视频播放 Licence 均可使用,若您暂未获取上述 Licence ,可[快速免费申请测试版 Licence](https://cloud.tencent.com/act/event/License) 以正常播放,正式版 License 需[购买](https://cloud.tencent.com/document/product/881/74588#.E8.B4.AD.E4.B9.B0.E5.B9.B6.E6.96.B0.E5.BB.BA.E6.AD.A3.E5.BC.8F.E7.89.88-license)
**说明**
通过播视频url进行播放
通过播视频url进行播放
**接口**
```dart
_controller.startPlay(url);
_controller.startVodPlay(url);
```
**参数说明**
......@@ -250,9 +254,13 @@ _controller.startPlay(url);
#### field播放
**注意**
10.7版本开始,startPlay变更为startVodPlay,需要通过 {@link SuperPlayerPlugin#setGlobalLicense} 设置 Licence 后方可成功播放, 否则将播放失败(黑屏),全局仅设置一次即可。直播 Licence、短视频 Licence 和视频播放 Licence 均可使用,若您暂未获取上述 Licence ,可[快速免费申请测试版 Licence](https://cloud.tencent.com/act/event/License) 以正常播放,正式版 License 需[购买](https://cloud.tencent.com/document/product/881/74588#.E8.B4.AD.E4.B9.B0.E5.B9.B6.E6.96.B0.E5.BB.BA.E6.AD.A3.E5.BC.8F.E7.89.88-license)
**说明**
通过视频field进行播放
通过视频field进行播放
**接口**
......@@ -260,7 +268,7 @@ _controller.startPlay(url);
TXPlayerAuthParams params = TXPlayerAuthParams();
params.appId = 1252463788;
params.fileId = "4564972819220421305";
_controller.startPlayWithParams(params);
_controller.startVodPlayWithParams(params);
```
**参数说明**
......@@ -320,7 +328,7 @@ _controller.stop();
**说明**
设置即将播放的视频,在startPlay加载视频地址之后,是否直接自动播放
设置即将播放的视频,在startVodPlay加载视频地址之后,是否直接自动播放
**接口**
......@@ -739,7 +747,7 @@ _controller.onPlayerState.listen((val) { });
![](https://qcloudimg.tencent-cloud.cn/raw/f43ea6105d9f80c4162241ca0605b8f0.png)
```dart
// 播放视频 A: 如果将 isAutoPlay 设置为 true, 那么 startPlay 调用会立刻开始视频的加载和播放
// 播放视频 A: 如果将 isAutoPlay 设置为 true, 那么 startVodPlay 调用会立刻开始视频的加载和播放
String url_A = "http://1252463788.vod2.myqcloud.com/xxxxx/v.f10.mp4";
await _controller_A.setIsAutoPlay(isAutoPlay: true);
await _controller_A.play(url_A);
......
......@@ -79,7 +79,7 @@ Blocks in red are the native code to be written, and blocks in yellow are the in
### Step 3. Start the playback
```dart
String flvUrl = "http://liteavapp.qcloud.com/live/liteavdemoplayerstreamid_demo1080p.flv";
await _controller.play("flvUrl", playType: TXPlayType.LIVE_FLV);
await _controller.startLivePlay("flvUrl", playType: TXPlayType.LIVE_FLV);
```
| Option | Enumerated Value | Description |
......@@ -143,7 +143,7 @@ _controller.switchStream("http://5815.liveplay.myqcloud.com/live/5815_62fe94d692
The time shifting feature allows you to return to any previous time point during a live stream and resume playback from that time point. It is highly suitable for scenarios in which there is no need for interaction but viewers may want to rewind and replay a video, such as sports and gaming events.
```dart
// Call `startPlay` first before setting time shifting
// Call `startLivePlay` first before setting time shifting
// Start playback
await _controller.setAppID(appId); // Configure `appId`
await _controller.prepareLiveSeek(domian, bizidNum); // The backend requests the live streaming start time
......@@ -199,7 +199,7 @@ This feature doesn't need to be enabled in advance, but the live stream must be
The playback URL cannot be a general CDN URL and must carry a hotlink protection signature. For more information on how to calculate a signature, see [Hotlink Protection URL Calculation](https://cloud.tencent.com/document/product/267/32735).
- **ACC must be specified as the playback type**
When calling the `startPlay` playback function, you need to set `type` to **PLAY_TYPE_LIVE_RTMP_ACC**, and the SDK will use the RTMP-UDP protocol to directly pull the live stream.
When calling the `startLivePlay` playback function, you need to set `type` to **PLAY_TYPE_LIVE_RTMP_ACC**, and the SDK will use the RTMP-UDP protocol to directly pull the live stream.
- **It has a limit on the number of streams played back concurrently**
Currently, a maximum of 10 streams can be played back concurrently. Because the cost of low-latency lines is much greater than CDN lines, we encourage users to use this feature only in scenarios that actually require high interaction rather than using it for scenarios which do not require extremely low latency.
......@@ -226,6 +226,10 @@ await _controller.initialize();
#### Playing back through URL
**Notice**
Starting from version 10.7.0, the Licence needs to be set through {@link SuperPlayerPlugin#setGlobalLicense} before it can be played successfully, otherwise the playback will fail (black screen), and it can only be set once globally. Live Licence, UGC Licence, and Player Licence can all be used. If you have not obtained the above Licence, you can quickly apply for a beta Licence for free To play, the official licence needs to be [purchased](https://cloud.tencent.com/document/product/881/74588#.E8.B4.AD.E4.B9.B0.E5.B9.B6.E6.96 .B0.E5.BB.BA.E6.AD.A3.E5.BC.8F.E7.89.88-license).
**Description**
This API is used to play back a video via URL.
......@@ -233,7 +237,7 @@ This API is used to play back a video via URL.
**API**
```dart
_controller.startPlay(url);
_controller.startLivePlay(url);
```
**Parameter description**
......@@ -288,7 +292,7 @@ _controller.stop();
**Description**
This API is used to set whether to automatically play back the video after calling `startPlay` to load the video URL.
This API is used to set whether to automatically play back the video after calling `startLivePlay` to load the video URL.
**API**
......
......@@ -79,7 +79,7 @@ TXLivePlayerController controller = TXLivePlayerController();
### step 3: 启动播放
```dart
String flvUrl = "http://liteavapp.qcloud.com/live/liteavdemoplayerstreamid_demo1080p.flv";
await _controller.play("flvUrl", playType: TXPlayType.LIVE_FLV);
await _controller.startLivePlay("flvUrl", playType: TXPlayType.LIVE_FLV);
```
| 可选值 | 枚举值 | 含义 |
......@@ -143,7 +143,7 @@ _controller.switchStream("http://5815.liveplay.myqcloud.com/live/5815_62fe94d692
时移功能是腾讯云推出的特色能力,可以在直播过程中,随时观看回退到任意直播历史时间点,并能在此时间点一直观看直播。非常适合游戏、球赛等互动性不高,但观看连续性较强的场景。
```dart
// 设置直播回看前,先调用 startPlay
// 设置直播回看前,先调用 startLivePlay
// 开始播放 ...
await _controller.setAppID(appId); // 配置 appId
await _controller.prepareLiveSeek(domian, bizidNum); // 后台请求直播起始时间
......@@ -199,7 +199,7 @@ _controller.setLiveMode(TXPlayerLiveMode.Smooth);
播放 URL 不能用普通的 CDN URL, 必须要带防盗链签名,防盗链签名的计算方法见 [txTime&txSecret](https://cloud.tencent.com/document/product/267/32735)
- **播放类型需要指定 ACC**
在调用 startPlay 函数时,需要指定 type 为 **PLAY_TYPE_LIVE_RTMP_ACC**,SDK 会使用 RTMP-UDP 协议拉取直播流。
在调用 startLivePlay 函数时,需要指定 type 为 **PLAY_TYPE_LIVE_RTMP_ACC**,SDK 会使用 RTMP-UDP 协议拉取直播流。
- **该功能有并发播放限制**
目前最多同时10路并发播放,设置这个限制的原因并非是技术能力限制,而是希望您只考虑在互动场景中使用(例如连麦时只给主播使用, 或者夹娃娃直播中只给操控娃娃机的玩家使用),避免因为盲目追求低延时而产生不必要的费用损失(低延迟线路的价格要贵于 CDN 线路)。
......@@ -226,14 +226,18 @@ await _controller.initialize();
#### url播放
**注意**
10.7版本开始,startPlay变更为startVodPlay,需要通过 {@link SuperPlayerPlugin#setGlobalLicense} 设置 Licence 后方可成功播放, 否则将播放失败(黑屏),全局仅设置一次即可。直播 Licence、短视频 Licence 和视频播放 Licence 均可使用,若您暂未获取上述 Licence ,可[快速免费申请测试版 Licence](https://cloud.tencent.com/act/event/License) 以正常播放,正式版 License 需[购买](https://cloud.tencent.com/document/product/881/74588#.E8.B4.AD.E4.B9.B0.E5.B9.B6.E6.96.B0.E5.BB.BA.E6.AD.A3.E5.BC.8F.E7.89.88-license)
**说明**
通过播视频url进行播放
通过播视频url进行播放
**接口**
```dart
_controller.startPlay(url);
_controller.startLivePlay(url);
```
**参数说明**
......
......@@ -197,7 +197,7 @@ class _DemoSuperplayerState extends State<DemoSuperplayer> {
}
void playCurrentModel(SuperPlayerModel model) {
_controller.playWithModel(model);
_controller.playWithModelNeedLicence(model);
}
void _getLiveListData() async {
......
......@@ -83,7 +83,7 @@ class _DemoTXLivelayerState extends State<DemoTXLivePlayer> with WidgetsBindingO
await _controller.initialize();
await _controller.setConfig(FTXLivePlayConfig());
// 安卓需要设置hls格式才可正常播放
await _controller.startPlay(_url, playType: TXPlayType.LIVE_FLV);
await _controller.startLivePlay(_url, playType: TXPlayType.LIVE_FLV);
}
@override
......@@ -208,7 +208,7 @@ class _DemoTXLivelayerState extends State<DemoTXLivePlayer> with WidgetsBindingO
),
new GestureDetector(
onTap: () async {
_controller.startPlay(_url, playType: TXPlayType.LIVE_FLV);
_controller.startLivePlay(_url, playType: TXPlayType.LIVE_FLV);
},
child: Container(
color: Colors.transparent,
......@@ -303,7 +303,7 @@ class _DemoTXLivelayerState extends State<DemoTXLivePlayer> with WidgetsBindingO
_url = url;
_controller.stop();
if (url.isNotEmpty) {
_controller.startPlay(url);
_controller.startLivePlay(url);
}
}, showFileEdited: false);
});
......
......@@ -85,7 +85,7 @@ class _DemoTXVodlayerState extends State<DemoTXVodPlayer>
await _controller.setAudioPlayoutVolume(volume);
_controller.setConfig(FTXVodPlayConfig());
await _controller.startPlay(_url);
await _controller.startVodPlay(_url);
}
@override
......@@ -327,7 +327,7 @@ class _DemoTXVodlayerState extends State<DemoTXVodPlayer>
double stratTime =
await _controller.getCurrentPlaybackTime();
await _controller.setStartTime(stratTime);
await _controller.startPlay(_url);
await _controller.startVodPlay(_url);
String wareMode = enableHardware ? "硬解" : "软解";
if (enableSuccess) {
EasyLoading.showToast("切换$wareMode成功");
......@@ -400,11 +400,11 @@ class _DemoTXVodlayerState extends State<DemoTXVodPlayer>
_appId = appId;
_fileId = fileId;
if (url.isNotEmpty) {
_controller.startPlay(url);
_controller.startVodPlay(url);
} else if (appId != 0 && fileId.isNotEmpty) {
TXPlayInfoParams params = TXPlayInfoParams(appId: _appId,
fileId: _fileId, psign: pSign != null ? pSign : "");
_controller.startPlayWithParams(params);
_controller.startVodPlayWithParams(params);
}
}, needPisgn: true);
});
......
......@@ -245,8 +245,13 @@ class SuperPlayerController {
});
}
/// 播放视频
Future<void> playWithModel(SuperPlayerModel videoModel) async {
/// 播放视频.
/// 10.7版本开始,playWithModel变更为playWithModelNeedLicence,需要通过 {@link SuperPlayerPlugin#setGlobalLicense} 设置 Licence 后方可成功播放,
/// 否则将播放失败(黑屏),全局仅设置一次即可。直播 Licence、短视频 Licence 和视频播放 Licence 均可使用,若您暂未获取上述 Licence ,
/// 可[快速免费申请测试版 Licence](https://cloud.tencent.com/act/event/License) 以正常播放,
/// 正式版 License 需[购买]
/// (https://cloud.tencent.com/document/product/881/74588#.E8.B4.AD.E4.B9.B0.E5.B9.B6.E6.96.B0.E5.BB.BA.E6.AD.A3.E5.BC.8F.E7.89.88-license)。
Future<void> playWithModelNeedLicence(SuperPlayerModel videoModel) async {
this.videoModel = videoModel;
_playAction = videoModel.playAction;
await resetPlayer();
......@@ -396,10 +401,10 @@ class SuperPlayerController {
query += "spfileid=${videoModel!.videoId!.fileId}" "&spdrmtype=$drmType&spappid=${videoModel!.appId}";
Uri newUri = Uri(path: url, query: query);
LogUtils.d(TAG, 'playVodURL: newurl = ${Uri.decodeFull(newUri.toString())} ;url= $url');
await _vodPlayerController.startPlay(Uri.decodeFull(newUri.toString()));
await _vodPlayerController.startVodPlay(Uri.decodeFull(newUri.toString()));
} else {
LogUtils.d(TAG, "playVodURL url:$url");
await _vodPlayerController.startPlay(url);
await _vodPlayerController.startVodPlay(url);
}
}
......@@ -459,7 +464,7 @@ class SuperPlayerController {
void _playLiveURL(String url, int playType) async {
_currentPlayUrl = url;
_setLiveListener();
bool result = await _livePlayerController.startPlay(url, playType: playType);
bool result = await _livePlayerController.startLivePlay(url, playType: playType);
if (result) {
_updatePlayerState(SuperPlayerState.PLAYING);
} else {
......@@ -632,7 +637,7 @@ class SuperPlayerController {
await _vodPlayerController.stop(isNeedClear: false);
LogUtils.d(TAG, "onQualitySelect quality.url:${videoQuality.url}");
await _vodPlayerController.setStartTime(currentTime);
await _vodPlayerController.startPlay(videoQuality.url);
await _vodPlayerController.startVodPlay(videoQuality.url);
} else {
LogUtils.d(TAG, "setBitrateIndex quality.index:${videoQuality.index}");
await _vodPlayerController.setBitrateIndex(videoQuality.index);
......@@ -726,7 +731,7 @@ class SuperPlayerController {
}
} else {
await _vodPlayerController.enableHardwareDecode(enable);
await playWithModel(videoModel!);
await playWithModelNeedLicence(videoModel!);
}
}
......
......@@ -17,7 +17,6 @@ class VideoBottomView extends StatefulWidget {
class _VideoBottomViewState extends State<VideoBottomView> {
static const TAG = "VideoBottomView";
double _playableProgress = 0;
double _currentDuration = 0;
double _videoDuration = 0;
double _bufferedDuration = 0;
......@@ -33,8 +32,11 @@ class _VideoBottomViewState extends State<VideoBottomView> {
if (widget._playerController.isPrepared) {
_videoDuration = widget._playerController.videoDuration;
_currentDuration = widget._playerController.currentDuration;
_bufferedDuration = 0;
} else if (null != widget._playerController.videoModel) {
_videoDuration = widget._playerController.videoModel!.duration.toDouble();
_currentDuration = 0;
_bufferedDuration = 0;
}
_isPlayMode = (widget._playerController.playerState == SuperPlayerState.PLAYING);
......@@ -179,6 +181,9 @@ class _VideoBottomViewState extends State<VideoBottomView> {
_currentDuration = duration;
_videoDuration = videoDuration;
_bufferedDuration = bufferedDration;
if(_bufferedDuration > _videoDuration) {
_bufferedDuration = _videoDuration;
}
});
}
}
......
......@@ -249,6 +249,6 @@ class _VideoSliderController {
void _checkRange(double value, {String? valueName}) {
if (value < 0.0 || value > 1.0) {
throw ArgumentError("${valueName ?? "value"} must range in 0.0 to 1.0,please check your param");
throw ArgumentError("${valueName ?? "value"} must range in 0.0 to 1.0,please check your param,current is $value");
}
}
......@@ -154,10 +154,10 @@ static const int uninitialized = -1;
return uninitialized;
}
- (int)startPlay:(NSString *)url type:(TX_Enum_PlayType)playType
- (int)startLivePlay:(NSString *)url type:(TX_Enum_PlayType)playType
{
if (_txLivePlayer != nil) {
return [_txLivePlayer startPlay:url type:playType];
return [_txLivePlayer startLivePlay:url type:playType];
}
return uninitialized;
}
......@@ -292,13 +292,13 @@ static const int uninitialized = -1;
BOOL isAutoPlay = [args[@"isAutoPlay"] boolValue];
[self setIsAutoPlay:isAutoPlay];
result(nil);
}else if([@"play" isEqualToString:call.method]){
}else if([@"startLivePlay" isEqualToString:call.method]){
NSString *url = args[@"url"];
int type = -1;
if(![[args objectForKey:@"playType"] isEqual:[NSNull null]]){
type = [args[@"playType"] intValue];
}
int r = [self startPlay:url type:type];
int r = [self startLivePlay:url type:type];
result(@(r));
}else if([@"stop" isEqualToString:call.method]){
BOOL r = [self stopPlay];
......
......@@ -160,16 +160,16 @@ BOOL volatile isStop = false;
}
}
- (int)startPlay:(NSString *)url
- (int)startVodPlay:(NSString *)url
{
if (_txVodPlayer != nil) {
return [_txVodPlayer startPlay:url];
return [_txVodPlayer startVodPlay:url];
}
return uninitialized;
}
- (int)startPlayWithParams:(NSDictionary *)params
- (int)startVodPlayWithParams:(NSDictionary *)params
{
if (_txVodPlayer != nil) {
TXPlayerAuthParams *p = [TXPlayerAuthParams new];
......@@ -179,7 +179,7 @@ BOOL volatile isStop = false;
if (psign.length > 0) {
p.sign = params[@"psign"];
}
return [_txVodPlayer startPlayWithParams:p];
return [_txVodPlayer startVodPlayWithParams:p];
}
return uninitialized;
}
......@@ -304,12 +304,12 @@ BOOL volatile isStop = false;
BOOL isAutoPlay = [args[@"isAutoPlay"] boolValue];
[self setIsAutoPlay:isAutoPlay];
result(nil);
}else if([@"play" isEqualToString:call.method]){
}else if([@"startVodPlay" isEqualToString:call.method]){
NSString *url = args[@"url"];
int r = [self startPlay:url];
int r = [self startVodPlay:url];
result(@(r));
}else if([@"startPlayWithParams" isEqualToString:call.method]) {
int r = [self startPlayWithParams:args];
}else if([@"startVodPlayWithParams" isEqualToString:call.method]) {
int r = [self startVodPlayWithParams:args];
result(@(r));
} else if([@"stop" isEqualToString:call.method]){
BOOL r = [self stopPlay];
......
......@@ -132,19 +132,22 @@ class TXLivePlayerController extends ChangeNotifier implements ValueListenable<T
/// 参考: [PlayType.LIVE_RTMP] ...
@deprecated
Future<bool> play(String url, {int? playType}) async {
return await startPlay(url, playType: playType);
return await startLivePlay(url, playType: playType);
}
///
/// 当设置[LivePlayer] 类型播放器时,需要参数[playType]
/// 参考: [PlayType.LIVE_RTMP] ...
@override
Future<bool> startPlay(String url, {int? playType}) async {
/// 10.7版本开始,startPlay变更为startLivePlay,需要通过 {@link SuperPlayerPlugin#setGlobalLicense} 设置 Licence 后方可成功播放,
/// 否则将播放失败(黑屏),全局仅设置一次即可。直播 Licence、短视频 Licence 和视频播放 Licence 均可使用,若您暂未获取上述 Licence ,
/// 可[快速免费申请测试版 Licence](https://cloud.tencent.com/act/event/License) 以正常播放,正式版 License 需[购买]
/// (https://cloud.tencent.com/document/product/881/74588#.E8.B4.AD.E4.B9.B0.E5.B9.B6.E6.96.B0.E5.BB.BA.E6.AD.A3.E5.BC.8F.E7.89.88-license)。
Future<bool> startLivePlay(String url, {int? playType}) async {
await _initPlayer.future;
await _createTexture.future;
_changeState(TXPlayerState.buffering);
final result = await _channel.invokeMethod("play", {"url": url, "playType": playType});
final result = await _channel.invokeMethod("startLivePlay", {"url": url, "playType": playType});
return result == 0;
}
......
......@@ -10,7 +10,6 @@ abstract class TXPlayerController {
double? get videoRight;
double? get videoBottom;
Future<bool> startPlay(String url);
Future<void> initialize({bool? onlyAudio});
Future<void> setAutoPlay({bool? isAutoPlay});
Future<bool> stop({bool isNeedClear = false});
......
......@@ -133,27 +133,34 @@ class TXVodPlayerController extends ChangeNotifier implements ValueListenable<TX
}
/// 通过url开始播放视频
/// 10.7版本开始,startPlay变更为startVodPlay,需要通过 {@link SuperPlayerPlugin#setGlobalLicense} 设置 Licence 后方可成功播放,
/// 否则将播放失败(黑屏),全局仅设置一次即可。直播 Licence、短视频 Licence 和视频播放 Licence 均可使用,若您暂未获取上述 Licence ,
/// 可[快速免费申请测试版 Licence](https://cloud.tencent.com/act/event/License) 以正常播放,正式版 License 需[购买]
/// (https://cloud.tencent.com/document/product/881/74588#.E8.B4.AD.E4.B9.B0.E5.B9.B6.E6.96.B0.E5.BB.BA.E6.AD.A3.E5.BC.8F.E7.89.88-license)。
/// @param url : 视频播放地址
/// return 是否播放成功
@override
Future<bool> startPlay(String url) async {
Future<bool> startVodPlay(String url) async {
await _initPlayer.future;
await _createTexture.future;
_changeState(TXPlayerState.buffering);
final result = await _channel.invokeMethod("play", {"url": url});
final result = await _channel.invokeMethod("startVodPlay", {"url": url});
return result == 0;
}
/// 通过fileld播放视频
/// 10.7版本开始,startPlayWithParams变更为startVodPlayWithParams,需要通过 {@link SuperPlayerPlugin#setGlobalLicense} 设置 Licence 后方可成功播放,
/// 否则将播放失败(黑屏),全局仅设置一次即可。直播 Licence、短视频 Licence 和视频播放 Licence 均可使用,若您暂未获取上述 Licence ,
/// 可[快速免费申请测试版 Licence](https://cloud.tencent.com/act/event/License) 以正常播放,正式版 License 需[购买]
/// (https://cloud.tencent.com/document/product/881/74588#.E8.B4.AD.E4.B9.B0.E5.B9.B6.E6.96.B0.E5.BB.BA.E6.AD.A3.E5.BC.8F.E7.89.88-license)。
/// @params : 见[TXPlayInfoParams]
/// return 是否播放成功
Future<void> startPlayWithParams(TXPlayInfoParams params) async {
Future<void> startVodPlayWithParams(TXPlayInfoParams params) async {
await _initPlayer.future;
await _createTexture.future;
_changeState(TXPlayerState.buffering);
await _channel.invokeMethod("startPlayWithParams", params.toJson());
await _channel.invokeMethod("startVodPlayWithParams", params.toJson());
}
/// 共享纹理id,原生层的纹理准备好之后,会将纹理id传递回来。
......
name: super_player
description: player plugin.
version: 1.0.5
version: 10.7.0
author:
homepage:
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论