<bdo id='JmA8H'></bdo><ul id='JmA8H'></ul>

        <tfoot id='JmA8H'></tfoot>

      1. <small id='JmA8H'></small><noframes id='JmA8H'>

        <i id='JmA8H'><tr id='JmA8H'><dt id='JmA8H'><q id='JmA8H'><span id='JmA8H'><b id='JmA8H'><form id='JmA8H'><ins id='JmA8H'></ins><ul id='JmA8H'></ul><sub id='JmA8H'></sub></form><legend id='JmA8H'></legend><bdo id='JmA8H'><pre id='JmA8H'><center id='JmA8H'></center></pre></bdo></b><th id='JmA8H'></th></span></q></dt></tr></i><div id='JmA8H'><tfoot id='JmA8H'></tfoot><dl id='JmA8H'><fieldset id='JmA8H'></fieldset></dl></div>
      2. <legend id='JmA8H'><style id='JmA8H'><dir id='JmA8H'><q id='JmA8H'></q></dir></style></legend>

      3. 使用 javascript 上传 Youtube 视频

        时间:2023-09-06

            <tbody id='nJ67r'></tbody>
          <i id='nJ67r'><tr id='nJ67r'><dt id='nJ67r'><q id='nJ67r'><span id='nJ67r'><b id='nJ67r'><form id='nJ67r'><ins id='nJ67r'></ins><ul id='nJ67r'></ul><sub id='nJ67r'></sub></form><legend id='nJ67r'></legend><bdo id='nJ67r'><pre id='nJ67r'><center id='nJ67r'></center></pre></bdo></b><th id='nJ67r'></th></span></q></dt></tr></i><div id='nJ67r'><tfoot id='nJ67r'></tfoot><dl id='nJ67r'><fieldset id='nJ67r'></fieldset></dl></div>
          <tfoot id='nJ67r'></tfoot>

            <bdo id='nJ67r'></bdo><ul id='nJ67r'></ul>

            <small id='nJ67r'></small><noframes id='nJ67r'>

                  <legend id='nJ67r'><style id='nJ67r'><dir id='nJ67r'><q id='nJ67r'></q></dir></style></legend>
                1. 本文介绍了使用 javascript 上传 Youtube 视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试使用 javascript 制作基于浏览器的 youtube 视频上传器.

                  我正在使用 (源文件位于 https://code.google.com/p/youtube-api-samples/source/browse/#git%2Fyt-upload-javascript)显示上传流程,使用 Google+ 登录按钮处理 OAuth 2(如果您愿意,可以使用普通的 OAuth 2 浏览器客户端流程)并带有进度指示器.它还展示了如何在上传后轮询视频处理状态,并在处理后将生成的视频嵌入页面.

                  I am trying to make a browser based youtube video uploader using javascript.

                  I am using sample code from here

                  After authentication when I upload video, POST request to youtube server never ends and video is not uploaded.

                  This is happening in the sample provided by google too.

                  Here is the function that i am using to upload video:

                  $('#upload').click(function(){
                      $('#upload').attr('disabled', true);
                  
                      var title = escapeXmlEntities($('#title').val());
                      var description = escapeXmlEntities($('#description').val());
                      var category = escapeXmlEntities($('#category option:selected').val());
                  
                      var xmlBody = '<?xml version="1.0"?> <entry xmlns="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" xmlns:yt="http://gdata.youtube.com/schemas/2007"> <media:group> <media:title type="plain">' + title + '</media:title> <media:description type="plain">' + description + '</media:description> <media:category scheme="http://gdata.youtube.com/schemas/2007/categories.cat">' + category + '</media:category> </media:group> </entry>';
                      showMsg("Submitting metadata of video to get upload token.");
                      $.ajax({
                          dataType: 'xml',
                          type: 'POST',
                          url: 'https://gdata.youtube.com/action/GetUploadToken',
                          contentType: 'application/atom+xml; charset=UTF-8',
                          processData: false,
                          headers: generateYouTubeApiHeaders(),
                          data: xmlBody,
                          success: function(responseXml) {
                              var xml = $(responseXml);
                              var nextUrl = window.location.href;
                              var submissionUrl = xml.find('url').text() + '?nexturl=' + encodeURIComponent(nextUrl);
                              var token = xml.find('token').text();
                  
                              showMsg("Uploading Video...");
                              $('#form_upload').attr('action', submissionUrl);
                              $('<input>').attr({
                                  type: 'hidden',
                                  name: 'token',
                                  value: token
                              }).appendTo('#form_upload');
                              $('#form_upload').submit();
                          },
                          error: function(jqXHR) {
                              showMsg('Metadata submission failed: ' + jqXHR.responseText);
                              $('#upload').removeAttr('disabled');
                              $('#upload').val('Upload');
                          }
                      });
                  });
                  

                  Here is the firebug screenshot of the last POST request made to youtube server that is never ending.

                  Moreover I want to get the progress of the video upload and show it using javascript but I don't know how to achieve it I googled and found many methods but nothing was successful for me.

                  解决方案

                  There's now support for resumable uploads using CORS in the YouTube Data API v3.

                  A rough, but working, example at https://youtube-api-samples.googlecode.com/git/yt-upload-javascript/index.html (source files at https://code.google.com/p/youtube-api-samples/source/browse/#git%2Fyt-upload-javascript) that shows the upload flow, using the Google+ sign-in button to handle OAuth 2 (you can use the normal OAuth 2 browser client flow if you'd prefer) and with a progress indicator. It also shows how you could poll for video processing status following an upload and embed the resulting video on a page once it's been processed.

                  这篇关于使用 javascript 上传 Youtube 视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:youtube api v3 按关键字搜索 javascript 下一篇:为什么 YouTube JavaScript Player API 打开一个与我的代码不同的 URL,只播放播放列表的第

                  相关文章

                  <tfoot id='vIbHS'></tfoot>

                  <small id='vIbHS'></small><noframes id='vIbHS'>

                        <bdo id='vIbHS'></bdo><ul id='vIbHS'></ul>

                      <i id='vIbHS'><tr id='vIbHS'><dt id='vIbHS'><q id='vIbHS'><span id='vIbHS'><b id='vIbHS'><form id='vIbHS'><ins id='vIbHS'></ins><ul id='vIbHS'></ul><sub id='vIbHS'></sub></form><legend id='vIbHS'></legend><bdo id='vIbHS'><pre id='vIbHS'><center id='vIbHS'></center></pre></bdo></b><th id='vIbHS'></th></span></q></dt></tr></i><div id='vIbHS'><tfoot id='vIbHS'></tfoot><dl id='vIbHS'><fieldset id='vIbHS'></fieldset></dl></div>
                    1. <legend id='vIbHS'><style id='vIbHS'><dir id='vIbHS'><q id='vIbHS'></q></dir></style></legend>