Измените пользовательский вид с эскиза на текст - расширение разработчика сценографа Roku 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" })
''''

Вызов идентификатора из представления сведений. Опять же, мне нужно изменить 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
''''

person MarlonC    schedule 15.10.2019    source источник


Ответы (2)


Марлон! Похоже, это можно сделать, изменив файлы, например: Изменить переданный и передать параметр в 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

Добавьте ярлык как дочерний и удалите плакат, поскольку нам не нужен плакат для отображения текста описания, и добавьте псевдоним для текста ярлыка. 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>

переименовать переданные параметры, идентификатор кнопки и заголовок кнопки 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
person hornyhedgehog    schedule 18.10.2019
comment
Добро пожаловать в SO! Пожалуйста, отвечая на вопрос, старайтесь не просто давать код, а что-то объяснять. - person David García Bodego; 18.10.2019
comment
Спасибо, Дэвид. Обновленный ответ с комментариями. - person hornyhedgehog; 18.10.2019
comment
Спасибо за ваш ответ. Не следует ли также изменить недопустимый элемент details.currentItem.hdPosterUrl ‹› на details.currentItem.description ‹›? - person MarlonC; 18.10.2019
comment
Я пробую сейчас и обновлю соответственно. Спасибо. - person MarlonC; 18.10.2019
comment
Triple H. Кажется, ваш ответ сработает. Но это только сейчас работает. Когда я нажимаю кнопку «Описание», ничего не происходит. и приложение зависает. - person MarlonC; 18.10.2019
comment
Ничего. Ваше предложение отлично сработало. У меня был fullDescription.txt вместо fullDescription.text. Я готов идти. Спасибо за вашу помощь. - person MarlonC; 18.10.2019

Для этого вам нужно просто добавить компонент метки на свой настраиваемый экран и передать описание на настраиваемый экран с помощью интерфейса, см.

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.

person Vadym    schedule 18.10.2019
comment
Добро пожаловать в SO! Пожалуйста, отвечая на вопрос, постарайтесь не просто дать код, а попытаться что-то по этому поводу объяснить. - person David García Bodego; 18.10.2019
comment
Это тоже работает. По сути, тот же ответ, что и у Ежика ниже. Я тоже опубликую это. . - person MarlonC; 18.10.2019