将自定义视图从缩略图更改为文本 - Roku Scenegraph Developer Extension SGDEX
Change Custom View from Thumbnail to text - Roku Scenegraph Developer Extension SGDEX
目前 Roku Scenegraph 中的客户模板仅显示来自网格源的缩略图。
我想改用网格提要中的完整描述。我将如何改变它?
从 GridHandler 解析。 (注意下面的描述。现在它显示 hdPosterUrl。我希望 CustomView 显示描述)。
''''
function ParseMediaItemToNode(mediaItem as Object, mediaType as String) as Object
itemNode = Utils_AAToContentNode({
"id": mediaItem.id
"title": mediaItem.title
"hdPosterUrl": mediaItem.thumbnail
"Description": mediaItem.Description
"Categories": mediaItem.genres[0]
})
''''
详情视图(注意下面的自定义和缩略图。需要将缩略图更改为描述)
''''
if currentItem.url <> invalid and currentItem.url <> ""
buttonsToCreate.Push({ title: "Play", id: "play" })
else if details.content.TITLE = "series"
buttonsToCreate.Push({ title: "Episodes", id: "episodes" })
else if details.content.TITLE = "SERIES"
buttonsToCreate.Push({ title: "Episodes", id: "episodes" })
end if
buttonsToCreate.Push({ title: "Custom", id: "thumbnail" })
''''
正在从详细信息视图调用 ID。同样,我需要将 hdPosterURL 更改为文本/描述。
''''
else if selectedButton.id = "thumbnail"
if details.currentItem.hdPosterUrl <> invalid then
ShowCustomView(details.currentItem.hdPosterURL)
end if
else
' handle all other button presses
end if
''''
Custom.xml
''''
<?xml version="1.0" encoding="utf-8" ?>
<component name="custom" extends="Group" >
<interface>
<field id="picPath" type="string" alias="thumbnail.uri" />
</interface>
<children>
<Poster id="thumbnail" translation="[0,0]" width="1280" height="720" />
</children>
</component>
''''
CustomViewLogic.brs
''''
sub ShowCustomView(hdPosterUrl as String)
m.customView = CreateObject("roSGNode", "custom")
m.customView.picPath = hdPosterUrl
m.top.ComponentController.CallFunc("show", {
view: m.customView
})
end sub
''''
马龙!
似乎可以通过像这样更改文件来完成:
将 passed 和 passing param 更改为 description
CustomViewLogic.brs
sub ShowCustomView(description as String)
m.customView = CreateObject("roSGNode", "custom")
m.customView.fullDesc = description
m.top.ComponentController.CallFunc("show", {
view: m.customView
})
end sub
添加标签作为 child ,并删除海报,因为我们不需要任何海报来显示描述文本,并为标签文本添加别名。
custom.xml
<?xml version="1.0" encoding="utf-8" ?>
<component name="custom" extends="Group" >
<interface>
<field id="fullDesc" type="string" alias="fullDescription.text" />
</interface>
<children>
<Label id="fullDescription" translation="[0,0]" width="1280" height="720" wrap="true"/>
</children>
</component>
重命名传递的参数、按钮 ID 和按钮标题
DetailsViewLogic.brs
sub OnDetailsContentSet(event as Object)
details = event.GetRoSGNode()
currentItem = event.GetData()
if currentItem <> invalid
buttonsToCreate = []
if currentItem.url <> invalid and currentItem.url <> ""
buttonsToCreate.Push({ title: "Play", id: "play" })
else if details.content.TITLE = "series"
buttonsToCreate.Push({ title: "Episodes", id: "episodes" })
end if
buttonsToCreate.Push({ title: "Description", id: "description" })
if buttonsToCreate.Count() = 0
buttonsToCreate.Push({ title: "No Content to play", id: "no_content" })
end if
btnsContent = CreateObject("roSGNode", "ContentNode")
btnsContent.Update({ children: buttonsToCreate })
end if
details.buttons = btnsContent
end sub
sub OnButtonSelected(event as Object)
details = event.GetRoSGNode()
selectedButton = details.buttons.GetChild(event.GetData())
if selectedButton.id = "play"
OpenVideoPlayer(details.content, details.itemFocused, details.isContentList)
else if selectedButton.id = "episodes"
if details.currentItem.seasons <> invalid then
ShowEpisodePickerView(details.currentItem.seasons)
end if
else if selectedButton.id = "description"
if details.currentItem.hdPosterUrl <> invalid then
ShowCustomView(details.currentItem.description)
end if
else
' handle all other button presses
end if
end sub
为此,您只需将标签组件添加到自定义屏幕并使用接口将描述传递给自定义屏幕,请参阅:
Custom.xml
<?xml version="1.0" encoding="utf-8" ?>
<component name="custom" extends="Group" >
<interface>
<field id="picPath" type="string" alias="thumbnail.uri" />
<field id="textDescription" type="string" alias="label.text" />
</interface>
<children>
<Poster id="thumbnail" translation="[0,0]" width="1280" height="720" />
<Label id="label" translation="[100,100]" width="1000" wrap="true" />
</children>
</component>
CustomViewLogic.brs
sub ShowCustomView(hdPosterUrl as String, description as String)
m.customView = CreateObject("roSGNode", "custom")
m.customView.picPath = hdPosterUrl
m.customView.textDescription = description
m.top.ComponentController.CallFunc("show", {
view: m.customView
})
end sub
DetailsViewLogic.brs
else if selectedButton.id = "thumbnail"
currentItem = details.currentItem
if currentItem <> invalid then
ShowCustomView(currentItem.hdPosterUrl, currentItem.description)
end if
else
此外,最好从 SGDEX CustomView 扩展自定义组件。
目前 Roku Scenegraph 中的客户模板仅显示来自网格源的缩略图。
我想改用网格提要中的完整描述。我将如何改变它?
从 GridHandler 解析。 (注意下面的描述。现在它显示 hdPosterUrl。我希望 CustomView 显示描述)。
''''
function ParseMediaItemToNode(mediaItem as Object, mediaType as String) as Object
itemNode = Utils_AAToContentNode({
"id": mediaItem.id
"title": mediaItem.title
"hdPosterUrl": mediaItem.thumbnail
"Description": mediaItem.Description
"Categories": mediaItem.genres[0]
})
''''
详情视图(注意下面的自定义和缩略图。需要将缩略图更改为描述)
''''
if currentItem.url <> invalid and currentItem.url <> ""
buttonsToCreate.Push({ title: "Play", id: "play" })
else if details.content.TITLE = "series"
buttonsToCreate.Push({ title: "Episodes", id: "episodes" })
else if details.content.TITLE = "SERIES"
buttonsToCreate.Push({ title: "Episodes", id: "episodes" })
end if
buttonsToCreate.Push({ title: "Custom", id: "thumbnail" })
''''
正在从详细信息视图调用 ID。同样,我需要将 hdPosterURL 更改为文本/描述。
''''
else if selectedButton.id = "thumbnail"
if details.currentItem.hdPosterUrl <> invalid then
ShowCustomView(details.currentItem.hdPosterURL)
end if
else
' handle all other button presses
end if
''''
Custom.xml
''''
<?xml version="1.0" encoding="utf-8" ?>
<component name="custom" extends="Group" >
<interface>
<field id="picPath" type="string" alias="thumbnail.uri" />
</interface>
<children>
<Poster id="thumbnail" translation="[0,0]" width="1280" height="720" />
</children>
</component>
''''
CustomViewLogic.brs
''''
sub ShowCustomView(hdPosterUrl as String)
m.customView = CreateObject("roSGNode", "custom")
m.customView.picPath = hdPosterUrl
m.top.ComponentController.CallFunc("show", {
view: m.customView
})
end sub
''''
马龙! 似乎可以通过像这样更改文件来完成: 将 passed 和 passing param 更改为 description CustomViewLogic.brs
sub ShowCustomView(description as String)
m.customView = CreateObject("roSGNode", "custom")
m.customView.fullDesc = description
m.top.ComponentController.CallFunc("show", {
view: m.customView
})
end sub
添加标签作为 child ,并删除海报,因为我们不需要任何海报来显示描述文本,并为标签文本添加别名。 custom.xml
<?xml version="1.0" encoding="utf-8" ?>
<component name="custom" extends="Group" >
<interface>
<field id="fullDesc" type="string" alias="fullDescription.text" />
</interface>
<children>
<Label id="fullDescription" translation="[0,0]" width="1280" height="720" wrap="true"/>
</children>
</component>
重命名传递的参数、按钮 ID 和按钮标题 DetailsViewLogic.brs
sub OnDetailsContentSet(event as Object)
details = event.GetRoSGNode()
currentItem = event.GetData()
if currentItem <> invalid
buttonsToCreate = []
if currentItem.url <> invalid and currentItem.url <> ""
buttonsToCreate.Push({ title: "Play", id: "play" })
else if details.content.TITLE = "series"
buttonsToCreate.Push({ title: "Episodes", id: "episodes" })
end if
buttonsToCreate.Push({ title: "Description", id: "description" })
if buttonsToCreate.Count() = 0
buttonsToCreate.Push({ title: "No Content to play", id: "no_content" })
end if
btnsContent = CreateObject("roSGNode", "ContentNode")
btnsContent.Update({ children: buttonsToCreate })
end if
details.buttons = btnsContent
end sub
sub OnButtonSelected(event as Object)
details = event.GetRoSGNode()
selectedButton = details.buttons.GetChild(event.GetData())
if selectedButton.id = "play"
OpenVideoPlayer(details.content, details.itemFocused, details.isContentList)
else if selectedButton.id = "episodes"
if details.currentItem.seasons <> invalid then
ShowEpisodePickerView(details.currentItem.seasons)
end if
else if selectedButton.id = "description"
if details.currentItem.hdPosterUrl <> invalid then
ShowCustomView(details.currentItem.description)
end if
else
' handle all other button presses
end if
end sub
为此,您只需将标签组件添加到自定义屏幕并使用接口将描述传递给自定义屏幕,请参阅:
Custom.xml
<?xml version="1.0" encoding="utf-8" ?>
<component name="custom" extends="Group" >
<interface>
<field id="picPath" type="string" alias="thumbnail.uri" />
<field id="textDescription" type="string" alias="label.text" />
</interface>
<children>
<Poster id="thumbnail" translation="[0,0]" width="1280" height="720" />
<Label id="label" translation="[100,100]" width="1000" wrap="true" />
</children>
</component>
CustomViewLogic.brs
sub ShowCustomView(hdPosterUrl as String, description as String)
m.customView = CreateObject("roSGNode", "custom")
m.customView.picPath = hdPosterUrl
m.customView.textDescription = description
m.top.ComponentController.CallFunc("show", {
view: m.customView
})
end sub
DetailsViewLogic.brs
else if selectedButton.id = "thumbnail"
currentItem = details.currentItem
if currentItem <> invalid then
ShowCustomView(currentItem.hdPosterUrl, currentItem.description)
end if
else
此外,最好从 SGDEX CustomView 扩展自定义组件。