components_extras_ExtrasItem.bs
import "pkg:/source/utils/misc.bs"
sub init()
initPosterImg()
initName()
initRole()
end sub
sub initPosterImg()
m.posterImg = m.top.findNode("posterImg")
end sub
sub initName()
m.name = m.top.findNode("pLabel")
end sub
sub initRole()
m.role = m.top.findNode("subTitle")
end sub
sub showContent()
' validate nodes to prevent crash
if not isValid(m.posterImg) then initPosterImg()
if not isValid(m.name) then initName()
if not isValid(m.role) then initRole()
if isValid(m.top.itemContent)
cont = m.top.itemContent
m.name.text = cont.labelText
m.name.maxWidth = cont.imageWidth
m.role.maxWidth = cont.imageWidth
m.posterImg.uri = cont.posterUrl
m.posterImg.width = cont.imageWidth
m.role.Text = cont.subTitle
else
m.role.text = tr("Unknown")
m.posterImg.uri = "pkg:/images/icons/baseline_person_white_48dp.png"
end if
end sub
sub focusChanged()
if m.top.itemHasFocus = true
m.name.repeatCount = -1
m.role.repeatCount = -1
else
m.name.repeatCount = 0
m.role.repeatCount = 0
end if
if m.global.device.isAudioGuideEnabled = true
txt2Speech = CreateObject("roTextToSpeech")
txt2Speech.Flush()
txt2Speech.Say(m.name.text)
txt2Speech.Say(m.role.text)
end if
end sub