From dd391ff0ea2f8c507bff394b41b0bb22945ea2c9 Mon Sep 17 00:00:00 2001 From: Nick Bisby Date: Sat, 17 Oct 2020 14:07:32 -0500 Subject: [PATCH] Initial batch of livetv updates to itemgrid2 --- components/ItemGrid2/GridItem.brs | 3 ++ components/ItemGrid2/ItemGrid2.brs | 10 +++++ components/ItemGrid2/LoadItemsTask2.brs | 14 +++++-- components/Pager.brs | 6 +-- components/data/ChannelData.brs | 4 +- components/data/ChannelData.xml | 12 +++--- components/data/CollectionData.brs | 5 +-- source/Main.brs | 22 +++++++++-- source/ShowScenes.brs | 52 ++++--------------------- source/VideoPlayer.brs | 3 +- 10 files changed, 64 insertions(+), 67 deletions(-) diff --git a/components/ItemGrid2/GridItem.brs b/components/ItemGrid2/GridItem.brs index e04eb9e5..09621438 100644 --- a/components/ItemGrid2/GridItem.brs +++ b/components/ItemGrid2/GridItem.brs @@ -29,6 +29,9 @@ sub itemContentChanged() else if itemData.type = "Boxset" then m.itemPoster.uri = itemData.PosterUrl m.itemText.text = itemData.Title + else if itemData.type = "TvChannel" then + m.itemPoster.uri = itemData.PosterUrl + m.itemText.text = itemData.Title else print "Unhandled Item Type: " + itemData.type end if diff --git a/components/ItemGrid2/ItemGrid2.brs b/components/ItemGrid2/ItemGrid2.brs index b20aa2aa..0a8a3f9c 100644 --- a/components/ItemGrid2/ItemGrid2.brs +++ b/components/ItemGrid2/ItemGrid2.brs @@ -51,6 +51,10 @@ sub loadInitialItems() m.loadItemsTask.itemType = "Movie" else if m.top.parentItem.collectionType = "tvshows" then 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 m.loadItemsTask.control = "RUN" @@ -89,6 +93,12 @@ sub SetUpOptions() { "Title": tr("OFFICIAL_RATING"), "Name": "OfficialRating" }, { "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 diff --git a/components/ItemGrid2/LoadItemsTask2.brs b/components/ItemGrid2/LoadItemsTask2.brs index b0c774f8..743f1444 100644 --- a/components/ItemGrid2/LoadItemsTask2.brs +++ b/components/ItemGrid2/LoadItemsTask2.brs @@ -7,7 +7,7 @@ sub loadItems() results = [] sort_field = m.top.sortField - + if m.top.sortAscending = true then sort_order = "Ascending" else @@ -28,14 +28,18 @@ sub loadItems() params.append({ IncludeItemTypes: m.top.ItemType}) 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) data = getJson(resp) if data.TotalRecordCount <> invalid then m.top.totalRecordCount = data.TotalRecordCount end if - + for each item in data.Items tmp = invalid @@ -45,11 +49,13 @@ sub loadItems() tmp = CreateObject("roSGNode", "SeriesData") else if item.Type = "BoxSet" then tmp = CreateObject("roSGNode", "CollectionData") + else if item.Type = "TvChannel" then + tmp = CreateObject("roSGNode", "ChannelData") else print "Unknown Type: " item.Type end if - + if tmp <> invalid then tmp.json = item diff --git a/components/Pager.brs b/components/Pager.brs index fc18d74c..40611e67 100644 --- a/components/Pager.brs +++ b/components/Pager.brs @@ -40,7 +40,7 @@ sub recountPages() m.top.pageFocused = m.top.findNode(stri(currentPage).trim()) - m.top.pageFocused.color = "#00ff00ff" + m.top.pageFocused.color = "#00A4DCff" updateLayout() end sub @@ -105,7 +105,7 @@ sub focusNext() m.top.pageFocused.color = "#a1a1a1FF" m.top.pageFocused = m.top.getChild(i + 1) - m.top.pageFocused.color = "#00ff00ff" + m.top.pageFocused.color = "#00A4DCff" m.top.pageFocused.setFocus(true) end sub @@ -115,7 +115,7 @@ sub focusPrev() m.top.pageFocused.color = "#a1a1a1FF" m.top.pageFocused = m.top.getChild(i - 1) - m.top.pageFocused.color = "#00ff00ff" + m.top.pageFocused.color = "#00A4DCff" m.top.pageFocused.setFocus(true) end sub diff --git a/components/data/ChannelData.brs b/components/data/ChannelData.brs index c8690780..2992f030 100644 --- a/components/data/ChannelData.brs +++ b/components/data/ChannelData.brs @@ -2,8 +2,8 @@ sub setFields() json = m.top.json m.top.id = json.id - m.top.title = json.name - m.top.live = true + m.top.Title = json.name + m.top.Type = "TvChannel" end sub sub setPoster() diff --git a/components/data/ChannelData.xml b/components/data/ChannelData.xml index 4f291be3..0fdab666 100644 --- a/components/data/ChannelData.xml +++ b/components/data/ChannelData.xml @@ -1,11 +1,11 @@ - + - - - - - + +