SDK Name | Cloud Video on Demand Flutter Upload SDK |
Version Number | V1.0.0 |
SDK Introduction | Provides a scenario for app end-users to upload local videos to the Cloud Video on Demand platform. |
Download SDK | 1. Click to download the Flutter Upload SDK and source code, unzip the downloaded compressed package, and you can see the vod_upload directory. 2. The upload source code is located in the vod_upload/lib directory. |
pubspec.yaml
vod_upload_flutter:path: ./vod_upload
flutter pub get
in the root directory of your project to refresh the dependencies.flutter pub get
command separately in the root directory
, SDK directory
, and SDK Example directory
to avoid potential errors.SDK Example directory
is the test project for the SDK. You can delete it if not needed.AndroidManifest.xml
.<!-- Network permissions --><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" />
Info.plist
in iOS
.<key>NSAppTransportSecurity</key><dict><key>NSAllowsArbitraryLoads</key><true/></dict>
Demo
in the SDK
, you should also declare permission to use the photo library.import 'package:vod_upload_flutter/txugc_publish.dart';
var uploader = TXUGCPublish(id: "",);
id
can be any string as long as it is unique
. The main purpose is to map the Flutter object to the native layer object.uploader.publishVideo(TXPublishParam(signature: "",videoPath: "",fileName: "",));
uploader.cancelUploadVideo();
uploader.resumeUploadVideo(TXPublishParam(signature: "",videoPath: "",fileName: "",));
uploader.publishMedia(TXMediaPublishParam(signature: "",mediaPath: "",fileName: "",));
uploader.cancelUploadMedia();
uploader.resumeUploadMedia(TXMediaPublishParam(signature: "",mediaPath: "",fileName: "",));
TXUGCPublish.prepareUpload(signature, callback);
static method
.// On Android, you can only get information during the upload process, while on iOS, you can get information throughout the process.uploader.getStatusInfo();
AppId
uploader.setAppId(appId);
uploader.setVideoListener(listener);
uploader.setMediaListener(listener);
TXPublishParam
Field | Type | Required | Explanation | Default Value |
signature | string | Yes | Signature | null |
videoPath | string | Yes | Video path | null |
fileName | string | Yes | File name | null |
enableResume | boolean | No | Enable resumable upload | true |
enableHttps | boolean | No | Enable HTTPS | false |
coverPath | string | No | Cover image | null |
enablePreparePublish | boolean | No | Enable prepare upload (can be manually triggered if disabled) | true |
sliceSize | integer | No | Chunk size (minimum 1M, maximum 10M, default 0, which means the file size divided by 10) | 0 |
concurrentCount | integer | No | Concurrent number of chunk uploads (if <=0, the default value of 2 will be used) | -1 |
TXMediaPublishParam
Field | Type | Required | Explanation | Default Value |
signature | string | Yes | Signature | null |
mediaPath | string | Yes | Media file path | null |
fileName | string | Yes | File name | null |
enableResume | boolean | No | Enable resumable upload | true |
enableHttps | boolean | No | Enable HTTPS | false |
coverPath | string | No | Cover image | null |
enablePreparePublish | boolean | No | Enable prepare upload (can be manually triggered if disabled) | true |
sliceSize | integer | No | Chunk size (minimum 1M, maximum 10M, default 0, which means the file size divided by 10) | 0 |
concurrentCount | integer | No | Concurrent number of chunk uploads (if <=0, the default value of 2 will be used) | -1 |
ITXVideoPublishListener
Method | Return Type | Explanation |
onPublishProgress | void | Upload progress callback |
onPublishComplete | void | Upload completion callback |
onPublishProgress
Parameter | Type | Explanation |
uploadBytes | integer | Number of bytes uploaded |
totalBytes | integer | Total number of bytes |
onPublishComplete
Parameter | Type | Explanation |
result | TXPublishResult | Upload result |
TXPublishResult
Parameter | Type | Explanation |
retCode | integer | Error code |
descMsg | string | Error description |
videoId | string | Video file ID |
videoURL | string | Video playback URL |
coverURL | string | Cover image storage URL |
ITXMediaPublishListener
Method | Return Type | Explanation |
onMediaPublishProgress | void | Upload progress callback |
onMediaPublishComplete | void | Upload completion callback |
onMediaPublishProgress
Parameter | Type | Explanation |
uploadBytes | integer | Number of bytes uploaded |
totalBytes | integer | Total number of bytes |
onMediaPublishComplete
Parameter | Type | Explanation |
result | TXMediaPublishResult | Upload result |
TXMediaPublishResult
Parameter | Type | Explanation |
retCode | integer | Error code |
descMsg | string | Error description |
mediaId | string | Media file ID |
mediaURL | string | Media file URL |
IPrepareUploadCallback
Method | Return Type | Explanation |
onLoading | void | Prepare upload start callback |
onFinish | void | Prepare upload completion callback |
ReportInfo
Field | Type | Explanation |
reqType | string | Request type, indicating the current step |
errCode | string | Error code |
cosErrCode | string | COS upload error code |
errMsg | string | Error message |
reqTime | string | Request start time for the current step |
reqTimeCost | string | Time spent on the current step |
fileSize | string | File size |
fileType | string | File type |
fileName | string | File name |
fileId | string | File ID |
appId | string | VOD App ID set through TXUGCPublish |
reqServerIp | string | IP address accessed during the current step |
reportId | string | Custom report ID provided by the customer, can be passed through the TXUGCPublish constructor |
reqKey | string | Request key, usually composed of the last modification time of the file and the start time of this upload |
vodSessionKey | string | Session key from the VOD server, obtained from the upload request interface |
cosRegion | string | Region accessed during the current upload |
requestId | string | Request ID for the current COS upload |
cosVideoPath | string | Path for the current COS video upload |
vodErrCode | integer | Signaling request error code |
useHttpDNS | integer | Whether to use httpDns for domain name resolution |
useCosAcc | integer | Whether COS domain name acceleration is enabled |
tcpConnTimeCost | integer | Time spent on connecting to the server in the current step |
recvRespTimeCost | integer | Time spent on receiving server response in the current step |
この記事はお役に立ちましたか?