diff --git a/components/ItemGrid/GridItem.brs b/components/ItemGrid/GridItem.brs
index 2438ce59..3f40cc6d 100644
--- a/components/ItemGrid/GridItem.brs
+++ b/components/ItemGrid/GridItem.brs
@@ -49,7 +49,7 @@ sub itemContentChanged()
m.itemPoster.uri = itemData.PosterUrl
m.itemText.text = itemData.Title
else
- print "Unhandled Item Type: " + itemData.type
+ print "Unhandled Grid Item Type: " + itemData.type
end if
'If Poster not loaded, ensure "blue box" is shown until loaded
diff --git a/components/home/HomeItem.brs b/components/home/HomeItem.brs
index 0f682374..06391013 100644
--- a/components/home/HomeItem.brs
+++ b/components/home/HomeItem.brs
@@ -56,6 +56,20 @@ sub itemContentChanged()
m.itemTextExtra.visible = true
m.itemTextExtra.font.size = 22
+ ' "Program" is from clicking on an "On Now" item on the Home Screen
+ if itemData.type = "Program"
+ m.itemText.Text = itemData.json.name
+ if itemData.json.ImageURL <> invalid
+ m.itemPoster.uri = itemData.json.ImageURL
+ end if
+
+ ' Set Episode title if available
+ if itemData.json.EpisodeTitle <> invalid
+ m.itemTextExtra.text = itemData.json.EpisodeTitle
+ end if
+
+ return
+ end if
if itemData.type = "Episode"
m.itemText.text = itemData.json.SeriesName
@@ -156,7 +170,7 @@ sub itemContentChanged()
return
end if
- print "Unhandled Item Type: " + itemData.type
+ print "Unhandled Home Item Type: " + itemData.type
end sub
diff --git a/components/home/HomeItem.xml b/components/home/HomeItem.xml
index 71d723e9..4fce477a 100644
--- a/components/home/HomeItem.xml
+++ b/components/home/HomeItem.xml
@@ -12,4 +12,7 @@
+
+
+
\ No newline at end of file
diff --git a/components/home/HomeRows.brs b/components/home/HomeRows.brs
index 54092e58..7f9e93a1 100644
--- a/components/home/HomeRows.brs
+++ b/components/home/HomeRows.brs
@@ -24,6 +24,8 @@ sub init()
m.LoadContinueTask.itemsToLoad = "continue"
m.LoadNextUpTask = createObject("roSGNode", "LoadItemsTask")
m.LoadNextUpTask.itemsToLoad = "nextUp"
+ m.LoadOnNowTask = createObject("roSGNode", "LoadItemsTask")
+ m.LoadOnNowTask.itemsToLoad = "onNow"
end sub
sub loadLibraries()
@@ -64,6 +66,7 @@ sub onLibrariesLoaded()
[464, 331], ' Continue Watching
[464, 331] ' Next Up
]
+ haveLiveTV = false
' validate library data
if m.libraryData <> invalid and m.libraryData.count() > 0
userConfig = m.top.userConfig
@@ -79,6 +82,12 @@ sub onLibrariesLoaded()
latestInRow = content.CreateChild("HomeRow")
latestInRow.title = tr("Latest in") + " " + lib.name + " >"
sizeArray.Push([464, 331])
+ else if lib.collectionType = "livetv"
+ ' If we have Live TV, add "On Now"
+ onNowRow = content.CreateChild("HomeRow")
+ onNowRow.title = tr("On Now")
+ sizeArray.Push([464, 331])
+ haveLiveTV = true
end if
end for
end if
@@ -89,6 +98,12 @@ sub onLibrariesLoaded()
' Load the Continue Watching Data
m.LoadContinueTask.observeField("content", "updateContinueItems")
m.LoadContinueTask.control = "RUN"
+
+ ' If we have Live TV access, load "On Now" data
+ if haveLiveTV
+ m.LoadOnNowTask.observeField("content", "updateOnNowItems")
+ m.LoadOnNowTask.control = "RUN"
+ end if
end sub
sub updateHomeRows()
@@ -192,7 +207,7 @@ sub updateNextUpItems()
userConfig = m.top.userConfig
filteredLatest = filterNodeArray(m.libraryData, "id", userConfig.LatestItemsExcludes)
for each lib in filteredLatest
- if lib.collectionType <> "livetv" and lib.collectionType <> "boxsets"
+ if lib.collectionType <> "livetv" and lib.collectionType <> "boxsets" and lib.json.CollectionType <> "Program"
loadLatest = createObject("roSGNode", "LoadItemsTask")
loadLatest.itemsToLoad = "latest"
loadLatest.itemId = lib.id
@@ -260,6 +275,44 @@ sub updateLatestItems(msg)
end if
end sub
+sub updateOnNowItems()
+ itemData = m.LoadOnNowTask.content
+ m.LoadOnNowTask.unobserveField("content")
+ m.LoadOnNowTask.content = []
+
+ if itemData = invalid then return
+
+ homeRows = m.top.content
+ onNowRowIndex = getRowIndex("On Now")
+
+ if itemData.count() < 1
+ if onNowRowIndex <> invalid
+ ' remove the row
+ deleteFromSizeArray(onNowRowIndex)
+ homeRows.removeChildIndex(onNowRowIndex)
+ end if
+ else
+ ' remake row using the new data
+ row = CreateObject("roSGNode", "HomeRow")
+ row.title = tr("On Now")
+ itemSize = [464, 331]
+ for each item in itemData
+ item.usePoster = row.usePoster
+ item.imageWidth = row.imageWidth
+ row.appendChild(item)
+ end for
+
+ if onNowRowIndex = invalid
+ ' insert new row under "My Media"
+ updateSizeArray(itemSize, 1)
+ homeRows.insertChild(row, 1)
+ else
+ ' replace the old row
+ homeRows.replaceChild(row, onNowRowIndex)
+ end if
+ end if
+end sub
+
function getRowIndex(rowTitle as string)
rowIndex = invalid
for i = 1 to m.top.content.getChildCount() - 1
diff --git a/components/home/LoadItemsTask.brs b/components/home/LoadItemsTask.brs
index 79e00b45..d1ef4439 100644
--- a/components/home/LoadItemsTask.brs
+++ b/components/home/LoadItemsTask.brs
@@ -74,7 +74,28 @@ sub loadItems()
tmp.json = item
results.push(tmp)
end for
+
+ else if m.top.itemsToLoad = "onNow"
+ url = "LiveTv/Programs/Recommended"
+ params = {}
+ params["userId"] = get_setting("active_user")
+ params["isAiring"] = true
+ params["limit"] = 16 ' 16 to be consistent with "Latest In"
+ params["imageTypeLimit"] = 1
+ params["enableImageTypes"] = "Primary,Thumb,Backdrop"
+ params["enableTotalRecordCount"] = false
+ params["fields"] = "ChannelInfo,PrimaryImageAspectRatio"
+
+ resp = APIRequest(url, params)
+ data = getJson(resp)
+ for each item in data.Items
+ tmp = CreateObject("roSGNode", "HomeData")
+ item.ImageURL = ImageURL(item.Id)
+ tmp.json = item
+ results.push(tmp)
+ end for
end if
+
m.top.content = results
-end sub
\ No newline at end of file
+end sub
diff --git a/locale/en_US/translations.ts b/locale/en_US/translations.ts
index 9d99cdb0..4edd447a 100644
--- a/locale/en_US/translations.ts
+++ b/locale/en_US/translations.ts
@@ -116,6 +116,10 @@
Latest in
+
+
+ On Now
+
Home
diff --git a/source/Main.brs b/source/Main.brs
index 4e68891e..9b5f8a76 100644
--- a/source/Main.brs
+++ b/source/Main.brs
@@ -112,7 +112,7 @@ sub Main (args as dynamic) as void
else if selectedItem.type = "Movie"
' open movie detail page
group = CreateMovieDetailsGroup(selectedItem)
- else if selectedItem.type = "TvChannel" or selectedItem.type = "Video"
+ else if selectedItem.type = "TvChannel" or selectedItem.type = "Video" or selectedItem.type = "Program"
' play channel feed
video_id = selectedItem.id
diff --git a/source/VideoPlayer.brs b/source/VideoPlayer.brs
index 4958d465..99d71191 100644
--- a/source/VideoPlayer.brs
+++ b/source/VideoPlayer.brs
@@ -26,6 +26,14 @@ sub AddVideoContent(video, audio_stream_idx = 1, subtitle_idx = -1, playbackPosi
return
end if
+ ' Special handling for "Programs" launched from "On Now"
+ if meta.json.type = "Program"
+ meta.title = meta.json.EpisodeTitle
+ meta.showID = meta.json.id
+ meta.live = true
+ video.id = meta.json.ChannelId
+ end if
+
video.content.title = meta.title
video.showID = meta.showID
diff --git a/source/api/Items.brs b/source/api/Items.brs
index 0374e490..b6f540c1 100644
--- a/source/api/Items.brs
+++ b/source/api/Items.brs
@@ -107,7 +107,7 @@ function ItemMetaData(id as string)
tmp.image = PosterImage(data.id)
tmp.json = data
return tmp
- else if data.type = "TvChannel"
+ else if data.type = "TvChannel" or data.type = "Program"
tmp = CreateObject("roSGNode", "ChannelData")
tmp.image = PosterImage(data.id)
tmp.json = data