在哪里调用widget.setVideoTitle(标题)

时间:2013-02-01 16:45:27

标签: youtube youtube-api

我可以在google提供的示例中调用widget.setVideoTitle(title):

<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 = "//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>

聚苯乙烯。 onProcessingComplete根本不起作用,如果注释它对上传没有任何影响,所以我不会在处理时返回任何消息.....

1 个答案:

答案 0 :(得分:0)

您应该可以在上传开始之前在onApiReady中设置它。有关示例,请参阅http://code.google.com/p/youtube-direct-lite/source/browse/static/js/ytdl/panels/webcam.js