2

我正在使用 Wistia API 进行视频上传。该代码似乎很好,根据 Wistia 文档,但是当我上传文件时,它显示进度从 0 到 100%,但在达到 100% 后,哨兵在控制台中记录了以下错误:

Uncaught TypeError: this.wRemoteRequestor.post is not a function

此错误指向以下行中https://fast.wistia.com/assets/external/api.js的 wistia js 文件:

 this.wRemoteRequestor.post(i, {
       dataType: "json",
       success: function(e) {
           r.transformToCreateMediaResponse(e),
           e.data.originalUrl = "".concat(r.generateExtensionlessOriginalUrl(o), ".bin"),
           r.wistiaUploader._onSuccessRaw(e)
       },
       error: function(e) {
           r.wistiaUploader._onError(e)
       }
    })

以下是代码:

 <div id="wistia-upload-widget" style="height:312px; width:500px;"></div>

  // Wistia Video Setup
  window._wapiq = window._wapiq || [];
  _wapiq.push(function(W) {
    window.wistiaUploader = new W.Uploader({
      accessToken: "{{wistia_access_token}}",
      dropIn: "wistia-upload-widget",
      projectId: "{{wistia_project_id}}"
    });

    wistiaUploader.bind("uploadstart", function(file) {
      window.onbeforeunload = confirmLeaveBeforeUpload;
      console.log("Upload has began: ", file);
    });

    wistiaUploader.bind('uploadsuccess', function(file, media) {
      console.log("Upload succeeded.");
     $.ajax({
        type: "POST",
        url: '{% url 'video:create' %}',
        data: {key: media.id},
        success: function (res) {
            window.onbeforeunload = confirmLeaveBeforePublish;
            $('#upload-init').addClass('hide');
            $('#video').val(res.data.pk);
            $('#video-thumbnail').addClass('hide');
            $('#uploaded-video').removeClass('hide');
        },
      });
    });

    wistiaUploader.bind('uploadembeddable', function(file, media, embedCode, oembedResponse) {
      console.log("Embeddable:", media);
    });

    wistiaUploader.bind("uploadfailed", function(file, errorResponse) {
      console.log("Upload failed:", errorResponse.error);
      alert("Unfortunately, your video failed to upload. Please give this information to support: " + errorResponse.error);
      window.onbeforeunload = null;
    });
  });

注意:访问令牌和 project_id 来自 django 并正确放置。

4

1 回答 1

1

看起来这是 Wistia 端的一个问题,因为根据他们的支持进行了更新。似乎总是这样,因为问题出在他们的 api.js 文件中。现在可以了。

于 2022-01-27T06:06:31.410 回答