This commit is contained in:
jimiatnymbl 2022-01-08 22:43:17 -07:00
parent 78fb57bcb1
commit 76c96ab1e7
5 changed files with 83 additions and 25 deletions

View File

@ -84,6 +84,25 @@ sub setupLabels()
m.recordSeriesOutline.height = recordSeriesButtonBackground.height
end sub
sub updateLabels(recordText = "Record", recordSeriesText = "Record Series")
m.recordLabel.text = tr(recordText)
m.recordSeriesLabel.text = tr(recordSeriesText)
boundingRect = m.recordButton.boundingRect()
recordButtonBackground = m.top.findNode("recordButtonBackground")
recordButtonBackground.width = boundingRect.width
recordButtonBackground.height = boundingRect.height
m.recordOutline.width = recordButtonBackground.width
m.recordOutline.height = recordButtonBackground.height
boundingRect = m.recordSeriesButton.boundingRect()
recordSeriesButtonBackground = m.top.findNode("recordSeriesButtonBackground")
recordSeriesButtonBackground.width = boundingRect.width
recordSeriesButtonBackground.height = boundingRect.height
m.recordSeriesOutline.width = recordSeriesButtonBackground.width
m.recordSeriesOutline.height = recordSeriesButtonBackground.height
end sub
sub channelUpdated()
if m.top.channel = invalid
m.top.findNode("noInfoChannelName").text = ""
@ -175,6 +194,16 @@ sub programUpdated()
m.image.uri = prog.PosterURL
' If currently being recorded, change button to "Stop Recording"
if prog.json.TimerId <> invalid
if prog.json.isSeries = true
updateLabels("Record", "Cancel Series Recording")
else
updateLabels("Cancel Recording", "Record Series")
end if
else
updateLabels()
end if
m.detailsView.visible = "true"
m.noInfoView.visible = "false"
@ -240,6 +269,8 @@ sub focusChanged()
m.recordSeriesFocusAnimationOpacity.keyValue = [0, 1]
m.viewChannelButton.setFocus(true)
m.viewChannelOutline.visible = true
m.recordOutline.visible = false
m.recordSeriesOutline.visible = false
else
m.top.watchSelectedChannel = false
m.top.recordSelectedChannel = false

View File

@ -1,35 +1,53 @@
sub init()
m.top.functionName = "RecordProgram"
m.top.functionName = "RecordOrCancelProgram"
end sub
sub RecordProgram()
sub RecordOrCancelProgram()
' Get Live TV default params from server...
if m.top.programDetails <> invalid
programId = m.top.programDetails.Id
' Are we setting up a recording or canceling one?
TimerId = invalid
if m.top.programDetails.json.TimerId <> invalid and m.top.programDetails.json.TimerId <> ""
TimerId = m.top.programDetails.json.TimerId
end if
url = "LiveTv/Timers/Defaults"
params = {
programId: programId
}
resp = APIRequest(url, params)
data = getJson(resp)
if TimerId = invalid
' Setting up a recording...
programId = m.top.programDetails.Id
if data <> invalid
' Create recording timer...
if m.top.recordSeries = true
url = "LiveTv/SeriesTimers"
url = "LiveTv/Timers/Defaults"
params = {
programId: programId
}
resp = APIRequest(url, params)
data = getJson(resp)
if data <> invalid
' Create recording timer...
if m.top.recordSeries = true
url = "LiveTv/SeriesTimers"
else
url = "LiveTv/Timers"
end if
resp = APIRequest(url)
postJson(resp, FormatJson(data))
else
url = "LiveTv/Timers"
' Error msg to user?
print "Error getting Live TV Defaults from Server"
end if
else
' Cancelling a recording...
if m.top.recordSeries = true
TimerId = m.top.programDetails.json.SeriesTimerId
url = Substitute("LiveTv/SeriesTimers/{0}", TimerId)
else
url = Substitute("LiveTv/Timers/{0}", TimerId)
end if
resp = APIRequest(url)
postJson(resp, FormatJson(data))
m.top.timerCreated = true
else
' Error msg to user?
print "Error getting Live TV Defaults from Server"
m.top.timerCreated = false
deleteVoid(resp)
end if
end if
m.top.recordOperationDone = true
end sub

View File

@ -4,7 +4,7 @@
<interface>
<field id="programDetails" type="node" value="" />
<field id="recordSeries" type="boolean" value="false" />
<field id="timerCreated" type="boolean" value="" />
<field id="recordOperationDone" type="boolean" value="" />
</interface>
<script type="text/brightscript" uri="RecordProgramTask.brs" />
<script type="text/brightscript" uri="pkg:/source/api/baserequest.brs" />

View File

@ -194,7 +194,7 @@ sub onRecordChannelSelected()
m.RecordProgramTask = createObject("roSGNode", "RecordProgramTask")
m.RecordProgramTask.programDetails = m.detailsPane.programDetails
m.RecordProgramTask.recordSeries = false
m.RecordProgramTask.observeField("timerCreated", "onTimerCreated")
m.RecordProgramTask.observeField("recordOperationDone", "onRecordOperationDone")
m.RecordProgramTask.control = "RUN"
m.scheduleGrid.showLoadingDataFeedback = false
@ -212,11 +212,11 @@ sub onRecordSeriesChannelSelected()
m.RecordProgramTask = createObject("roSGNode", "RecordProgramTask")
m.RecordProgramTask.programDetails = m.detailsPane.programDetails
m.RecordProgramTask.recordSeries = true
m.RecordProgramTask.observeField("timerCreated", "onTimerCreated")
m.RecordProgramTask.observeField("recordOperationDone", "onRecordOperationDone")
m.RecordProgramTask.control = "RUN"
end sub
sub onTimerCreated()
sub onRecordOperationDone()
m.scheduleGrid.showLoadingDataFeedback = false
end sub

View File

@ -110,6 +110,15 @@ function postJson(req, data = "" as string)
return json
end function
function deleteVoid(req)
req.setMessagePort(CreateObject("roMessagePort"))
req.AddHeader("Content-Type", "application/json")
req.SetRequest("DELETE")
req.GetToString()
return true
end function
function get_url()
base = get_setting("server")
if base.right(1) = "/"