Begin tracking play state
This commit is contained in:
parent
c088ce14ac
commit
18ccd45998
|
@ -24,6 +24,8 @@ function buildURL(path as String, params={} as Object) as string
|
|||
else if type(field.value) = "roInteger" then
|
||||
item = field.key + "=" + req.escape(str(field.value).trim())
|
||||
'item = field.key + "=" + str(field.value).trim()
|
||||
else if type(field.value) = "roFloat" then
|
||||
item = field.key + "=" + req.escape(str(field.value).trim())
|
||||
else if field <> invalid
|
||||
item = field.key + "=" + req.escape(field.value)
|
||||
'item = field.key + "=" + field.value
|
||||
|
|
|
@ -424,16 +424,22 @@ sub showVideoPlayer(video_id)
|
|||
while true
|
||||
msg = wait(0, port)
|
||||
if type(msg) = "roSGScreenEvent" and msg.isScreenClosed() then
|
||||
if video = invalid then return
|
||||
|
||||
progress = int( video.position / video.duration * 100)
|
||||
if progress > 95 ' TODO - max resume percentage
|
||||
MarkItemWatched(video_id)
|
||||
end if
|
||||
' TODO - report progress here
|
||||
ticks = video.position * 10000000
|
||||
ItemSessionStop(video_id, {"PositionTicks": ticks})
|
||||
return
|
||||
else if nodeEventQ(msg, "state")
|
||||
state = msg.getData()
|
||||
if state = "stopped" or state = "finished"
|
||||
screen.close()
|
||||
else if state = "playing"
|
||||
ticks = video.position * 10000000
|
||||
ItemSessionStart(video_id, {"PositionTicks": ticks})
|
||||
end if
|
||||
end if
|
||||
end while
|
||||
|
|
20
source/api_sessions.brs
Normal file
20
source/api_sessions.brs
Normal file
|
@ -0,0 +1,20 @@
|
|||
function ItemSessionUpdate(id as String, params={})
|
||||
url = "Sessions/Playing/Progress"
|
||||
params.ItemId = id
|
||||
resp = APIRequest(url, params)
|
||||
return postJson(resp)
|
||||
end function
|
||||
|
||||
function ItemSessionStart(id as String, params={})
|
||||
url = "Sessions/Playing"
|
||||
params.ItemId = id
|
||||
resp = APIRequest(url, params)
|
||||
return postJson(resp)
|
||||
end function
|
||||
|
||||
function ItemSessionStop(id as String, params={})
|
||||
url = "Sessions/Playing/Stopped"
|
||||
params.ItemId = id
|
||||
resp = APIRequest(url, params)
|
||||
return postJson(resp)
|
||||
end function
|
Loading…
Reference in New Issue
Block a user