WIP (recording single and series with red logo)

This commit is contained in:
jimiatnymbl 2022-01-08 21:40:25 -07:00
parent c9bf023949
commit 78fb57bcb1
9 changed files with 101 additions and 21 deletions

View File

@ -27,6 +27,13 @@ sub loadProgramDetails()
program.channelIndex = channelIndex
program.programIndex = programIndex
program.fullyLoaded = true
' Are we currently recording this program?
if program.json.TimerId <> invalid
' This is needed here because the callee (onProgramDetailsLoaded) replaces the grid item with
' this newly created item from the server, without this, the red icon
' disappears when the user focuses on the program in question
program.hdSmallIconUrl = "pkg:/images/red.png"
end if
m.top.programDetails = program
end sub

View File

@ -32,10 +32,14 @@ sub loadSchedule()
for each item in data.Items
program = createObject("roSGNode", "ScheduleProgramData")
program.json = item
' Are we currently recording this program?
if program.json.TimerId <> invalid
program.hdSmallIconUrl = "pkg:/images/red.png"
end if
results.push(program)
end for
m.top.schedule = results
end sub
end sub

View File

@ -23,13 +23,20 @@ sub init()
m.viewChannelFocusAnimationOpacity = m.top.findNode("viewChannelFocusAnimationOpacity")
m.recordFocusAnimationOpacity = m.top.findNode("recordFocusAnimationOpacity")
m.recordSeriesFocusAnimationOpacity = m.top.findNode("recordSeriesFocusAnimationOpacity")
m.focusAnimation = m.top.findNode("focusAnimation")
m.viewChannelButton = m.top.findNode("viewChannelButton")
m.recordButton = m.top.findNode("recordButton")
m.recordSeriesButton = m.top.findNode("recordSeriesButton")
m.viewChannelOutline = m.top.findNode("viewChannelOutline")
m.recordOutline = m.top.findNode("recordOutline")
m.recordSeriesOutline = m.top.findNode("recordSeriesOutline")
m.viewChannelLabel = m.top.findNode("viewChannelButtonLabel")
m.recordLabel = m.top.findNode("recordButtonLabel")
m.recordSeriesLabel = m.top.findNode("recordSeriesButtonLabel")
m.focusAnimation.observeField("state", "onAnimationComplete")
@ -52,6 +59,7 @@ sub setupLabels()
isRepeatBackground.height = boundingRect.height + 8
m.episodeDetailsGroup.removeChildIndex(0)
m.viewChannelLabel.text = tr("View Channel")
boundingRect = m.viewChannelButton.boundingRect()
viewButtonBackground = m.top.findNode("viewChannelButtonBackground")
viewButtonBackground.width = boundingRect.width + 20
@ -59,12 +67,21 @@ sub setupLabels()
m.viewChannelOutline.width = viewButtonBackground.width
m.viewChannelOutline.height = viewButtonBackground.height
m.recordLabel.text = tr("Record")
boundingRect = m.recordButton.boundingRect()
recordButtonBackground = m.top.findNode("recordButtonBackground")
recordButtonBackground.width = boundingRect.width + 20
recordButtonBackground.height = boundingRect.height + 20
m.recordOutline.width = recordButtonBackground.width
m.recordOutline.height = recordButtonBackground.height
m.recordOutline.height = recordButtonBackground.height
m.recordSeriesLabel.text = tr("Record Series")
boundingRect = m.recordSeriesButton.boundingRect()
recordSeriesButtonBackground = m.top.findNode("recordSeriesButtonBackground")
recordSeriesButtonBackground.width = boundingRect.width + 20
recordSeriesButtonBackground.height = boundingRect.height + 20
m.recordSeriesOutline.width = recordSeriesButtonBackground.width
m.recordSeriesOutline.height = recordSeriesButtonBackground.height
end sub
sub channelUpdated()
@ -220,6 +237,7 @@ sub focusChanged()
m.overview.maxLines = m.maxDetailLines
m.viewChannelFocusAnimationOpacity.keyValue = [0, 1]
m.recordFocusAnimationOpacity.keyValue = [0, 1]
m.recordSeriesFocusAnimationOpacity.keyValue = [0, 1]
m.viewChannelButton.setFocus(true)
m.viewChannelOutline.visible = true
else
@ -228,6 +246,7 @@ sub focusChanged()
m.top.recordSeriesSelectedChannel = false
m.viewChannelFocusAnimationOpacity.keyValue = [1, 0]
m.recordFocusAnimationOpacity.keyValue = [1, 0]
m.recordSeriesFocusAnimationOpacity.keyValue = [1, 0]
end if
m.focusAnimation.control = "start"
@ -249,10 +268,9 @@ function onKeyEvent(key as string, press as boolean) as boolean
else if key = "OK" and m.recordButton.hasFocus()
m.top.recordSelectedChannel = true
return true
' TODO/FIXME: Add Record Series button and logic
' else if key = "OK" and m.recordSeriesButton.hasFocus()
' m.top.recordSeriesSelectedChannel = true
' return true
else if key = "OK" and m.recordSeriesButton.hasFocus()
m.top.recordSeriesSelectedChannel = true
return true
end if
if key = "right" and m.viewChannelButton.hasFocus()
@ -260,6 +278,14 @@ function onKeyEvent(key as string, press as boolean) as boolean
m.viewChannelOutline.visible = false
m.recordOutline.visible = true
return true
else if key = "right" and m.recordButton.hasFocus()
m.recordSeriesButton.setFocus(true)
m.recordOutline.visible = false
m.recordSeriesOutline.visible = true
else if key = "left" and m.recordSeriesButton.hasFocus()
m.recordButton.setFocus(true)
m.recordOutline.visible = true
m.recordSeriesOutline.visible = false
else if key = "left" and m.recordButton.hasFocus()
m.viewChannelButton.setFocus(true)
m.viewChannelOutline.visible = true

View File

@ -39,15 +39,22 @@
<Group id="viewChannelButton" opacity="0">
<Poster id="viewChannelButtonBackground" uri="pkg:/images/white.9.png" blendColor="#006fab" />
<Poster id="viewChannelOutline" visible="false" uri="pkg:/images/hd_focus.9.png" />
<Label text="View Channel" translation="[20,20]" />
<Label id="viewChannelButtonLabel" text="View Channel" translation="[20,20]" />
</Group>
<!-- Record button -->
<Group id="recordButton" opacity="0">
<Poster id="recordButtonBackground" uri="pkg:/images/white.9.png" blendColor="#006fab" />
<Poster id="recordOutline" visible="false" uri="pkg:/images/hd_focus.9.png" />
<Label text="Record" translation="[20,20]" />
<Label id="recordButtonLabel" text="Record" translation="[20,20]" />
</Group>
<!-- Record Series button-->
<Group id="recordSeriesButton" opacity="0">
<Poster id="recordSeriesButtonBackground" uri="pkg:/images/white.9.png" blendColor="#006fab" />
<Poster id="recordSeriesOutline" visible="false" uri="pkg:/images/hd_focus.9.png" />
<Label id="recordSeriesButtonLabel" text="Record Series" translation="[20,20]" />
</Group>
</LayoutGroup>
</LayoutGroup>
@ -62,6 +69,7 @@
<Animation id="focusAnimation" duration="0.66" repeat="false" easeFunction="linear" >
<FloatFieldInterpolator id="viewChannelFocusAnimationOpacity" key="[0.0, 1]" fieldToInterp="viewChannelButton.opacity" />
<FloatFieldInterpolator id="recordFocusAnimationOpacity" key="[0.0, 1]" fieldToInterp="recordButton.opacity" />
<FloatFieldInterpolator id="recordSeriesFocusAnimationOpacity" key="[0.0, 1]" fieldToInterp="recordSeriesButton.opacity" />
</Animation>
</children>
<interface>

View File

@ -17,11 +17,13 @@ sub RecordProgram()
if data <> invalid
' Create recording timer...
url = "LiveTv/Timers"
if m.top.recordSeries = true
url = "LiveTv/SeriesTimers"
else
url = "LiveTv/Timers"
end if
resp = APIRequest(url)
success = postJson(resp, FormatJson(data))
print "success value " success
' Indicate success back to our caller
postJson(resp, FormatJson(data))
m.top.timerCreated = true
else
' Error msg to user?

View File

@ -3,6 +3,7 @@
<component name="RecordProgramTask" extends="Task">
<interface>
<field id="programDetails" type="node" value="" />
<field id="recordSeries" type="boolean" value="false" />
<field id="timerCreated" type="boolean" value="" />
</interface>
<script type="text/brightscript" uri="RecordProgramTask.brs" />

View File

@ -6,6 +6,7 @@ sub init()
m.detailsPane.observeField("watchSelectedChannel", "onWatchChannelSelected")
m.detailsPane.observeField("recordSelectedChannel", "onRecordChannelSelected")
m.detailsPane.observeField("recordSeriesSelectedChannel", "onRecordSeriesChannelSelected")
m.gridStartDate = CreateObject("roDateTime")
m.scheduleGrid.contentStartTime = m.gridStartDate.AsSeconds() - 1800
@ -188,24 +189,35 @@ sub onRecordChannelSelected()
' Set focus back to grid before showing channel, to ensure grid has focus when we return
focusProgramDetails(false)
'TODO/FIXME:
' * Present "Please Wait"
m.scheduleGrid.showLoadingDataFeedback = true
' * Send data to Server
m.RecordProgramTask = createObject("roSGNode", "RecordProgramTask")
m.RecordProgramTask.programDetails = m.detailsPane.programDetails
m.RecordProgramTask.recordSeries = false
m.RecordProgramTask.observeField("timerCreated", "onTimerCreated")
m.RecordProgramTask.control = "RUN"
' * Indicate success / failure
m.scheduleGrid.showLoadingDataFeedback = false
end sub
' Handle user selecting "Record Series" from Program Details
sub onRecordSeriesChannelSelected()
if m.detailsPane.recordSeriesSelectedChannel = false then return
' Set focus back to grid before showing channel, to ensure grid has focus when we return
focusProgramDetails(false)
m.scheduleGrid.showLoadingDataFeedback = true
m.RecordProgramTask = createObject("roSGNode", "RecordProgramTask")
m.RecordProgramTask.programDetails = m.detailsPane.programDetails
m.RecordProgramTask.recordSeries = true
m.RecordProgramTask.observeField("timerCreated", "onTimerCreated")
m.RecordProgramTask.control = "RUN"
end sub
sub onTimerCreated()
if m.RecordProgramTask.timerCreated = true
print "Timer Created Successfully!!"
else
print "Timer creation failed :-("
end if
m.scheduleGrid.showLoadingDataFeedback = false
end sub
' As user scrolls grid, check if more data requries to be loaded

BIN
images/red.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

View File

@ -361,6 +361,26 @@
<translation>TV Guide</translation>
<extracomment>Menu option for showing Live TV Guide / Schedule</extracomment>
</message>
<message>
<source>View Channel</source>
<translation>View Channel</translation>
</message>
<message>
<source>Record</source>
<translation>Record</translation>
</message>
<message>
<source>Record Series</source>
<translation>Record Series</translation>
</message>
<message>
<source>Cancel Recording</source>
<translation>Cancel Recording</translation>
</message>
<message>
<source>Cancel Series Recording</source>
<translation>Cancel Series Recording</translation>
</message>
<message>
<source>Connecting to Server</source>
<translation>Connecting to Server</translation>