dongxi7609 2018-06-26 23:39 采纳率: 0%
浏览 74
已采纳

Youtube-Api按钮在ajax调用后不会显示

I am trying to setup a youtube upload for one of my own projects. I am using the sample code from google that can be found here: https://developers.google.com/youtube/v3/code_samples/javascript#upload-a-video

The script to upload videos works perfectly fine. My only problem is the following:

I would like to offer multiple areas for the upload or multiple uploads in other words.

There is the general file that contains the sign-in button and the video upload itself. This file will be loaded into a DIV-container via Ajax. Loading the file works fine as well. The only problem is, that the sign-in button wont show up if the file was being loaded via ajax.

It seems to me that i would have to initialize the api again but even after searching the web for hours i could not fint anything. All i know is, that the following code is loaded by the api automatically:

googleApiClientReady = function() {
    gapi.auth.init(function() {
        window.setTimeout(checkAuth, 1);
    });
}

So i think i need to figure out a way, how to load that function again once the ajax-call is finished. I just can not figure out how. Every time i try to call this function the browser gives me a gapi.client error message.

Does anybody have experience with the youtube api? What am i doing wrong here? Thanks

  • 写回答

1条回答 默认 最新

  • dqan70724 2018-06-27 15:46
    关注

    The answer would be in this line:

    UploadVideo.prototype.handleUploadClicked = function() {
      $('#button').attr('disabled', true);
      this.uploadFile($('#file').get(0).files[0]);
    };
    

    If this function is called after uploading and getting the video data, it will disable the upload button. Just remove that line and you'll be able to upload multiple videos.

    Hope this helps.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥170 如图所示配置eNSP
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改
  • ¥20 wireshark抓不到vlan
  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果