import 'package:universal_html/js.dart';

class TcVod {
  final JsObject _uploader;

  TcVod(Function getSignature, dynamic fileRaw)
      : _uploader = context.callMethod('createTcVodInstance', [
          getSignature,
          fileRaw,
        ]) as JsObject;

  // 添加您需要实现的功能和对应的方法，例如：
  void addMediaProgressListener(Function(double) listener) {
    context.callMethod('addMediaProgressListener', [
      _uploader,
      allowInterop((double progress) {
        listener(progress);
      }),
    ]);
  }

  void onDone(Function(String) listener) {
    context.callMethod('onDone', [
      _uploader,
      allowInterop((String fileObj) {
        listener(fileObj);
      }),
    ]);
  }

  void addMediaUploadResumeListener(Function() listener) {
    context.callMethod('addMediaUploadResumeListener', [
      _uploader,
      allowInterop(listener),
    ]);
  }

  void cancelUpload() {
    context.callMethod('cancelUpload', [_uploader]);
  }

  void resumeUpload() {
    context.callMethod('resumeUpload', [_uploader]);
  }
}
