Initial batch of livetv updates to itemgrid2

This commit is contained in:
Nick Bisby 2020-10-17 14:07:32 -05:00
parent 419c4a4829
commit dd391ff0ea
No known key found for this signature in database
GPG Key ID: F6E0C4E6D0B5EB36
10 changed files with 64 additions and 67 deletions

View File

@ -29,6 +29,9 @@ sub itemContentChanged()
else if itemData.type = "Boxset" then else if itemData.type = "Boxset" then
m.itemPoster.uri = itemData.PosterUrl m.itemPoster.uri = itemData.PosterUrl
m.itemText.text = itemData.Title m.itemText.text = itemData.Title
else if itemData.type = "TvChannel" then
m.itemPoster.uri = itemData.PosterUrl
m.itemText.text = itemData.Title
else else
print "Unhandled Item Type: " + itemData.type print "Unhandled Item Type: " + itemData.type
end if end if

View File

@ -51,6 +51,10 @@ sub loadInitialItems()
m.loadItemsTask.itemType = "Movie" m.loadItemsTask.itemType = "Movie"
else if m.top.parentItem.collectionType = "tvshows" then else if m.top.parentItem.collectionType = "tvshows" then
m.loadItemsTask.itemType = "Series" m.loadItemsTask.itemType = "Series"
else if m.top.parentItem.collectionType = "livetv" then
m.loadItemsTask.itemType = "LiveTV"
else
print "Unknown Type: " m.top.parentItem
end if end if
m.loadItemsTask.control = "RUN" m.loadItemsTask.control = "RUN"
@ -89,6 +93,12 @@ sub SetUpOptions()
{ "Title": tr("OFFICIAL_RATING"), "Name": "OfficialRating" }, { "Title": tr("OFFICIAL_RATING"), "Name": "OfficialRating" },
{ "Title": tr("RELEASE_DATE"), "Name": "PremiereDate" }, { "Title": tr("RELEASE_DATE"), "Name": "PremiereDate" },
] ]
'Live TV
else if m.top.parentItem.collectionType = "livetv" then
options.views = [{"Title": tr("Live TV"), "Name": "livetv" }]
options.sort = [
{ "Title": tr("TITLE"), "Name": "SortName" }
]
end if end if

View File

@ -7,7 +7,7 @@ sub loadItems()
results = [] results = []
sort_field = m.top.sortField sort_field = m.top.sortField
if m.top.sortAscending = true then if m.top.sortAscending = true then
sort_order = "Ascending" sort_order = "Ascending"
else else
@ -28,14 +28,18 @@ sub loadItems()
params.append({ IncludeItemTypes: m.top.ItemType}) params.append({ IncludeItemTypes: m.top.ItemType})
end if end if
url = Substitute("Users/{0}/Items/", get_setting("active_user")) if m.top.ItemType = "LiveTV" then
url = "LiveTv/Channels"
else
url = Substitute("Users/{0}/Items/", get_setting("active_user"))
end if
resp = APIRequest(url, params) resp = APIRequest(url, params)
data = getJson(resp) data = getJson(resp)
if data.TotalRecordCount <> invalid then if data.TotalRecordCount <> invalid then
m.top.totalRecordCount = data.TotalRecordCount m.top.totalRecordCount = data.TotalRecordCount
end if end if
for each item in data.Items for each item in data.Items
tmp = invalid tmp = invalid
@ -45,11 +49,13 @@ sub loadItems()
tmp = CreateObject("roSGNode", "SeriesData") tmp = CreateObject("roSGNode", "SeriesData")
else if item.Type = "BoxSet" then else if item.Type = "BoxSet" then
tmp = CreateObject("roSGNode", "CollectionData") tmp = CreateObject("roSGNode", "CollectionData")
else if item.Type = "TvChannel" then
tmp = CreateObject("roSGNode", "ChannelData")
else else
print "Unknown Type: " item.Type print "Unknown Type: " item.Type
end if end if
if tmp <> invalid then if tmp <> invalid then
tmp.json = item tmp.json = item

View File

@ -40,7 +40,7 @@ sub recountPages()
m.top.pageFocused = m.top.findNode(stri(currentPage).trim()) m.top.pageFocused = m.top.findNode(stri(currentPage).trim())
m.top.pageFocused.color = "#00ff00ff" m.top.pageFocused.color = "#00A4DCff"
updateLayout() updateLayout()
end sub end sub
@ -105,7 +105,7 @@ sub focusNext()
m.top.pageFocused.color = "#a1a1a1FF" m.top.pageFocused.color = "#a1a1a1FF"
m.top.pageFocused = m.top.getChild(i + 1) m.top.pageFocused = m.top.getChild(i + 1)
m.top.pageFocused.color = "#00ff00ff" m.top.pageFocused.color = "#00A4DCff"
m.top.pageFocused.setFocus(true) m.top.pageFocused.setFocus(true)
end sub end sub
@ -115,7 +115,7 @@ sub focusPrev()
m.top.pageFocused.color = "#a1a1a1FF" m.top.pageFocused.color = "#a1a1a1FF"
m.top.pageFocused = m.top.getChild(i - 1) m.top.pageFocused = m.top.getChild(i - 1)
m.top.pageFocused.color = "#00ff00ff" m.top.pageFocused.color = "#00A4DCff"
m.top.pageFocused.setFocus(true) m.top.pageFocused.setFocus(true)
end sub end sub

View File

@ -2,8 +2,8 @@ sub setFields()
json = m.top.json json = m.top.json
m.top.id = json.id m.top.id = json.id
m.top.title = json.name m.top.Title = json.name
m.top.live = true m.top.Type = "TvChannel"
end sub end sub
sub setPoster() sub setPoster()

View File

@ -1,11 +1,11 @@
<?xml version="1.0" encoding="utf-8" ?> <?xml version="1.0" encoding="utf-8" ?>
<component name="ChannelData" extends="ContentNode"> <component name="ChannelData" extends="JFContentItem">
<interface> <interface>
<field id="id" type="string" /> <field id="channelID" type="string" />
<field id="title" type="string" /> <field id="Title" type="string" />
<field id="image" type="node" onChange="setPoster" />
<field id="posterURL" type="string" />
<field id="json" type="associativearray" onChange="setFields" />
</interface> </interface>
<script type="text/brightscript" uri="ChannelData.brs" /> <script type="text/brightscript" uri="ChannelData.brs" />
<script type="text/brightscript" uri="pkg:/source/api/Image.brs" />
<script type="text/brightscript" uri="pkg:/source/api/baserequest.brs" />
<script type="text/brightscript" uri="pkg:/source/utils/config.brs" />
</component> </component>

View File

@ -7,8 +7,8 @@ sub setFields()
m.top.Description = json.overview m.top.Description = json.overview
m.top.favorite = json.UserData.isFavorite m.top.favorite = json.UserData.isFavorite
m.top.watched = json.UserData.played m.top.watched = json.UserData.played
m.top.Type = "Boxset" m.top.Type = "Boxset"
setPoster() setPoster()
end sub end sub
@ -18,7 +18,6 @@ sub setPoster()
else else
if m.top.json.ImageTags.Primary <> invalid then if m.top.json.ImageTags.Primary <> invalid then
imgParams = { "maxHeight": 440, "maxWidth": 295, "Tag" : m.top.json.ImageTags.Primary } imgParams = { "maxHeight": 440, "maxWidth": 295, "Tag" : m.top.json.ImageTags.Primary }
m.top.posterURL = ImageURL(m.top.json.id, "Primary", imgParams) m.top.posterURL = ImageURL(m.top.json.id, "Primary", imgParams)
else if m.top.json.BackdropImageTags <> invalid then else if m.top.json.BackdropImageTags <> invalid then

View File

@ -113,7 +113,7 @@ sub Main()
group.visible = false group.visible = false
m.overhang.title = selectedItem.title m.overhang.title = selectedItem.title
group = CreateChannelList(selectedItem.Id) group = CreateChannelList(selectedItem)
group.overhangTitle = selectedItem.title group.overhangTitle = selectedItem.title
m.scene.appendChild(group) m.scene.appendChild(group)
else if selectedItem.type = "Boxset" then else if selectedItem.type = "Boxset" then
@ -180,6 +180,22 @@ sub Main()
ReportPlayback(group, "start") ReportPlayback(group, "start")
m.overhang.visible = false m.overhang.visible = false
end if end if
else if selectedItem.type = "TvChannel" then
' play channel feed
print selectedItem
video_id = selectedItem.id
video = CreateVideoPlayerGroup(video_id)
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
end if
else else
' TODO - switch on more node types ' TODO - switch on more node types
if selectedItem.type = "CollectionFolder" OR selectedItem.type = "UserView" then if selectedItem.type = "CollectionFolder" OR selectedItem.type = "UserView" then
@ -253,7 +269,7 @@ sub Main()
' If you select a Channel from ANYWHERE, follow this flow ' If you select a Channel from ANYWHERE, follow this flow
node = getMsgPicker(msg, "picker") node = getMsgPicker(msg, "picker")
video_id = node.id video_id = node.id
' Show Channel Loading spinner ' Show Channel Loading spinner
dialog = createObject("roSGNode", "ProgressDialog") dialog = createObject("roSGNode", "ProgressDialog")
dialog.title = tr("Loading Channel Data") dialog.title = tr("Loading Channel Data")
@ -279,7 +295,7 @@ sub Main()
dialog.buttons = [tr("OK")] dialog.buttons = [tr("OK")]
m.scene.dialog = dialog m.scene.dialog = dialog
end if end if
else if isNodeEvent(msg, "search_value") else if isNodeEvent(msg, "search_value")
query = msg.getRoSGNode().search_value query = msg.getRoSGNode().search_value
group.findNode("SearchBox").visible = false group.findNode("SearchBox").visible = false

View File

@ -317,55 +317,17 @@ function CreateCollectionDetailList(collectionId)
return group return group
end function end function
function CreateChannelList(libraryItem)
group = CreateObject("roSGNode", "ItemGrid2")
print libraryItem
group.parentItem = libraryItem
' group = CreateObject("roSGNode", "Channels")
' group.id = libraryId
group.observeField("selectedItem", m.port)
function CreateChannelList(libraryId)
group = CreateObject("roSGNode", "Channels")
group.id = libraryId
group.observeField("channelSelected", m.port)
sidepanel = group.findNode("options") sidepanel = group.findNode("options")
channel_options = [
{"title": "Sort Field",
"base_title": "Sort Field",
"key": "channel_sort_field",
"default": "Name",
"values": [
{display: tr("Name"), value: "SortName"}
]},
{"title": "Sort Order",
"base_title": "Sort Order",
"key": "channel_sort_order",
"default": "Ascending",
"values": [
{display: tr("Descending"), value: "Descending"},
{display: tr("Ascending"), value: "Ascending"}
]}
]
new_options = []
for each opt in channel_options
o = CreateObject("roSGNode", "OptionsData")
o.title = tr(opt.title)
o.choices = opt.values
o.base_title = tr(opt.base_title)
o.config_key = opt.key
o.value = get_user_setting(opt.key, opt.default)
new_options.append([o])
end for
sidepanel.options = new_options
sidepanel.observeField("closeSidePanel", m.port)
p = CreatePaginator()
group.appendChild(p)
group.pageNumber = 1
p.currentPage = group.pageNumber
ChannelLister(group, m.page_size)
return group return group
end function end function

View File

@ -21,7 +21,7 @@ function VideoContent(video) as object
meta = ItemMetaData(video.id) meta = ItemMetaData(video.id)
video.content.title = meta.Name video.content.title = meta.Name
' If there is a last playback positon, ask user if they want to resume ' If there is a last playback positon, ask user if they want to resume
position = meta.json.UserData.PlaybackPositionTicks position = meta.json.UserData.PlaybackPositionTicks
if position > 0 then if position > 0 then
@ -149,6 +149,7 @@ function getTranscodeParameters(meta as object)
end if end if
end if end if
print meta.json.MediaStreams
streamInfo = { Codec: meta.json.MediaStreams[0].codec } streamInfo = { Codec: meta.json.MediaStreams[0].codec }
if meta.json.MediaStreams[0].Profile <> invalid and meta.json.MediaStreams[0].Profile.len() > 0 then if meta.json.MediaStreams[0].Profile <> invalid and meta.json.MediaStreams[0].Profile.len() > 0 then
streamInfo.Profile = LCase(meta.json.MediaStreams[0].Profile) streamInfo.Profile = LCase(meta.json.MediaStreams[0].Profile)