我有一个视频流应用程序我正在努力让我从listTemplate中选择一年的视频,其中每年都是一个带有视频资源链接的catalogTemplate。 listTemplate和catalogTemplate之间的导航工作正常,但是当我从其中一个catalogTemplates中选择一个视频时,视频会在后面模板中播放,而不是前往前台。我怎么能解决我认为是这样的导航堆栈错误?下面是我用来实际呈现内容的代码,部分来自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);
}
}
}
);
}
},
答案 0 :(得分:0)
一个想法:templateURL
仍指向有效地址,因此所显示功能的下半部分会直接为您的视频添加叠加层?
验证(或确保)只设置两个选项中的一个(videoURL
,templateURL
)。如果之前没有看到loadResource()
,则只运行videoURL
部分。像...
if(videoURL) {
...
} else if (templateURL) {
...
}