|
109 | 109 | m.top.productionYear = videoData.ProductionYear |
110 | 110 | end if |
111 | 111 |
|
| 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 | + |
112 | 119 | numVideoStreams = 0 |
113 | 120 | numAudioStreams = 0 |
114 | 121 |
|
|
175 | 182 | return |
176 | 183 | end if |
177 | 184 |
|
| 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 |
178 | 199 | date = CreateObject("roDateTime") |
179 | 200 | endTime = int(m.top.remainingPositionTime) |
180 | 201 | date.fromSeconds(date.asSeconds() + endTime) |
|
185 | 206 |
|
186 | 207 | sub setVideoLogoGroup() |
187 | 208 | 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 |
188 | 224 |
|
189 | 225 | ' if isValid(m.top.officialRating) and m.top.officialRating <> "" |
190 | 226 | ' m.videoOfficialRating.text = m.top.officialRating |
|
193 | 229 |
|
194 | 230 | sub setVideoTitle() |
195 | 231 | 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 |
196 | 239 | end sub |
197 | 240 |
|
198 | 241 | sub setVideoSubTitle() |
|
202 | 245 | airDateNodeCreated = false |
203 | 246 |
|
204 | 247 | ' 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 |
211 | 253 |
|
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 |
238 | 280 |
|
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 |
248 | 290 |
|
249 | | - premiereDateNode = createSubtitleLabelNode("videoAirDate") |
250 | | - premiereDateNode.text = formatIsoDateVideo(m.top.premiereDate) |
| 291 | + premiereDateNode = createSubtitleLabelNode("videoAirDate") |
| 292 | + premiereDateNode.text = formatIsoDateVideo(m.top.premiereDate) |
251 | 293 |
|
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 |
253 | 313 | end if |
254 | 314 | end if |
255 | 315 | end if |
|
280 | 340 | end sub |
281 | 341 |
|
282 | 342 | 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 | + |
286 | 354 | setEndsAtText() |
287 | 355 | end sub |
288 | 356 |
|
|
0 commit comments