Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
out/
out/roku-deploy.zip
.history/
.vscode/
19 changes: 0 additions & 19 deletions .vscode/launch.json

This file was deleted.

155 changes: 155 additions & 0 deletions components/keyboardScene.brs
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
sub init()
m.keyboard = m.top.findNode("myKeyboard")
m.itemsList = m.top.findNode("searchList")
m.video = m.top.findNode("video")
m.itemsList.observeField("itemSelected", "handleItemSelected")
m.heading = m.top.findNode("heading")
m.keyboard.setFocus(true)
m.keyboard.observeField("text", "handleText")
m.http = createObject("roSGNode", "httpTask")
m.http.observeFieldScoped("response", "useResponse")
m.keyboard.textBox.observeField("text", "handleText")
m.keyboard.observeField("submit", "handleSubmit")
end sub

sub handleText()
m.text = m.keyboard.textBox.text
end sub

sub handleSubmit()
handleVideoPlaybackResponse()

' m.http.request = { payload: {
' userId: 1,
' title: "WOW, IT WORKED ^_^",
' }, url: "https://youtube.googleapis.com/youtube/v3/search?part=snippet&q=" + m.text + "&maxResults=25&type=video&key=AIzaSyCxEpZ8-3gkiFpoc2SAkPBfcPFqQd6m_dw", requestType: "GET" }
' m.http.control = "RUN"
end sub

sub useResponse()
m.itemsThatContainString = createObject("roSGNode", "ContentNode")
items = []
m.itemsList.numColumns = 3
for each item in parseJson(m.http.response.body).items
Content = m.itemsThatContainString.createChild("ContentNode")
Content.HDPosterUrl = item.snippet.thumbnails.medium.url
Content.id = item.id.videoId
items.push(item)
end for
if items.count() = 2
m.itemsList.numColumns = 2
else if items.count() = 1
m.itemsList.numColumns = 1
end if
' handle empty text box
if m.keyboard.textBox.text = ""
m.itemsList.content = invalid
m.heading.visible = false
else
m.heading.visible = true
m.itemsList.content = m.itemsThatContainString
handleHeading()
end if
end sub

sub handleHeading()
m.heading.text = "These are the top videos that match " + Chr(34) + m.keyboard.textBox.text + Chr(34)
end sub

sub handleItemSelected()
' http://scienceandfilm.org/uploads/videos/files/afronauts_trailer.mp4
' playVideo(m.itemsThatContainString.getChild(m.itemsList.itemSelected).id)
end sub

function onKeyEvent(key as String, press as Boolean) as Boolean
if press and m.keyboard.visible = true
if key = "right" and not m.itemsList.hasFocus()
m.itemsList.setFocus(true)
return true
else if key = "left" and not m.keyboard.hasFocus()
m.keyboard.setFocus(true)
end if
end if
return false
end function

sub playVideo(id as String)
' m.videoPlaybackTask = createObject("roSGNode", "httpTask")
' m.videoPlaybackTask.request = { payload: {
' userId: 1,
' title: "WOW, IT WORKED ^_^",
' }, url: "https://www.youtube.com/watch?v=" + id, requestType: "GET" }
' m.videoPlaybackTask.control = "RUN"
' m.videoPlaybackTask.observeFieldScoped("response", "handleVideoPlaybackResponse")
end sub

sub handleVideoPlaybackResponse()
' initialPlayerResponseRegEx = createObject("roRegex", "ytInitialPlayerResponse\s*=\s*({.+?})\s*;", "m")
' matches = initialPlayerResponseRegEx.match(m.videoPlaybackTask.response.body)
videoContent = createObject("RoSGNode", "ContentNode")
' YouTube API Limit Exceeded
' videoContent.url = parseJson(matches[1]).streamingData.formats[0].url
videoContent.url = "https://bitmovin-a.akamaihd.net/content/art-of-motion_drm/m3u8s/11331.m3u8"
videoContent.streamFormat = "hls"
videoContent.drmParams = {
name: "Vertimatrix",
authDomain: "https://playready.directtaps.net/pr/svc/rightsmanager.asmx?PlayRight=1&ContentKey=EAtsIJQPd5pFiRUrV9Layw==",
serializationUrl: "https://playready.directtaps.net/pr/svc/rightsmanager.asmx?PlayRight=1&ContentKey=EAtsIJQPd5pFiRUrV9Layw=="
}
m.video.content = videoContent
m.video.visible = true
m.video.enableUI = false
m.video.enableTrickPlay = false
m.video.createChild("TrickPlay")
m.keyboard.visible = false
m.video.seekMode = "accurate"
m.video.setFocus(true)
m.video.control = "play"
m.video.getChild(2).setFocus(true)
m.video.getChild(2).observeField("play", "handlePlay")
m.video.getChild(2).observeField("forward", "handleForward")
m.video.getChild(2).observeField("back", "handleBack")
m.video.getChild(2).observeField("cc", "handleCC")
m.video.observeField("state", "videoStarted")
m.video.observeField("position", "updatePosition")
m.video.observeField("bufferingStatus", "updateBuffering")
end sub

sub updateBuffering()
if m.video.bufferingStatus <> invalid
m.video.getChild(2).loadingData = { percentage: m.video.bufferingStatus.percentage, done: m.video.bufferingStatus.prebufferDone }
end if
end sub

sub updatePosition()
m.video.getChild(2).position = m.video.position
end sub

sub videoStarted()
m.video.getChild(2).duration = m.video.duration
end sub

sub handlePlay()
if m.video.control = "play" or m.video.control = "resume"
m.video.control = "pause"
else
m.video.control = "resume"
end if
if m.video.state = "finished"
m.video.control = "play"
end if
end sub

sub handleForward()
m.video.seek = m.video.position + 15
m.video.control = "resume"
end sub

sub handleBack()
m.video.seek = m.video.position - 15
m.video.control = "resume"
end sub

sub handleCC()

end sub
12 changes: 12 additions & 0 deletions components/keyboardScene.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<component name="keyboardScene" extends="Scene" initialFocus="mainRowList">
<script type="text/brightscript" uri="keyboardScene.brs" />
<children>
<Group id="mainSearch">
<keyboardComponent id="myKeyboard" />
<Label id="heading" translation="[ 700, 145 ]" />
<PosterGrid id="searchList" basePosterSize="[125,125]" itemSpacing="[16,16]" translation="[ 730, 180 ]" numRows="3" numColumns="3" />
<Video id="video" visible="false" />
</Group>
</children>
</component>
7 changes: 7 additions & 0 deletions components/keyboardSceneItem.brs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
sub init()
m.itemPoster = m.top.findNode("imagePoster")
end sub

sub showContent()
m.itemPoster.uri = m.top.itemContent.HDPOSTERURL
end sub
10 changes: 10 additions & 0 deletions components/keyboardSceneItem.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<component name="SearchListItem" extends="Group">
<script type="text/brightscript" uri="keyboardSceneItem.brs" />
<interface>
<field id="itemContent" type="node" onChange="showContent" />
</interface>
<children>
<Poster id="imagePoster" width="50" height="50" />
</children>
</component>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
178 changes: 178 additions & 0 deletions components/keyboardcomponent/keyboardComponent.brs
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
sub init()
m.keyboardController = m.top.findNode("keyboardController")
m.keys = ["A", "J", "S", "1", "B", "K", "T", "2", "C", "L", "U", "3", "D", "M", "V", "4", "E", "N", "W", "5", "F", "O", "X", "6", "G", "P", "Y", "7", "H", "Q", "Z", "8", "I", "R", "0", "9"]
m.symbolsKeys = ["!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "-", "_", "+", "-", "/", "\", "|", "[", "]", "{", "}", ":", ";", "", "'", ",", ".", "<", ">", "?", "=", "`", "~", "X", "O", "..."]
m.symbolsFlag = false
initButtons()
m.focusIdx = 0
m.Col1.getChild(0).setFocus(true)
initObservers()
end sub

sub initButtons()
m.Col1 = m.keyboardController.findNode("Col1")
m.Col2 = m.keyboardController.findNode("Col2")
m.Col3 = m.keyboardController.findNode("Col3")
m.Col4 = m.keyboardController.findNode("Col4")
m.Col5 = m.keyboardController.findNode("Col5")
m.Col6 = m.keyboardController.findNode("Col6")
m.Col7 = m.keyboardController.findNode("Col7")
m.Col8 = m.keyboardController.findNode("Col8")
m.Col9 = m.keyboardController.findNode("Col9")
m.SYMBOLS = m.keyboardController.findNode("SYMBOLS")
m.SPACEBAR = m.keyboardController.findNode("SPACEBAR")
m.DELETE = m.keyboardController.findNode("DELETE")
m.SEARCH = m.keyboardController.findNode("SEARCH")
m.textBox = m.top.findNode("textBox")
it = -1
for each child in m.keyboardController.getChildren(9, 0)
it++
it2 = it + 3
for i = it to it2
childButton = createObject("roSGNode", "Button")
childButton.getChild(1).uri = ""
childButton.getChild(2).text = m.keys[i]
childButton.getChild(2).width = 72
childButton.getChild(2).height = 72
childButton.getChild(2).font = "font:SmallestBoldSystemFont"
childButton.getChild(2).horizAlign = "center"
childButton.iconUri = ""
childButton.focusedIconUri = ""
childButton.focusedTextFont = "font:SmallestBoldSystemFont"
childButton.textFont = "font:SmallestBoldSystemFont"
child.appendChild(childButton)
end for
it = it2
end for
end sub

sub handleSymbols()
it = -1
if m.symbolsFlag
for each child in m.keyboardController.getChildren(9, 0)
it++
it2 = it + 3
btnIdx = 0
for i = it to it2
child.getChild(btnIdx).getChild(2).text = m.keys[i]
btnIdx++
end for
it = it2
end for
m.symbolsFlag = false
else
for each child in m.keyboardController.getChildren(9, 0)
it++
it2 = it + 3
btnIdx = 0
for i = it to it2
child.getChild(btnIdx).getChild(2).text = m.symbolsKeys[i]
btnIdx++
end for
it = it2
end for
m.symbolsFlag = true
end if
end sub

sub initObservers()
m.Col1.observeField("buttonSelected", "handleItemSelect")
m.Col2.observeField("buttonSelected", "handleItemSelect")
m.Col3.observeField("buttonSelected", "handleItemSelect")
m.Col4.observeField("buttonSelected", "handleItemSelect")
m.Col5.observeField("buttonSelected", "handleItemSelect")
m.Col6.observeField("buttonSelected", "handleItemSelect")
m.Col7.observeField("buttonSelected", "handleItemSelect")
m.Col8.observeField("buttonSelected", "handleItemSelect")
m.Col9.observeField("buttonSelected", "handleItemSelect")
m.DELETE.observeField("buttonSelected", "handleExternalButtonSelect")
m.SPACEBAR.observeField("buttonSelected", "handleExternalButtonSelect")
m.SYMBOLS.observeField("buttonSelected", "handleExternalButtonSelect")
m.SEARCH.observeField("buttonSelected", "handleExternalButtonSelect")
m.top.textBox = m.textBox
end sub

sub handleExternalButtonSelect(event)
if event.getRoSGNode().text = "SPACE"
m.textBox.text += " "
else if event.getRoSGNode().id = "DELETE"
m.textBox.text = m.textBox.text.Left(m.textBox.text.Len() - 1)
else if event.getRoSGNode().id = "DELETE"
m.top.submit = not m.top.submit
else if event.getRoSGNode().id = "SEARCH"
m.top.submit = not m.top.submit
else
handleSymbols()
end if
end sub

sub handleItemSelect(event)
text = event.getRoSGNode().focusedChild.getChild(2).text
m.textBox.text += text
end sub

function onKeyEvent(key as String, press as Boolean) as Boolean
m.rowIdx = m.keyboardController.getChild(m.focusIdx).buttonFocused
if press
if key = "right" and m.focusIdx < 8 and not m.DELETE.hasFocus() and not m.SYMBOLS.hasFocus() and not m.SPACEBAR.hasFocus()
m.focusIdx++
m.keyboardController.getChild(m.focusIdx).focusButton = m.rowIdx
return true
else if key = "left" and m.focusIdx > 0 and not m.DELETE.hasFocus() and not m.SYMBOLS.hasFocus() and not m.SPACEBAR.hasFocus()
m.focusIdx--
m.keyboardController.getChild(m.focusIdx).focusButton = m.rowIdx
return true
else if key = "down" and m.focusIdx >= 2 and m.focusIdx <= 5
m.SPACEBAR.setFocus(true)
return true
else if key = "down" and m.focusIdx < 2
m.SYMBOLS.setFocus(true)
return true
else if key = "down" and m.focusIdx = 8
m.SEARCH.setFocus(true)
else if key = "down" and m.focusIdx > 5
m.DELETE.setFocus(true)
return true
else if key = "up" and m.focusIdx > 5
' Go to the item right above DELETE
m.keyboardController.getChild(8).focusButton = 3
m.focusIdx = 8
return true
else if key = "up" and m.focusIdx >= 2 and m.focusIdx <= 5
' Go to the item right above SPACE
m.keyboardController.getChild(4).focusButton = 3
m.focusIdx = 4
return true
else if key = "up" and m.focusIdx < 2
' Go to the item right above SYMBOLS
m.keyboardController.getChild(0).focusButton = 3
m.focusIdx = 0
return true
else if key = "right" and m.SPACEBAR.hasFocus()
m.focusIdx = 8
m.DELETE.setFocus(true)
return true
else if key = "right" and m.SYMBOLS.hasFocus()
m.focusIdx = 4
m.SPACEBAR.setFocus(true)
return true
else if key = "left" and m.DELETE.hasFocus()
m.focusIdx = 4
m.SPACEBAR.setFocus(true)
return true
else if key = "left" and m.SPACEBAR.hasFocus()
m.focusIdx = 0
m.SYMBOLS.setFocus(true)
return true
else if key = "left" and m.SEARCH.hasFocus()
m.focusIdx = 0
m.DELETE.setFocus(true)
return true
else if key = "right" and m.DELETE.hasFocus()
m.focusIdx = 0
m.SEARCH.setFocus(true)
return true
end if
end if
return false
end function
Loading