Skip to content

Commit dd24427

Browse files
committed
Update code docs
1 parent 47e11b5 commit dd24427

2 files changed

Lines changed: 120 additions & 50 deletions

File tree

docs/components_video_OSD.bs.html

Lines changed: 115 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,13 @@
109109
m.top.productionYear = videoData.ProductionYear
110110
end if
111111

112+
if isValid(videoData.CurrentProgram)
113+
m.top.runTimeTicks = videoData.CurrentProgram.RunTimeTicks
114+
m.top.runTimeMinutes = ticksToMinutes(m.top.runTimeTicks)
115+
116+
m.top.currentProgram = FormatJson(videoData.CurrentProgram)
117+
end if
118+
112119
numVideoStreams = 0
113120
numAudioStreams = 0
114121

@@ -175,6 +182,20 @@
175182
return
176183
end if
177184

185+
' if type is tvchannel, set endsAtTime to current program enddate
186+
if m.top.type = "TvChannel" and m.top.currentProgram <> ""
187+
currentProgram = ParseJson(m.top.currentProgram)
188+
if isValid(currentProgram.EndDate) and currentProgram.EndDate <> ""
189+
' Parse the EndDate and format as time only
190+
endDateTime = CreateObject("roDateTime")
191+
endDateTime.fromISO8601String(currentProgram.EndDate)
192+
endDateTime.toLocalTime()
193+
m.endsAtTime.text = formatTime(endDateTime)
194+
return
195+
end if
196+
end if
197+
198+
' for all other types, calculate endsAtTime based on remainingPositionTime
178199
date = CreateObject("roDateTime")
179200
endTime = int(m.top.remainingPositionTime)
180201
date.fromSeconds(date.asSeconds() + endTime)
@@ -185,6 +206,21 @@
185206

186207
sub setVideoLogoGroup()
187208
m.videoLogo.uri = m.top.videoLogo
209+
currentProgram = ParseJson(m.top.currentProgram)
210+
211+
if isValidAndNotEmpty(currentProgram) and m.top.type = "TvChannel"
212+
' set video title to current program name
213+
if isValid(currentProgram.ImageTags) and isValid(currentProgram.ImageTags.Primary)
214+
imgParams = {
215+
maxHeight: 300,
216+
maxWidth: 500,
217+
quality: 90,
218+
tag: currentProgram.ImageTags.Primary
219+
}
220+
221+
m.videoLogo.uri = buildURL(Substitute("/items/{0}/images/Primary/0", currentProgram.id), imgParams)
222+
end if
223+
end if
188224

189225
' if isValid(m.top.officialRating) and m.top.officialRating <> ""
190226
' m.videoOfficialRating.text = m.top.officialRating
@@ -193,6 +229,13 @@
193229

194230
sub setVideoTitle()
195231
m.videoTitle.text = m.top.videoTitle
232+
currentProgram = ParseJson(m.top.currentProgram)
233+
234+
if isValidAndNotEmpty(currentProgram) and m.top.type = "TvChannel"
235+
if isValid(currentProgram.Name)
236+
m.videoTitle.text = currentProgram.Name
237+
end if
238+
end if
196239
end sub
197240

198241
sub setVideoSubTitle()
@@ -202,54 +245,71 @@
202245
airDateNodeCreated = false
203246

204247
' EPISODE
205-
if isValid(m.top.type)
206-
if m.top.Type = "Episode" or m.top.Type = "Recording"
207-
' Title
208-
if m.top.seriesName <> ""
209-
m.videoTitle.text = m.top.seriesName
210-
end if
248+
if m.top.type = "Episode" or m.top.type = "Recording"
249+
' Title
250+
if m.top.seriesName <> ""
251+
m.videoTitle.text = m.top.seriesName
252+
end if
211253

212-
' episodeInfo
213-
episodeInfoText = ""
214-
'
215-
' Season number
216-
if isValid(m.top.seasonNumber)
217-
episodeInfoText = episodeInfoText + `${tr("S")}${m.top.seasonNumber}`
218-
else
219-
episodeInfoText = episodeInfoText + `${tr("S")}?`
220-
end if
221-
' Episode number
222-
if isValid(m.top.episodeNumber)
223-
episodeInfoText = episodeInfoText + `:${tr("E")}${m.top.episodeNumber}`
224-
else
225-
episodeInfoText = episodeInfoText + `:${tr("E")}??`
226-
end if
227-
' Episode number end
228-
if isValid(m.top.episodeNumberEnd) and m.top.episodeNumberEnd <> 0 and m.top.episodeNumberEnd > m.top.episodeNumber
229-
' add entry for every episode eg. S6:E1E2
230-
for i = m.top.episodeNumber + 1 to m.top.episodeNumberEnd
231-
episodeInfoText = episodeInfoText + `${tr("E")}${m.top.episodeNumberEnd}`
232-
end for
233-
end if
234-
' Episode name
235-
if isValid(m.top.videoTitle) and m.top.videoTitle <> ""
236-
episodeInfoText = episodeInfoText + ` - ${m.top.videoTitle}`
237-
end if
254+
' episodeInfo
255+
episodeInfoText = ""
256+
'
257+
' Season number
258+
if isValid(m.top.seasonNumber)
259+
episodeInfoText = episodeInfoText + `${tr("S")}${m.top.seasonNumber}`
260+
else
261+
episodeInfoText = episodeInfoText + `${tr("S")}?`
262+
end if
263+
' Episode number
264+
if isValid(m.top.episodeNumber)
265+
episodeInfoText = episodeInfoText + `:${tr("E")}${m.top.episodeNumber}`
266+
else
267+
episodeInfoText = episodeInfoText + `:${tr("E")}??`
268+
end if
269+
' Episode number end
270+
if isValid(m.top.episodeNumberEnd) and m.top.episodeNumberEnd <> 0 and m.top.episodeNumberEnd > m.top.episodeNumber
271+
' add entry for every episode eg. S6:E1E2
272+
for i = m.top.episodeNumber + 1 to m.top.episodeNumberEnd
273+
episodeInfoText = episodeInfoText + `${tr("E")}${m.top.episodeNumberEnd}`
274+
end for
275+
end if
276+
' Episode name
277+
if isValid(m.top.videoTitle) and m.top.videoTitle <> ""
278+
episodeInfoText = episodeInfoText + ` - ${m.top.videoTitle}`
279+
end if
238280

239-
if episodeInfoText <> ""
240-
episodeInfoNode = createSubtitleLabelNode("episodeInfo")
241-
episodeInfoNode.text = episodeInfoText
242-
displaySubtitleNode(episodeInfoNode)
243-
end if
244-
else if m.top.type = "Movie"
245-
' videoAirDate
246-
if isValid(m.top.premiereDate) and m.top.premiereDate <> ""
247-
airDateNodeCreated = true
281+
if episodeInfoText <> ""
282+
episodeInfoNode = createSubtitleLabelNode("episodeInfo")
283+
episodeInfoNode.text = episodeInfoText
284+
displaySubtitleNode(episodeInfoNode)
285+
end if
286+
else if m.top.type = "Movie"
287+
' videoAirDate
288+
if isValid(m.top.premiereDate) and m.top.premiereDate <> ""
289+
airDateNodeCreated = true
248290

249-
premiereDateNode = createSubtitleLabelNode("videoAirDate")
250-
premiereDateNode.text = formatIsoDateVideo(m.top.premiereDate)
291+
premiereDateNode = createSubtitleLabelNode("videoAirDate")
292+
premiereDateNode.text = formatIsoDateVideo(m.top.premiereDate)
251293

252-
displaySubtitleNode(premiereDateNode)
294+
displaySubtitleNode(premiereDateNode)
295+
end if
296+
else if m.top.type = "TvChannel"
297+
' TvChannel
298+
if isValid(m.top.currentProgram) and m.top.currentProgram <> ""
299+
currentProgram = ParseJson(m.top.currentProgram)
300+
301+
if isValidAndNotEmpty(currentProgram)
302+
' set video title to current program name
303+
if isValid(currentProgram.Name)
304+
currentChannel = createSubtitleLabelNode("currentChannel")
305+
currentChannel.text = currentProgram.ChannelName
306+
307+
if isValid(currentProgram.ChannelNumber) and currentProgram.ChannelNumber <> ""
308+
currentChannel.text = `${currentChannel.text} (${currentProgram.ChannelNumber})`
309+
end if
310+
311+
displaySubtitleNode(currentChannel)
312+
end if
253313
end if
254314
end if
255315
end if
@@ -280,9 +340,17 @@
280340
end sub
281341

282342
sub onProgressPercentageChanged()
283-
m.videoPositionTime.text = secondsToTimestamp(m.top.positionTime, true)
284-
m.videoRemainingTime.text = "-" + secondsToTimestamp(m.top.remainingPositionTime, true)
285-
m.progressBar.width = m.progressBarBackground.width * m.top.progressPercentage
343+
' change progress bar for live tv
344+
if m.top.type = "TvChannel"
345+
m.videoPositionTime.text = secondsToTimestamp(m.top.positionTime, true)
346+
m.videoRemainingTime.text = tr("LIVE")
347+
m.progressBar.width = m.progressBarBackground.width ' set to full width
348+
else
349+
m.videoPositionTime.text = secondsToTimestamp(m.top.positionTime, true)
350+
m.videoRemainingTime.text = "-" + secondsToTimestamp(m.top.remainingPositionTime, true)
351+
m.progressBar.width = m.progressBarBackground.width * m.top.progressPercentage
352+
end if
353+
286354
setEndsAtText()
287355
end sub
288356

docs/source_Main.bs.html

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,11 @@
6565

6666
' Verify the file was written successfully
6767
fs = CreateObject("roFileSystem")
68-
if fs.Exists("tmp:/font") and m.global.session.user.settings["ui.font.fallback"] = true
69-
' Calculate font scale factor once for all UI components
70-
calculateFontScaleFactor()
68+
if fs.Exists("tmp:/font")
69+
if m.global.session.user.settings["ui.font.fallback"] = true
70+
' Calculate font scale factor once for all UI components
71+
calculateFontScaleFactor()
72+
end if
7173
else
7274
print "WARNING - Main: Fallback font file was not created successfully"
7375
end if

0 commit comments

Comments
 (0)