Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update LiveTV to use ItemGrid2 #271

Merged
merged 4 commits into from
Oct 19, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions components/ItemGrid2/GridItem.brs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions components/ItemGrid2/ItemGrid2.brs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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

Expand Down
14 changes: 10 additions & 4 deletions components/ItemGrid2/LoadItemsTask2.brs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ sub loadItems()
results = []

sort_field = m.top.sortField

if m.top.sortAscending = true then
sort_order = "Ascending"
else
Expand All @@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions components/Pager.brs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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

Expand Down
3 changes: 2 additions & 1 deletion components/data/ChannelData.brs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ sub setFields()
json = m.top.json

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

sub setPoster()
Expand Down
12 changes: 6 additions & 6 deletions components/data/ChannelData.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="utf-8" ?>
<component name="ChannelData" extends="ContentNode">
<component name="ChannelData" extends="JFContentItem">
<interface>
<field id="id" 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" />
<field id="channelID" type="string" />
<field id="Title" type="string" />
</interface>
<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>
5 changes: 2 additions & 3 deletions components/data/CollectionData.brs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ sub setFields()
m.top.Description = json.overview
m.top.favorite = json.UserData.isFavorite
m.top.watched = json.UserData.played
m.top.Type = "Boxset"
m.top.Type = "Boxset"

setPoster()
end sub

Expand All @@ -18,7 +18,6 @@ sub setPoster()
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)
else if m.top.json.BackdropImageTags <> invalid then
Expand Down
22 changes: 19 additions & 3 deletions source/Main.brs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ sub Main()
group.visible = false

m.overhang.title = selectedItem.title
group = CreateChannelList(selectedItem.Id)
group = CreateChannelList(selectedItem)
group.overhangTitle = selectedItem.title
m.scene.appendChild(group)
else if selectedItem.type = "Boxset" then
Expand Down Expand Up @@ -180,6 +180,22 @@ sub Main()
ReportPlayback(group, "start")
m.overhang.visible = false
end if
else if selectedItem.type = "TvChannel" then
' play channel feed
print selectedItem
neilsb marked this conversation as resolved.
Show resolved Hide resolved
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
' TODO - switch on more node types
if selectedItem.type = "CollectionFolder" OR selectedItem.type = "UserView" then
Expand Down Expand Up @@ -253,7 +269,7 @@ sub Main()
' 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")
Expand All @@ -279,7 +295,7 @@ sub Main()
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
Expand Down
52 changes: 7 additions & 45 deletions source/ShowScenes.brs
Original file line number Diff line number Diff line change
Expand Up @@ -317,55 +317,17 @@ function CreateCollectionDetailList(collectionId)
return group
end function

function CreateChannelList(libraryItem)
group = CreateObject("roSGNode", "ItemGrid2")
print libraryItem
group.parentItem = libraryItem
' group = CreateObject("roSGNode", "Channels")
' group.id = libraryId



function CreateChannelList(libraryId)
group = CreateObject("roSGNode", "Channels")
group.id = libraryId

group.observeField("channelSelected", m.port)
group.observeField("selectedItem", m.port)


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
end function
Expand Down