1 В избранное 0 Ответвления 0

OSCHINA-MIRROR/leanflutter-flutter_txugcupload

Присоединиться к Gitlife
Откройте для себя и примите участие в публичных проектах с открытым исходным кодом с участием более 10 миллионов разработчиков. Приватные репозитории также полностью бесплатны :)
Присоединиться бесплатно
Клонировать/Скачать
README.md 4.1 КБ
Копировать Редактировать Web IDE Исходные данные Просмотреть построчно История
gitlife-traslator Отправлено 01.12.2024 06:31 ab01b5a

flutter_txugcupload

pub version

Flutter — это набор инструментов для разработки мобильных приложений под Android и iOS, а также для веб-приложений из единой кодовой базы.

Flutter TXUGCPublish — это пакет для разработчиков на Flutter, который позволяет интегрировать в приложения функции загрузки видео на платформу Tencent Cloud.


  • Быстрое начало
    • Установка

      • Добавление в файл 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
    • Интеграция Если вы используете 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

Опубликовать ( 0 )

Вы можете оставить комментарий после Вход в систему

1
https://api.gitlife.ru/oschina-mirror/leanflutter-flutter_txugcupload.git
git@api.gitlife.ru:oschina-mirror/leanflutter-flutter_txugcupload.git
oschina-mirror
leanflutter-flutter_txugcupload
leanflutter-flutter_txugcupload
main