2020-02-23 04:47:00 +00:00
|
|
|
sub init()
|
|
|
|
m.title = m.top.findNode("title")
|
2020-05-05 21:09:18 +00:00
|
|
|
m.title.text = tr("Loading...")
|
2022-04-24 03:49:42 +00:00
|
|
|
m.options = m.top.findNode("tvListOptions")
|
2022-04-26 01:02:50 +00:00
|
|
|
m.overview = m.top.findNode("overview")
|
|
|
|
m.deviceInfo = CreateObject("roDeviceInfo")
|
2020-02-23 04:47:00 +00:00
|
|
|
end sub
|
|
|
|
|
2021-06-26 10:18:09 +00:00
|
|
|
sub itemContentChanged()
|
2021-07-09 20:08:32 +00:00
|
|
|
item = m.top.itemContent
|
|
|
|
itemData = item.json
|
|
|
|
if itemData.indexNumber <> invalid
|
|
|
|
indexNumber = itemData.indexNumber.toStr() + ". "
|
|
|
|
else
|
|
|
|
indexNumber = ""
|
|
|
|
end if
|
2022-04-26 01:02:50 +00:00
|
|
|
m.title.text = indexNumber + item.title
|
2021-07-09 20:08:32 +00:00
|
|
|
m.top.findNode("poster").uri = item.posterURL
|
2022-04-26 01:02:50 +00:00
|
|
|
m.overview.text = item.overview
|
2020-02-23 04:47:00 +00:00
|
|
|
|
2021-07-09 20:08:32 +00:00
|
|
|
if type(itemData.RunTimeTicks) = "LongInteger"
|
|
|
|
m.top.findNode("runtime").text = stri(getRuntime()).trim() + " mins"
|
|
|
|
m.top.findNode("endtime").text = tr("Ends at %1").Replace("%1", getEndTime())
|
|
|
|
end if
|
2022-02-05 01:53:54 +00:00
|
|
|
|
2021-07-09 20:08:32 +00:00
|
|
|
if itemData.communityRating <> invalid
|
|
|
|
m.top.findNode("star").visible = true
|
|
|
|
m.top.findNode("communityRating").text = str(int(itemData.communityRating * 10) / 10)
|
|
|
|
else
|
|
|
|
m.top.findNode("star").visible = false
|
|
|
|
end if
|
2022-02-05 01:53:54 +00:00
|
|
|
|
2022-04-26 16:35:40 +00:00
|
|
|
videoIdx = invalid
|
|
|
|
audioIdx = invalid
|
2022-04-29 13:15:40 +00:00
|
|
|
|
2022-02-05 01:53:54 +00:00
|
|
|
if itemData.MediaStreams <> invalid
|
|
|
|
for i = 0 to itemData.MediaStreams.Count() - 1
|
2022-02-05 02:00:15 +00:00
|
|
|
if itemData.MediaStreams[i].Type = "Video" and videoIdx = invalid
|
2022-02-05 01:53:54 +00:00
|
|
|
videoIdx = i
|
2022-04-29 13:15:40 +00:00
|
|
|
m.top.findNode("video_codec").text = tr("Video") + ": " + itemData.mediaStreams[videoIdx].DisplayTitle
|
2022-02-05 02:00:15 +00:00
|
|
|
else if itemData.MediaStreams[i].Type = "Audio" and audioIdx = invalid
|
2022-04-24 03:49:42 +00:00
|
|
|
if item.selectedAudioStreamIndex > 1
|
|
|
|
audioIdx = item.selectedAudioStreamIndex
|
|
|
|
else
|
|
|
|
audioIdx = i
|
|
|
|
end if
|
2022-04-29 13:15:40 +00:00
|
|
|
m.top.findNode("audio_codec").text = tr("Audio") + ": " + itemData.mediaStreams[audioIdx].DisplayTitle
|
2022-02-05 01:53:54 +00:00
|
|
|
end if
|
|
|
|
if videoIdx <> invalid and audioIdx <> invalid then exit for
|
|
|
|
end for
|
|
|
|
end if
|
2022-04-24 03:49:42 +00:00
|
|
|
|
2022-04-26 16:35:40 +00:00
|
|
|
m.top.findNode("video_codec").visible = videoIdx <> invalid
|
2022-04-29 13:15:40 +00:00
|
|
|
if audioIdx <> invalid
|
2022-04-29 13:20:34 +00:00
|
|
|
m.top.findNode("audio_codec").visible = true
|
2022-04-29 13:15:40 +00:00
|
|
|
DisplayAudioAvailable(itemData.mediaStreams)
|
|
|
|
else
|
2022-04-29 13:20:34 +00:00
|
|
|
m.top.findNode("audio_codec").visible = false
|
2022-04-29 13:15:40 +00:00
|
|
|
end if
|
2022-04-24 03:49:42 +00:00
|
|
|
end sub
|
|
|
|
|
|
|
|
sub DisplayAudioAvailable(streams)
|
|
|
|
|
|
|
|
count = 0
|
|
|
|
for i = 0 to streams.Count() - 1
|
|
|
|
if streams[i].Type = "Audio"
|
|
|
|
count++
|
|
|
|
end if
|
|
|
|
end for
|
|
|
|
|
|
|
|
if count > 1
|
|
|
|
m.top.findnode("audio_codec_count").text = "+" + stri(count - 1).trim()
|
|
|
|
end if
|
|
|
|
|
2021-06-26 10:18:09 +00:00
|
|
|
end sub
|
2020-02-23 04:47:00 +00:00
|
|
|
|
|
|
|
function getRuntime() as integer
|
2021-07-09 20:08:32 +00:00
|
|
|
itemData = m.top.itemContent.json
|
2020-02-23 04:47:00 +00:00
|
|
|
|
2021-07-09 20:08:32 +00:00
|
|
|
' A tick is .1ms, so 1/10,000,000 for ticks to seconds,
|
|
|
|
' then 1/60 for seconds to minutess... 1/600,000,000
|
|
|
|
return int(itemData.RunTimeTicks / 600000000.0)
|
2020-02-23 04:47:00 +00:00
|
|
|
end function
|
|
|
|
|
|
|
|
function getEndTime() as string
|
2021-07-09 20:08:32 +00:00
|
|
|
itemData = m.top.itemContent.json
|
|
|
|
date = CreateObject("roDateTime")
|
|
|
|
duration_s = int(itemData.RunTimeTicks / 10000000.0)
|
|
|
|
date.fromSeconds(date.asSeconds() + duration_s)
|
|
|
|
date.toLocalTime()
|
2020-02-23 04:47:00 +00:00
|
|
|
|
2021-07-09 20:08:32 +00:00
|
|
|
return formatTime(date)
|
2020-02-23 04:47:00 +00:00
|
|
|
end function
|
2022-04-26 01:02:50 +00:00
|
|
|
|
|
|
|
sub focusChanged()
|
|
|
|
if m.top.itemHasFocus = true
|
|
|
|
' text to speech for accessibility
|
|
|
|
if m.deviceInfo.IsAudioGuideEnabled() = true
|
|
|
|
txt2Speech = CreateObject("roTextToSpeech")
|
|
|
|
txt2Speech.Flush()
|
|
|
|
txt2Speech.Say(m.title.text)
|
|
|
|
txt2Speech.Say(m.overview.text)
|
|
|
|
end if
|
|
|
|
end if
|
|
|
|
end sub
|