Merge pull request #278 from neilsb/live-tv-tidyup

Minor changes for Live TV
This commit is contained in:
Anthony Lavado 2020-10-29 00:06:01 -04:00 committed by GitHub
commit 5b268cbe3d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 42 additions and 62 deletions

View File

@ -8,6 +8,14 @@ sub init()
m.itemPoster.observeField("loadStatus", "onPosterLoadStatusChanged")
m.itemText.translation = [0, m.itemPoster.height + 7]
'Parent is MarkupGrid and it's parent is the ItemGrid
topParent = m.top.GetParent().GetParent()
'Get the imageDisplayMode for these grid items
if topParent.imageDisplayMode <> invalid
m.itemPoster.loadDisplayMode = topParent.imageDisplayMode
end if
end sub
sub itemContentChanged()

View File

@ -56,6 +56,9 @@ sub loadInitialItems()
m.loadItemsTask.itemType = "Series"
else if m.top.parentItem.collectionType = "livetv" then
m.loadItemsTask.itemType = "LiveTV"
'For LiveTV, we want to "Fit" the item images, not zoom
m.top.imageDisplayMode = "scaleToFit"
else
print "Unknown Type: " m.top.parentItem
end if

View File

@ -33,6 +33,7 @@
<interface>
<field id="parentItem" type="node" onChange="loadInitialItems" />
<field id="selectedItem" type="node" alwaysNotify="true" />
<field id="imageDisplayMode" type="string" value="scaleToZoom" />
</interface>
<script type="text/brightscript" uri="ItemGrid2.brs" />
</component>

View File

@ -5,12 +5,14 @@ sub setFields()
m.top.Title = json.name
m.top.live = true
m.top.Type = "TvChannel"
setPoster()
end sub
sub setPoster()
if m.top.image <> invalid
m.top.posterURL = m.top.image.url
else
m.top.posterURL = ""
else if m.top.json.ImageTags.Primary <> invalid then
imgParams = { "maxHeight": 440, "maxWidth": 295, "Tag": m.top.json.ImageTags.Primary }
m.top.posterURL = ImageURL(m.top.json.id, "Primary", imgParams)
end if
end sub

View File

@ -20,6 +20,11 @@ sub setData()
m.top.thumbnailURL = ImageURL(datum.id, "Primary", params)
m.top.widePosterUrl = m.top.thumbnailURL
' Add Icon URLs for display if there is no Poster
if datum.CollectionType = "livetv" then
m.top.iconUrl = "pkg:/images/baseline_live_tv_white_48dp.png"
end if
else if datum.type = "Episode" then
imgParams = { "AddPlayedIndicator": datum.UserData.Played }

View File

@ -4,6 +4,7 @@
<field id="id" type="string" />
<field id="name" type="string" />
<field id="thumbnailURL" type="string" />
<field id="iconURL" type="string" />
<field id="posterURL" type="string" />
<field id="widePosterURL" type="string" />
<field id="type" type="string" />

View File

@ -5,6 +5,7 @@ sub itemContentChanged()
m.itemText = m.top.findNode("itemText")
itemPoster = m.top.findNode("itemPoster")
itemIcon = m.top.findNode("itemIcon")
itemTextExtra = m.top.findNode("itemTextExtra")
' Desired Image Width
@ -26,6 +27,9 @@ sub itemContentChanged()
' Whether to use WidePoster or Thumbnail in this row
usePoster = m.top.GetParent().content.usePoster
if itemData.iconUrl <> invalid
itemIcon.uri = itemData.iconUrl
end if
' Format the Data based on the type of Home Data

View File

@ -2,6 +2,7 @@
<component name="HomeItem" extends="Group">
<children>
<Rectangle id="backdrop" width="464" height="261" translation="[8,5]" />
<Poster id="itemIcon" width="100" height="100" translation="[190,85]" loadDisplayMode="scaleToFit" />
<Poster id="itemPoster" width="464" height="261" translation="[8,5]" loadDisplayMode="scaleToZoom" />
<ScrollingLabel id="itemText" horizAlign="center" vertAlign="center" font="font:SmallBoldSystemFont" height="64" maxWidth="456" translation="[8,267]" repeatCount="0" />
<Label id="itemTextExtra" horizAlign="left" vertAlign="center" font="font:SmallBoldSystemFont" height="32" width="456" translation="[8,300]" visible="false" color="#777777FF" />

View File

@ -1,14 +0,0 @@
sub init()
end sub
function onKeyEvent(key as string, press as boolean) as boolean
if not press then return false
if key = "down"
m.top.lastFocus = m.top.focusedChild
m.top.findNode("paginator").setFocus(true)
end if
return false
end function

View File

@ -1,14 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<component name="Channels" extends="JFGroup">
<children>
<ItemGrid id="picker" visible="true" itemsPerRow="6" />
<OptionsSlider id="options" />
<Rectangle translation="[0,981]" width="1920" height="100" color="#101010" />
</children>
<interface>
<field id="channelSelected" alias="picker.itemSelected" />
<field id="objects" alias="picker.objects" />
<field id="pageNumber" type="integer" />
</interface>
<script type="text/brightscript" uri="Channels.brs" />
</component>

View File

@ -183,7 +183,15 @@ sub Main()
else if selectedItem.type = "TvChannel" then
' play channel feed
video_id = selectedItem.id
' Show Channel Loading spinner
dialog = createObject("roSGNode", "ProgressDialog")
dialog.title = tr("Loading Channel Data")
m.scene.dialog = dialog
video = CreateVideoPlayerGroup(video_id)
dialog.close = true
if video <> invalid then
group.lastFocus = group.focusedChild
group.setFocus(false)
@ -194,6 +202,12 @@ sub Main()
group.control = "play"
ReportPlayback(group, "start")
m.overhang.visible = false
else
dialog = createObject("roSGNode", "Dialog")
dialog.title = tr("Error loading Channel Data")
dialog.message = tr("Unable to load Channel Data from the server")
dialog.buttons = [tr("OK")]
m.scene.dialog = dialog
end if
else
' TODO - switch on more node types
@ -264,37 +278,6 @@ sub Main()
ReportPlayback(group, "start")
m.overhang.visible = false
end if
else if isNodeEvent(msg, "channelSelected")
' If you select a Channel from ANYWHERE, follow this flow
node = getMsgPicker(msg, "picker")
video_id = node.id
' Show Channel Loading spinner
dialog = createObject("roSGNode", "ProgressDialog")
dialog.title = tr("Loading Channel Data")
m.scene.dialog = dialog
video = CreateVideoPlayerGroup(video_id)
dialog.close = true
if video <> invalid then
group.lastFocus = group.focusedChild
group.setFocus(false)
group.visible = false
group = video
m.scene.appendChild(group)
group.setFocus(true)
group.control = "play"
ReportPlayback(group, "start")
m.overhang.visible = false
else
dialog = createObject("roSGNode", "Dialog")
dialog.title = tr("Error loading Channel Data")
dialog.message = tr("Unable to load Channel Data from the server")
dialog.buttons = [tr("OK")]
m.scene.dialog = dialog
end if
else if isNodeEvent(msg, "search_value")
query = msg.getRoSGNode().search_value
group.findNode("SearchBox").visible = false

View File

@ -269,7 +269,7 @@ function getAudioFormat(meta as object) as string
if meta.json.mediaSources = invalid then return ""
audioInfo = getAudioInfo(meta)
if audioInfo.count() = 0 then return ""
if audioInfo.count() = 0 or audioInfo[0].codec = invalid then return ""
return audioInfo[0].codec
end function