1

基本上我想重定向到 Youtube 上传小部件( https://developers.google.com/youtube/youtube_upload_widget )的 onProcessingComplete 中的其他页面(例如http://www.mysiteurl.com/)。

这是我的代码:

   <!DOCTYPE html>
<html>
  <body>
    <!-- 1. The 'widget' div element will contain the upload widget.
         The 'player' div element will contain the player IFrame. -->
    <div id="widget"></div>
    <div id="player"></div>

    <script>
      // 2. Asynchronously load the Upload Widget and Player API code.
      var tag = document.createElement('script');
      tag.src = "https://www.youtube.com/iframe_api";
      var firstScriptTag = document.getElementsByTagName('script')[0];
      firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);

      // 3. Define global variables for the widget and the player.
      //    The function loads the widget after the JavaScript code
      //    has downloaded and defines event handlers for callback
      //    notifications related to the widget.
      var widget;
      var player;
      function onYouTubeIframeAPIReady() {
        widget = new YT.UploadWidget('widget', {
          width: 500,
          events: {
            'onUploadSuccess': onUploadSuccess,
            'onProcessingComplete': onProcessingComplete
          }
        });
      }

      // 4. This function is called when a video has been successfully uploaded.
      function onUploadSuccess(event) {
        alert('Video ID ' + event.data.videoId + ' was uploaded and is currently being processed.');
      }

      // 5. This function is called when a video has been successfully
      //    processed.
      function onProcessingComplete(event) {
        player = new YT.Player('player', {
          height: 390,
          width: 640,
          videoId: event.data.videoId,
          events: {}
        });
      }
    </script>
  </body>
</html>

但我不知道在捕获网络摄像头视频后做重定向(我认为要更改的事件是 onProcessingComplete)。

谢谢!

4

1 回答 1

1

我想如果你只是想在上传视频后重定向页面,那么正确的事件是:

上传成功

这样:

// 4. This function is called when a video has been successfully uploaded.
      function onUploadSuccess(event) {
        window.location = "http://www.mysiteurl.com/";
      }
于 2013-05-30T13:50:04.400 回答