0

我有一个正在开发的视频流应用程序,它可以让我从 listTemplate 中选择一年的视频,然后每年都是一个 catalogTemplate,其中包含指向视频资源的链接。listTemplate 和 catalogTemplate 之间的导航可以正常工作,但是当我从其中一个 catalogTemplate 中选择视频时,视频会在模板后面播放,而不是在前台播放。如何修复我认为是这样的导航堆栈错误?下面是我用来实际展示内容的代码,部分取自 Apple 的文档。

load: function(event) {
      console.log(event);

      var self = this,
          ele = event.target,
          templateURL = ele.getAttribute("template"),
          presentation = ele.getAttribute("presentation"),
          videoURL = ele.getAttribute("videoURL");

      if(videoURL) {
        //2
        var player = new Player();
        var playlist = new Playlist();
        var mediaItem = new MediaItem("video", videoURL);

        player.playlist = playlist;
        player.playlist.push(mediaItem);
        player.present();
      };

      /*
      Check if the selected element has a 'template' attribute. If it does then we begin
      the process to present the template to the user.
      */
      if (templateURL) {
          /*
          Whenever a user action is taken you need to visually indicate to the user that
          you are processing their action. When a users action indicates that a new document
          should be presented you should first present a loadingIndicator. This will provide
          the user feedback if the app is taking a long time loading the data or the next 
          document.
          */
          self.showLoadingIndicator(presentation);

          /* 
          Here we are retrieving the template listed in the templateURL property.
          */
          resourceLoader.loadResource(templateURL,
              function(resource) {
                  if (resource) {
                      /*
                      The XML template must be turned into a DOMDocument in order to be 
                      presented to the user. See the implementation of makeDocument below.
                      */
                      var doc = self.makeDocument(resource);

                      /*
                      Event listeners are used to handle and process user actions or events. Listeners
                      can be added to the document or to each element. Events are bubbled up through the
                      DOM heirarchy and can be handled or cancelled at at any point.

                      Listeners can be added before or after the document has been presented.

                      For a complete list of available events, see the TVMLKit DOM Documentation.
                      */
                      doc.addEventListener("select", self.load.bind(self));
                      // doc.addEventListener("highlight", self.load.bind(self));


                      /*
                      This is a convenience implementation for choosing the appropriate method to 
                      present the document. 
                      */
                      if (self[presentation] instanceof Function) {
                          self[presentation].call(self, doc, ele);
                      } else {
                          self.defaultPresenter.call(self, doc);
                      }
                  }
              }
          );
      }
  },
4

1 回答 1

0

一个想法:templateURL仍然指向一个有效的地址,因此您显示的功能的下部将直接为您的视频添加覆盖?

验证(或确保)仅设置两个选项 ( videoURL, templateURL) 之一。或者,如果之前没有看到过,则只运行该loadResource()部分。videoURL喜欢...

if(videoURL) {
    ...
} else if (templateURL) {
    ...
}
于 2016-01-18T19:35:36.847 回答