Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
zpon committed Apr 27, 2019
0 parents commit 7413496
Show file tree
Hide file tree
Showing 58 changed files with 1,241 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# DR on Demand ROKU channel

This project is not affiliated with DR / Danmark Radio in any way.
112 changes: 112 additions & 0 deletions components/ListScreen.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
<?xml version="1.0" encoding="UTF-8"?>

<component name="ListScreen" extends="Group" initialFocus="list">

<interface>
<field id = "obj" type = "assocarray" onChange="objSet" />
</interface>

<script type="text/brightscript">
<![CDATA[
Sub init()
m.top.setFocus(true)
m.list = m.top.findNode("list")
m.list.content = createObject("RoSGNode", "ContentNode")
' Download offset
m.offset = 0
' Downloaded items to be displayed
m.items = []
m.list.ObserveField("itemSelected", "listItemSelected")
End Sub
sub listItemSelected()
print "Item Selected"
selectedItem = m.list.itemSelected
print "-- selected item "; selectedItem
if (selectedItem >= 0) and (selectedItem < m.items.Count())
m.list.visible = false
obj = m.items.GetEntry(selectedItem)
print obj.type
m.CurrentScreen = CreateObject("RoSGNode", "SeriesScreen")
m.CurrentScreen.obj = obj
m.CurrentScreen.id = "CURRENT_TEST"
m.top.AppendChild(m.CurrentScreen)
m.CurrentScreen.SetFocus(true)
end if
end sub
function onKeyEvent(key as String, press as Boolean) as Boolean
print "in testList.xml onKeyEvent ";key;" "; press
if press then
if key = "back"
if not (m.CurrentScreen = invalid)
print "CLEANING UP m.CurrentScreen"
m.top.RemoveChild(m.CurrentScreen)
m.CurrentScreen = invalid
m.list.visible = true
m.list.SetFocus(true)
return true
end if
else if key = "home"
m.top.RemoveChild(m.CurrentScreen)
m.CurrentScreen = invalid
end if
end if
return false
end function
Sub objSet()
print "Obj set"
if m.top.obj.type = "letter"
loadLetterData()
else
print "Wrong type: " + obj.type
end if
end Sub
Sub loadLetterData()
m.FetcherTask = createObject("roSGNode", "FetcherTask")
m.FetcherTask.url = "https://www.dr.dk/mu-online/api/1.4/search/tv/programcards-latest-episode-with-asset/series-title-starts-with/" + m.top.obj.letter.EncodeUriComponent() +"?orderBy=title&limit=40&offset=" + m.offset.ToStr()
m.FetcherTask.observeField("result", "letterDataLoaded")
m.FetcherTask.control = "RUN"
end Sub
Sub letterDataLoaded()
'listContent = createObject("RoSGNode", "ContentNode")
? m.FetcherTask.result.Items
m.items.append(m.FetcherTask.result.Items)
'm.list.content.appendChildren(listContent)
m.offset += m.FetcherTask.result.Items.count()
print "Offset: " ; m.offset
if m.offset < m.FetcherTask.result.TotalSize
print "Load more"
loadLetterData()
else
m.items.SortBy("SeriesTitle", "i")
for each item in m.items
node = m.list.content.createChild("ContentNode")
node.title = item.SeriesTitle
end for
print "Nothing left to load"
end if
end Sub
]]>
</script>
<children>
<LabelList
id="list"
translation="[100, 32]"
itemSize="[1024, 72]"
itemSpacing="[15, 15]"
focusRow="0" >
</LabelList>
</children>
</component>
92 changes: 92 additions & 0 deletions components/PlayerScreen.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<?xml version="1.0" encoding="UTF-8"?>


<component name="PlayerScreen" extends="Group" initialFocus="video">
<interface>
<field id="card" type="assocarray" onChange="cardSet" />
<field id="done" type="bool" />
</interface>

<script type = "text/brightscript" uri = "pkg:/source/utils.brs" />
<script type = "text/brightscript" uri = "pkg:/source/decrypt.brs" />
<script type="text/brightscript">
<![CDATA[
Sub init()
m.top.setFocus(true)
m.video = m.top.findNode("video")
m.FetcherTask = createObject("roSGNode", "FetcherTask")
m.top.done = false
m.video.ObserveField("state", "stateChange")
End Sub
Sub stateChange()
? m.video.state
if m.video.state = "finished"
m.top.done = true
end if
end Sub
Sub rowListContentChanged()
print "ContentUpdate"
m.RowList.content = m.LoadTask.content
end Sub
Sub cardSet()
print "cardSet"
? m.top.card
m.FetcherTask.url = m.top.card.PrimaryAsset.Uri
m.FetcherTask.observeField("result", "play")
m.FetcherTask.control = "RUN"
end Sub
Sub play()
print "play"
? m.FetcherTask.result
link = decrypt(m.FetcherTask.result.Links[1].EncryptedUri, m.global.seed)
? link
item = createObject("RoSGNode", "ContentNode")
item.Title = m.top.card.SeriesTitle + " - " + m.top.card.Title
item.Description = m.top.card.Subtitle
item.HDPosterUrl = m.top.card.PrimaryImageUri
item.Url = link
item.streamFormat = m.FetcherTask.result.Links[1].Target
if m.FetcherTask.result.DoesExist("SubtitlesList") and m.FetcherTask.result.SubtitlesList.Count() > 0
item.SubtitleUrl = m.FetcherTask.result.SubtitlesList[0].Uri
item.SubtitleTracks = [{Description: m.FetcherTask.result.SubtitlesList[0].Language}]
end if
? item
m.video.content = item
m.video.control = "play"
m.video.SetFocus(true)
end Sub
]]>
</script>
<children>
<Video
id = "video"
translation = "[0,0]"
width = "1920"
height = "1080"
enableUI = "true"
loop = "false"
/>
<RowList
id="rowList"
translation="[231,100]"
itemComponentName="PosterItem"
itemSize="[1458,254]"
numRows="5"
rowItemSize="[[1220,591],[351,197]]"
rowHeights="[648,254]"
rowItemSpacing="[[54,0],[18,0]]"
rowLabelOffset="[[0,8]]"
showRowLabel="[true]"
showRowCounter="[true]"
focusXOffset="[119,0]"
rowFocusAnimationStyle = "floatingFocus"/>
</children>
</component>

Loading

0 comments on commit 7413496

Please sign in to comment.