我正在尝试制作一个苹果电视应用程序。
我使用的是tvOS开发者库中的示例代码:
https://developer.apple.com/library/tvos/samplecode/TVMLAudioVideo/Introduction/Intro.html
我想显示来自application.js:的数据
video.title = metadata.title;
video.subtitle = metadata.subtitle;
video.description = metadata.description;
video.artworkImageURL = metadata.artworkImageURL;
var Videos = {
video: [{
title: "AV BipBop",
subtitle: "Sample HLS Stream",
description: "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
artworkImageURL: "",
contentRatingDomain: "movie",
contentRatingRanking: 400,
url: "https://devimages.apple.com.edgekey.net/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8"
}],
在我的index.xml.js 中
/*
Copyright (C) 2015 Apple Inc. All Rights Reserved.
See LICENSE.txt for this sample’s licensing information
Abstract:
A list template shows a list of items on the right, such as movies or TV shows. Focus on one to see its related content on the left, such as its artwork or description.
*/
var Template = function() {
return '<?xml version="1.0" encoding="UTF-8"?>' +
'<document>' +
'<listTemplate>' +
'<list>' +
'<header>' +
'<title>Playback examples</title>' +
'</header>' +
'<section>' +
'<listItemLockup id="video">' +
'<title> (Here video title ) </title>' +
'</listItemLockup>' +
'<listItemLockup id="playlist">' +
'<title>Playlist</title>' +
'</listItemLockup>' +
'</section>' +
'</list>' +
'</listTemplate>' +
'</document>';
}
我试过:${title}和${video.title},但都不起作用。
您试图引用的对象超出范围。您可以修改您的模板,将字典作为参数。
var Template = function(video) {
var doc = '<?xml version="1.0" encoding="UTF-8"?>' +
'<document>' +
'<listTemplate>' +
'<list>' +
'<header>' +
'<title>Playback examples</title>' +
'</header>' +
'<section>' +
'<listItemLockup id="video">' +
'<title>${video["title"]}</title>' +
'</listItemLockup>' +
'<listItemLockup id="playlist">' +
'<title>Playlist</title>' +
'</listItemLockup>' +
'</section>' +
'</list>' +
'</listTemplate>' +
'</document>';
return doc;
}
您需要修改调用以从ResourceLoader.js中创建此模板,如下所示:
var resource = Template.call(self, myVideoDictionary);