Skip to content

Commit

Permalink
made some improvements in UI layer.
Browse files Browse the repository at this point in the history
  • Loading branch information
mnsrulz committed Feb 2, 2020
1 parent 08ad1bf commit 782069e
Show file tree
Hide file tree
Showing 7 changed files with 113 additions and 141 deletions.
66 changes: 21 additions & 45 deletions components/s0/s0.brs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ sub init()
m.top.appendChild(oh)
m.Overhang = oh

ps = createObject("roSGNode", "PanelSet")
m.top.appendChild(ps)
m.panelSet = ps
m.panelSet = createObject("roSGNode", "PanelSet")
m.top.appendChild(m.panelSet)

oh.showOptions = true
loadCategories()
Expand All @@ -19,29 +18,16 @@ sub initVideoPlayer()
m.video = createObject("roSGNode", "Video")
m.video.visible = false
m.top.appendChild(m.video)
m.video.observeField("state","controlvideoplay")
end sub

sub controlvideoplay()
print m.video.state
if (m.video.state = "finished") then
m.video.control = "stop"
'm.videolist.setFocus(true)
m.video.visible = false
else if(m.video.state = "error") then
m.listpanel4.random = RND(999999)
end if
end sub

function onKeyEvent(key as string,press as boolean) as boolean
' This event is an overhead, but we have live with it.
if press then
if key = "back"
if (m.video.state = "playing")
if (m.video.visible)
m.video.control = "stop"
'm.videolist.setFocus(true)
m.video.visible = false
m.listpanel4.random = RND(999999)
''m.listpanel4.setFocus(true)
m.mediaSourcesPanel.lastFocusNode.setFocus(true)
return true
end if
end if
Expand Down Expand Up @@ -80,46 +66,36 @@ end sub
sub showcategorymedia()
categorycontent = m.categoriespanel.list.content.getChild(m.categoriespanel.list.itemFocused)
m.gridPanel.categoryKey = categorycontent.ShortDescriptionLine1
m.Overhang.title = categorycontent.title
end sub

sub setpanels()
m.categoriespanel = m.panelSet.createChild("s1")
m.gridPanel = m.panelSet.createChild("s2")
m.listpanel3 = createObject("RoSGNode","s3")
m.listpanel4 = createObject("RoSGNode", "s4")
m.listpanel4.video = m.video

m.listpanel3.topcontainer = m.top
m.listpanel3.gridPanel = m.gridPanel
m.gridPanel.grid.observeField("itemFocused", "showCurrentSelectedMediaInfo")
m.gridPanel.observeField("focusedChild", "slidepanels")
m.listpanel3.observeField("focusedChild", "slidepanels1")
end sub

sub showCurrentSelectedMediaInfo()
currentSelectedMediaItem = m.gridPanel.grid.content.getChild(m.gridPanel.grid.itemFocused)
m.Overhang.title = currentSelectedMediaItem.shortdescriptionline1
m.listpanel3.mediaItem = currentSelectedMediaItem

m.posterPanel = createObject("RoSGNode","s3")
m.posterPanel.mediaItem = currentSelectedMediaItem
m.gridPanel.nextPanel = m.posterPanel
m.posterPanel.observeField("focusedChild", "onFucusPosterPanel")
print "selection changed"
end sub

sub slidepanels()
sub onFucusPosterPanel()
if not m.panelSet.isGoingBack
if m.panelSet.leftPanelIndex = 0 then
m.panelSet.appendChild(m.listpanel3)
end if
m.posterPanel.posterMode = "full"
mediaSourcesPanel = createObject("RoSGNode", "s4")
mediaSourcesPanel.video = m.video
m.mediaSourcesPanel = mediaSourcesPanel
m.panelSet.appendChild(mediaSourcesPanel)
currentSelectedMediaItem = m.gridPanel.grid.content.getChild(m.gridPanel.grid.itemFocused)
mediaSourcesPanel.mediaItem = currentSelectedMediaItem
m.mediaSourcesPanel.setFocus(true)
else
m.listpanel3.posterMode = "normal"
m.gridPanel.setFocus(true)
end if
end sub

sub slidepanels1()
if not m.panelSet.isGoingBack
if m.panelSet.leftPanelIndex = 1 then
m.listpanel3.posterMode = "full"
m.panelSet.appendChild(m.listpanel4)
m.listpanel4.mediaItem = m.listpanel3.mediaItem
end if
m.posterPanel.posterMode = ""
end if
end sub
97 changes: 50 additions & 47 deletions components/s2/s2.brs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ sub init()
m.top.focusable = true
m.top.hasNextPanel = true
' m.top.leftPosition = 130
m.top.createNextPanelOnItemFocus = false
m.top.createNextPanelOnItemFocus = true
m.top.selectButtonMovesPanelForward = true
m.top.optionsAvailable = false
m.top.grid = m.top.findNode("posterGridCategoryMedia")
Expand Down Expand Up @@ -44,54 +44,57 @@ end function

sub showpostergrid()
resultAsJson = ParseJSON(m.readPosterGridTask.content)
parsedContent = createObject("roSGNode", "ContentNode")
for each mediaItem in resultAsJson.items
gridPoster = createObject("roSGNode", "ContentNode")
gridPoster.id = mediaItem.imdbInfo.id
gridPoster.shortdescriptionline1 = mediaItem.imdbInfo.title
gridPoster.Description = mediaItem.imdbInfo.plot
if IsString(mediaItem.mediaSourceUrl)
' gridPoster.SDPosterUrl = "http://mediacatalogadmin.herokuapp.com" + mediaItem.imdbInfo.posterThumb
' gridPoster.HDPosterUrl = "http://mediacatalogadmin.herokuapp.com" + mediaItem.imdbInfo.posterThumb
gridPoster.SDPosterUrl = mediaItem.imdbInfo.posterThumb
gridPoster.HDPosterUrl = mediaItem.imdbInfo.posterThumb
gridPoster.Url = mediaItem.imdbInfo.posterHD
if resultAsJson <> invalid

sources = CreateObject("roArray", 1, true)
sources.push("http://mediacatalogadmin.herokuapp.com" + mediaItem.mediaSourceUrl)
gridPoster.StreamContentIDs = sources
else
sources = CreateObject("roArray", mediaItem.mediaSources.Count(), true)
for each source in mediaItem.mediaSources
streamUrl = "http://apighost.herokuapp.com/api/gddirectstreamurl/" + source.id
headerStrigify = ""
if (IsString(source.streamUrl) and source.streamUrl <> "")
streamUrl = source.streamUrl
end if
if (IsArray(source.headers))
headerStrigify = JoinStrArr(source.headers, ";")
end if
sources.push({
url : streamUrl,
bitrate : source.size
quality : false
contentid : source.source + "|" + source.mimeType + "|" + headerStrigify
})
end for
gridPoster.Streams = sources
gridPoster.shortdescriptionline2 = mediaItem.mediaSources[0].id
' basePoster = Left(mediaItem.imdbInfo.poster, lastIndexOf(mediaItem.imdbInfo.poster, "@"))
' gridPoster.SDPosterUrl = basePoster + "._V1_UX182_CR0,0,182,268_AL_.jpg"
' gridPoster.HDPosterUrl = basePoster + "._V1_UX182_CR0,0,182,268_AL_.jpg"
' gridPoster.Url = basePoster + "._V1_UX388_CR0,0,388,512_AL_.jpg"
gridPoster.SDPosterUrl = mediaItem.imdbInfo.posterThumb
gridPoster.HDPosterUrl = mediaItem.imdbInfo.posterThumb
gridPoster.Url = mediaItem.imdbInfo.posterHD
end if
parsedContent = createObject("roSGNode", "ContentNode")
for each mediaItem in resultAsJson.items
gridPoster = createObject("roSGNode", "ContentNode")
gridPoster.id = mediaItem.imdbInfo.id
gridPoster.shortdescriptionline1 = mediaItem.imdbInfo.title
gridPoster.Description = mediaItem.imdbInfo.plot
if IsString(mediaItem.mediaSourceUrl)
' gridPoster.SDPosterUrl = "http://mediacatalogadmin.herokuapp.com" + mediaItem.imdbInfo.posterThumb
' gridPoster.HDPosterUrl = "http://mediacatalogadmin.herokuapp.com" + mediaItem.imdbInfo.posterThumb
gridPoster.SDPosterUrl = mediaItem.imdbInfo.posterThumb
gridPoster.HDPosterUrl = mediaItem.imdbInfo.posterThumb
gridPoster.Url = mediaItem.imdbInfo.posterHD

parsedContent.appendChild(gridPoster)
end for
m.top.grid.content = parsedContent
sources = CreateObject("roArray", 1, true)
sources.push("http://mediacatalogadmin.herokuapp.com" + mediaItem.mediaSourceUrl)
gridPoster.StreamContentIDs = sources
else
sources = CreateObject("roArray", mediaItem.mediaSources.Count(), true)
for each source in mediaItem.mediaSources
streamUrl = "http://apighost.herokuapp.com/api/gddirectstreamurl/" + source.id
headerStrigify = ""
if (IsString(source.streamUrl) and source.streamUrl <> "")
streamUrl = source.streamUrl
end if
if (IsArray(source.headers))
headerStrigify = JoinStrArr(source.headers, ";")
end if
sources.push({
url : streamUrl,
bitrate : source.size
quality : false
contentid : source.source + "|" + source.mimeType + "|" + headerStrigify
})
end for
gridPoster.Streams = sources
gridPoster.shortdescriptionline2 = mediaItem.mediaSources[0].id
' basePoster = Left(mediaItem.imdbInfo.poster, lastIndexOf(mediaItem.imdbInfo.poster, "@"))
' gridPoster.SDPosterUrl = basePoster + "._V1_UX182_CR0,0,182,268_AL_.jpg"
' gridPoster.HDPosterUrl = basePoster + "._V1_UX182_CR0,0,182,268_AL_.jpg"
' gridPoster.Url = basePoster + "._V1_UX388_CR0,0,388,512_AL_.jpg"
gridPoster.SDPosterUrl = mediaItem.imdbInfo.posterThumb
gridPoster.HDPosterUrl = mediaItem.imdbInfo.posterThumb
gridPoster.Url = mediaItem.imdbInfo.posterHD
end if

parsedContent.appendChild(gridPoster)
end for
m.top.grid.content = parsedContent
end if
end sub

function lastIndexOf(input as string, char as string) as integer
Expand Down
4 changes: 3 additions & 1 deletion components/s3/s3.brs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ sub init()
m.top.focusable = true
m.top.hasNextPanel = true
'm.top.leftPosition = 130
m.top.createNextPanelOnItemFocus = false
' m.top.createNextPanelOnItemFocus = false
m.top.optionsAvailable = false
m.top.goBackCount = 2
m.mediaTitle = m.top.findNode("mediaTitle")
Expand Down Expand Up @@ -38,6 +38,8 @@ sub readImdbInfo()
else if resultAsJson.rating <> invalid
m.mediaDesc.text = "Imdb: " + resultAsJson.rating
end if
else
print "Imdb info parse result failed"
end if
end sub

Expand Down
3 changes: 1 addition & 2 deletions components/s3/s3.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@
<LayoutGroup
id = "infoRectangle"
translation = "[ 0, 44 ]"
color = "0x101010C0" itemSpacings = "[8]">
itemSpacings = "[8]">
<Poster id="mediaposter" width="288" height="428" />
<Label
id = "mediaTitle"
width="388"
wrap = "true"
Lines = "2"
font = "font:MediumSystemFont" />
<Label
id = "mediaDesc"
Expand Down
69 changes: 31 additions & 38 deletions components/s4/s4.brs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ sub init()
m.top.focusable = true
m.top.hasNextPanel = false
m.top.leftPosition = 130
m.top.createNextPanelOnItemFocus = false
m.lstMediaSources = m.top.findNode("mediaSourceList")
m.mediaTitle = m.top.findNode("mediaTitle")
m.mediaDesc = m.top.findNode("mediaDesc")
Expand Down Expand Up @@ -49,30 +48,17 @@ sub readmediaitem()
ContentNode_child_object.ShortDescriptionLine2 = categoryKey.contentid.Split("|")[2]
print categoryKey.displayName
end for
m.LoadMediaItemsTask = CreateObject("roSGNode", "SimpleTask")
m.LoadMediaItemsTask.uri = "http://jsonplaceholder.typicode.com/todos/1"
m.LoadMediaItemsTask.observeField("content", "fakeEvent")
print "setting to execution of category load task"
m.LoadMediaItemsTask.control = "RUN"
m.lstMediaSources.setFocus(true)
end if
m.lstMediaSources.observeField("itemFocused", "preloadmedia")
m.lstMediaSources.observeField("itemSelected", "itemselected")
m.top.video.observeField("state", "controlvideoplay")

m.mediaTitle.text = currentitem.shortdescriptionline1
m.mediaDesc.text = currentitem.DESCRIPTION
m.mediaFileName.text = ""
end sub

sub readRandom()
m.FakeEventTask = CreateObject("roSGNode", "SimpleTask")
m.FakeEventTask.uri = "http://jsonplaceholder.typicode.com/todos/1"
m.FakeEventTask.observeField("content", "fakeEvent")
print "setting up fake event task"
m.FakeEventTask.control = "RUN"
end sub

sub fakeEvent()
m.lstMediaSources.setFocus(true)
end sub

sub loadmediaitems()
print "Loading media sources..."
resultAsJson = ParseJSON(m.LoadMediaItemsTask.content)
Expand All @@ -97,6 +83,7 @@ end sub


sub preloadmedia()
print "Preloading media"
selectedmediaitem = m.lstMediaSources.content.getChild(m.lstMediaSources.itemFocused)
previousvideocontenturl = ""
if m.top.video.content <> invalid
Expand All @@ -109,7 +96,6 @@ sub preloadmedia()
m.mediaFileName.text = selectedmediaitem.title
videoContent.streamformat = getMediaStreamFormat(selectedmediaitem.ShortDescriptionLine1) ''should be passed from top
videoContent.HttpHeaders = getMediaStreamHeaders(selectedmediaitem.ShortDescriptionLine2)
' videoContent.enableUI = true
m.top.video.content = videoContent
m.top.video.control = "prebuffer"
end if
Expand Down Expand Up @@ -143,23 +129,30 @@ function getMediaStreamHeaders(headers as string) as object
return headersasarray
end function

function onKeyEvent(key as string, press as boolean) as boolean
if press then
if key = "back"
if (m.top.video.state = "playing")
m.top.video.control = "stop"
'm.videolist.setFocus(true)
m.top.video.visible = false
return true
end if
else if (key = "OK") then
m.top.video.visible = true
m.top.video.setFocus(true)
if (m.top.video.content.STREAMFORMAT = "hls")
m.top.video.seek = 9999999999
end if
m.top.video.control = "play"
end if
sub itemselected()
m.top.video.visible = true
m.top.video.setFocus(true)
if (m.top.video.content.STREAMFORMAT = "hls")
m.top.video.seek = 9999999999
end if
return false
end function
m.top.video.control = "play"
m.top.lastFocusNode = m.lstMediaSources
end sub

sub controlvideoplay()
print m.top.video.state
if (m.top.video.state = "finished") then
m.top.video.control = "stop"
m.top.video.visible = false
m.lstMediaSources.setFocus(true)
else if (m.top.video.state = "buffering") then
currentplayitem = m.top.video
else if(m.top.video.state = "error") then
' itemfocusednow = m.lstMediaSources.itemFocused
' selectedmediaitem = m.lstMediaSources.content.getChild(itemfocusednow)
' selectedmediaitem.title = "ERROR READING SOURCE"
m.lstMediaSources.setFocus(true)
end if
end sub


7 changes: 3 additions & 4 deletions components/s4/s4.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,18 @@
<interface>
<field id="video" type="node" />
<field id="mediaItem" type="node" onChange = "readmediaitem" />
<field id="random" type="string" onChange="readRandom" />
<field id="lastFocusNode" type="node" />
</interface>
<script type = "text/brightscript" uri = "pkg:/components/s4/s4.brs"/>

<children>
<LayoutGroup
id = "layoutgroup4"
translation = "[ 0, 40 ]"
color = "0x101010C0" itemSpacings = "[8]">
itemSpacings = "[8]">
<Label
id = "mediaTitle" width="645"
wrap = "true"
Lines = "2"
font = "font:MediumBoldSystemFont" />
<LabelList id = "mediaSourceList" itemSize="[512, 32]" numRows="6">
<ContentNode role = "content">
Expand All @@ -29,8 +28,8 @@
</LabelList>
<Label
id = "mediaFileName" width="645"
maxLines = "2"
wrap = "true"
Lines = "2"
font = "font:SmallSystemFont" />
<Label
id = "mediaDesc" width="645"
Expand Down
Loading

0 comments on commit 782069e

Please sign in to comment.