1 Star 5 Fork 0

LeanFlutter / flutter_txugcupload

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

flutter_txugcupload

pub version

适用于 Flutter 的腾讯云点播上传 SDK


快速开始

安装

将此添加到包的 pubspec.yaml 文件中:

dependencies:
  flutter_txugcupload: ^0.1.0

dependencies:
  flutter_txugcupload:
    git:
      url: https://github.com/leanflutter/flutter_txugcupload.git
      ref: main

您可以从命令行安装软件包:

$ flutter packages get

集成

如果您在 Podfile 中使用 use_frameworks!,请按以下示例进行修改你的 Podfile 文件。

# 省略上方非关键代码

target 'Runner' do
  use_frameworks!

  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))

  # If you use `use_frameworks!` in your Podfile,
  # uncomment the below $static_framework array and also
  # the pre_install section. 
  $static_framework = ['flutter_txugcupload']
  
  pre_install do |installer|
    Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}
    installer.pod_targets.each do |pod|
        if $static_framework.include?(pod.name)
          def pod.build_type;
            Pod::BuildType.static_library
          end
        end
      end
  end
end

# 省略下方非关键代码

用法

实现一个视频上传进度监听器(TXVideoPublishListener)

class VideoPublishListener extends TXVideoPublishListener {
  final Function(int uploadBytes, int totalBytes) onVideoPublishProgress;
  final Function(TXPublishResult result) onVideoPublishComplete;

  VideoPublishListener({
    this.onVideoPublishProgress,
    this.onVideoPublishComplete,
  });

  @override
  void onPublishProgress(int uploadBytes, int totalBytes) {
    if (this.onVideoPublishProgress == null) return;

    this.onVideoPublishProgress(uploadBytes, totalBytes);
  }

  @override
  void onPublishComplete(TXPublishResult result) {
    if (this.onVideoPublishComplete == null) return;

    this.onVideoPublishComplete(result);
  }
}

上传视频

TXUGCPublish txUgcPublish = TXUGCPublish(customKey: '<customKey>');

TXPublishParam param = TXPublishParam(
  videoPath: '<videoPath>',
  signature: '<signature>',
);
txUgcPublish.setVideoPublishListener(VideoPublishListener(
  onVideoPublishProgress: (uploadBytes, totalBytes) {
    int progress = ((uploadBytes / totalBytes) * 100).toInt();
  },
  onVideoPublishComplete: (result) {
    // 当 result.errCode 为 0 时即为上传成功,更多错误码请查看下方链接
    // https://cloud.tencent.com/document/product/266/9539#.E9.94.99.E8.AF.AF.E7.A0.81
  },
));
txUgcPublish.publishVideo(param);

相关链接

许可证

MIT

MIT License Copyright (c) 2022 LiJianying <lijy91@foxmail.com> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

适用于 Flutter 的腾讯云点播上传 SDK 展开 收起
Dart 等 5 种语言
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Dart
1
https://gitee.com/leanflutter/flutter_txugcupload.git
git@gitee.com:leanflutter/flutter_txugcupload.git
leanflutter
flutter_txugcupload
flutter_txugcupload
main

搜索帮助