提交 549332ed authored 作者: dokieyang's avatar dokieyang

Update ReadMe.md

上级 a679b40a
......@@ -11,12 +11,23 @@ This directory contains the demo source code of the Player SDK for Flutter plugi
├── ios // Demo source code of the Player for iOS plugin
├── lib // Demo source code of the Player for Dart plugin
├── docs // Help documentation
└── example // Superplayer component
├── superplayer_widget // Superplayer component
└── example // Demo code related to player
├── android // Demo source code for Android
├── ios // Demo source code for iOS
└── lib // Code samples for VOD and live players as well as Superplayer
```
## Branch Description
The Flutter player relies on the TXLiteAVSDK. This project provides 3 branches for integration based on business needs:
[main](https://github.com/LiteAVSDK/Player_Flutter/tree/main): relies on the TXLiteAVSDK_Player SDK, which is the default branch.
[Professional](https://github.com/LiteAVSDK/Player_Flutter/tree/Professional): relies on the TXLiteAVSDK_Professional SDK. If the TXLiteAVSDK_Professional SDK has already been integrated into the project, this branch needs to be integrated.
[Player_Premium](https://github.com/LiteAVSDK/Player_Flutter/tree/Player_Premium): relies on the TXLiteAVSDK_Player_Premium SDK, which includes value-added features such as external subtitles and multiple audio tracks, and is supported starting from version 11.7.
## Project Overview
The Player SDK is a subproduct of RT-Cube, which provides VOD and live players based on Tencent Cloud's powerful backend capabilities and AI technologies. It can be used together with VOD or CSS to quickly implement smooth and stable playback for various use cases. It allows you to focus on your business while delivering an ultra fast HD playback experience.
......@@ -43,276 +54,6 @@ In addition, those SDKs require license verification for the video playback feat
If you don't have the necessary license and **need to use the live playback or VOD playback feature in the Player SDK 10.1 or later, you need to purchase the license.** For more information, see [here](https://cloud.tencent.com/document/product/881/74199#.E6.8E.88.E6.9D.83.E8.AF.B4.E6.98.8E). If you don't need to use those features or haven't upgraded the SDK to the latest version, you won't be affected by this change.
## Quick Integration
### Configuring `pubspec.yaml`
Integrate `LiteAVSDK_Player` (which is integrated by default) and add the following configuration to `pubspec.yaml`:
```yaml
super_player:
git:
url: https://github.com/tencentyun/SuperPlayer
path: Flutter
```
To integrate `LiteAVSDK_Professional`, change the configuration in `pubspec.yaml` as follows:
```yaml
super_player:
git:
url: https://github.com/tencentyun/SuperPlayer
path: Flutter
ref: Professional
```
Then, update the dependency package:
```yaml
flutter packages get
```
### Adding native configuration
#### Android configuration
Add the following configuration to the `AndroidManifest.xml` file of Android:
```xml
<!--network permission-->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<!--VOD player floating window permission-->
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<!--storage-->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
```
#### iOS configuration
Add the following configuration to the `Info.plist` file of iOS:
```xml
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
```
iOS natively uses `pod` for dependency. Edit the `podfile` file and specify your player SDK edition. `TXLiteAVSDK_Player` is integrated by default.
```xml
pod 'TXLiteAVSDK_Player' // Player Edition
```
Integrate SDK Professional Edition.
```
pod 'TXLiteAVSDK_Professional' // Professional Edition
```
If no edition is specified, the latest version of `TXLiteAVSDK_Player` will be installed by default.
### FAQs about integration
Run the `flutter doctor` command to check the runtime environment until "No issues found!" is displayed.
Run `flutter pub get` to ensure that all dependent components have been updated successfully.
## Applying for and Integrating Video Playback License
If you have the required license, you need to get the license URL and key in the [RT-Cube console](https://console.cloud.tencent.com/vcube).
[![image](https://user-images.githubusercontent.com/88317062/169646279-929248e3-8ded-4b9e-8b04-2b6e462054a0.png)](https://user-images.githubusercontent.com/88317062/169646279-929248e3-8ded-4b9e-8b04-2b6e462054a0.png)
If you don't have the required license, you need to get it as instructed in [Video Playback License](https://cloud.tencent.com/document/product/881/74588).
To integrate a player, you need to [sign up for a Tencent Cloud account](https://cloud.tencent.com/login), apply for the video playback license, and then integrate the license as follows. We recommend you integrate it during application start.
If no license is integrated, exceptions may occur during playback.
```dart
String licenceURL = ""; // The obtained license URL
String licenceKey = ""; // The obtained license key
SuperPlayerPlugin.setGlobalLicense(licenceURL, licenceKey);
```
## Using the VOD Player
The core class of the VOD player is `TXVodPlayerController`. For the detailed demo, see `DemoTXVodPlayer`.
```dart
import 'package:flutter/material.dart';
import 'package:super_player/super_player.dart';
class Test extends StatefulWidget {
@override
State<StatefulWidget> createState() => _TestState();
}
class _TestState extends State<Test> {
late TXVodPlayerController _controller;
double _aspectRatio = 16.0 / 9.0;
String _url =
"http://1400329073.vod2.myqcloud.com/d62d88a7vodtranscq1400329073/59c68fe75285890800381567412/adp.10.m3u8";
@override
void initState() {
super.initState();
String licenceUrl = ""; // The obtained license URL
String licenseKey = ""; // The obtained license key
SuperPlayerPlugin.setGlobalLicense(licenceUrl, licenseKey);
_controller = TXVodPlayerController();
initPlayer();
}
Future<void> initPlayer() async {
await _controller.initialize();
await _controller.startVodPlay(_url);
}
@override
Widget build(BuildContext context) {
return Container(
height: 220,
color: Colors.black,
child: AspectRatio(aspectRatio: _aspectRatio, child: TXPlayerVideo(controller: _controller)));
}
}
```
## Using Superplayer
The core class of Superplayer is `SuperPlayerVideo`, and videos can be played back after it is created.
```dart
import 'package:flutter/material.dart';
import 'package:super_player/super_player.dart';
/// flutter superplayer demo
class DemoSuperplayer extends StatefulWidget {
@override
State<StatefulWidget> createState() => _DemoSuperplayerState();
}
class _DemoSuperplayerState extends State<DemoSuperplayer> {
List<SuperPlayerModel> videoModels = [];
bool _isFullScreen = false;
SuperPlayerController _controller;
@override
void initState() {
super.initState();
String licenceUrl = "Enter the URL of the purchased license";
String licenseKey = "Enter the license key";
SuperPlayerPlugin.setGlobalLicense(licenceUrl, licenseKey);
_controller = SuperPlayerController(context);
FTXVodPlayConfig config = FTXVodPlayConfig();
config.preferredResolution = 720 * 1280;
_controller.setPlayConfig(config);
_controller.onSimplePlayerEventBroadcast.listen((event) {
String evtName = event["event"];
if (evtName == SuperPlayerViewEvent.onStartFullScreenPlay) {
setState(() {
_isFullScreen = true;
});
} else if (evtName == SuperPlayerViewEvent.onStopFullScreenPlay) {
setState(() {
_isFullScreen = false;
});
} else {
print(evtName);
}
});
initData();
}
@override
Widget build(BuildContext context) {
return WillPopScope(
child: Container(
child: Scaffold(
backgroundColor: Colors.transparent,
appBar: _isFullScreen
? null
: AppBar(
backgroundColor: Colors.transparent,
title: const Text('SuperPlayer'),
),
body: SafeArea(
child: Builder(
builder: (context) => getBody(),
),
),
),
),
onWillPop: onWillPop);
}
Future<bool> onWillPop() async {
return !_controller.onBackPress();
}
Widget getBody() {
return Column(
children: [_getPlayArea()],
);
}
Widget _getPlayArea() {
return SuperPlayerView(_controller);
}
Widget _getListArea() {
return Container(
margin: EdgeInsets.only(top: 10),
child: ListView.builder(
itemCount: videoModels.length,
itemBuilder: (context, i) => _buildVideoItem(videoModels[i]),
),
);
}
Widget _buildVideoItem(SuperPlayerModel playModel) {
return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ListTile(
leading: Image.network(playModel.coverUrl),
title: new Text(
playModel.title,
style: TextStyle(color: Colors.white),
),
onTap: () => playCurrentModel(playModel)),
Divider()
],
);
}
void playCurrentModel(SuperPlayerModel model) {
_controller.playWithModelNeedLicence(model);
}
void initData() async {
SuperPlayerModel model = SuperPlayerModel();
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.playWithModelNeedLicence(model);
}
@override
void dispose() {
// must invoke when page exit.
_controller.releasePlayer();
super.dispose();
}
}
```
## Custom Development Guide
The Player SDK for Flutter plugin encapsulates native player capabilities. We recommend you use the following methods for deep custom development:
......
......@@ -30,6 +30,16 @@
└── lib // 点播播放、直播播放、播放器组件使用例子
```
## 分支说明
Flutter 播放器依赖 TXLiteAVSDK,此工程提供 3 个分支,请根据业务需要进行集成:
[main](https://github.com/LiteAVSDK/Player_Flutter/tree/main):依赖 TXLiteAVSDK_Player SDK,默认分支。
[Professional](https://github.com/LiteAVSDK/Player_Flutter/tree/Professional):依赖 TXLiteAVSDK_Professional SDK,如果项目中已经集成 TXLiteAVSDK_Professional SDK ,则需要集成此分支。
[Player_Premium](https://github.com/LiteAVSDK/Player_Flutter/tree/Player_Premium): 依赖 TXLiteAVSDK_Player_Premium SDK,包含外挂字幕、多音轨等增值功能,从 11.7 版本开始支持。
## Flutter播放器简介
腾讯云视立方·播放器 SDK 是音视频终端 SDK(腾讯云视立方)的子产品 SDK 之一,基于腾讯云强大的后台能力与 AI 技术,提供视频点播和直播播放能力的强大播放载体。结合腾讯云点播或云直播使用,可以快速体验流畅稳定的播放性能。充分覆盖多类应用场景,满足客户多样需求,让客户轻松聚焦于业务发展本身,畅享极速高清播放新体验。
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论