Thanks for your reply. The URL works and sends me the playlist, though it works only inside of my VLAN. I am absolutely positive the link is OK.
Here is my code:
Function SCVideoPlayer(sessionid, media as object,toRestart = false)
tokenResponse = ParseJson(apiCallToken(GetGlobalAA().username,GetGlobalAA().password,sessionid,media.id))
this = {
port: CreateObject("roMessagePort")
progress: 0 'buffering progress
position: 0 'playback position (in seconds)
paused: false 'is the video currently paused?
fonts: CreateObject("roFontRegistry") 'global font registry
fontSize: 0
canvas: CreateObject("roImageCanvas") 'user interface
player: CreateObject("roVideoPlayer")
setup: SetupFullscreenCanvas
paint: PaintFullscreenCanvas
eventloop: EventLoop
mediaid: media
rectangles: CreateObject("roAssociativeArray")
watermark:""
timer: CreateObject("roTimespan")
currentTime: 0
pauseTimer:CreateObject("roTimespan")
pauseTimeout:45
streamClosed:false
isStreamStarted:false
tokenRetryCounter:3
isInterrupted:false
clientTimeoutTimer:CreateObject("roTimespan")
currentTime:0
loadingDialog:CreateObject("roOneLineDialog")
request: apiHeartbeat(GetGlobalAA().username,GetGlobalAA().password)
}
this.canvas.SetMessagePort(this.port)
this.canvas.SetLayer(1, { Color: "#000000",CompositionMode: "Source" })
this.canvas.SetRequireAllImagesToDraw(false)
this.canvas.Show()
this.layout = {
full: this.canvas.GetCanvasRect()
top: { x: 0, y: 0, w: 720, h: 80 }
left: { x: 100, y: 100, w: 280, h: 210 }
right: { x: 400, y: 100, w: 220, h: 210 }
bottom: { x: 100, y: 340, w: 520, h: 140 }
foo:{x:Rnd(300), y:Rnd(300), w:100,h:200}
}
this.fontSize = int(this.canvas.GetCanvasRect().h*(this.mediaid.spoilSizePercent/100))
this.background = "pkg:/images/back-sd.jpg"
this.headerfont = this.fonts.get("lmroman10 caps", 30, 50, false)
this.player.SetMessagePort(this.port)
this.player.setCGMS(3)
this.player.SetLoop(false)
this.player.SetPositionNotificationPeriod(1)
this.player.SetDestinationRect(this.canvas.GetCanvasRect())
this.player.SetCertificatesFile("common:/certs/ca-bundle.crt")
this.player.InitClientCertificates()
this.player.SetCertificatesDepth(8)
targetRectSeekBar = CreateObject("roAssociativeArray")
targetRectSeekBar.w = int(this.canvas.GetCanvasRect().w/2)
targetRectSeekBar.h = 35
targetRectSeekBar.x = int((this.canvas.GetCanvasRect().w/2) - int(targetRectSeekBar.w/2))
targetRectSeekBar.y = int(this.canvas.GetCanvasRect().h - (targetRectSeekBar.h + 73))
playBackStringRect = CreateObject("roAssociativeArray")
playBackStringRect.y = this.canvas.GetCanvasRect().h - (targetRectSeekBar.h + 80)
remainingPlayStringRect = CreateObject("roAssociativeArray")
remainingPlayStringRect.y = playBackStringRect.y
this.rectangles = {
targetRectSeekBar: targetRectSeekBar
playBackStringRect:playBackStringRect
remainingPlayStringRect: remainingPlayStringRect
}
streamUrl = ""
if tokenResponse <> invalid
token = tokenResponse.token
streamHost = tokenResponse.url
session = Stri(sessionid).trim()
mediaid = Stri(media.id).trim()
tokenid = token
if session <> invalid and mediaid <> invalid and tokenid <> invalid
'r = CreateObject("roRegex", mediaid, "")
'mediaidS = GetGlobalAA().iosStreaming + mediaid
'streamHost = r.ReplaceAll(streamHost, mediaidS)
streamUrl = streamHost
print "streamHost: "; streamHost
print "mediaid: "; mediaid
print "session: "; session
print "streamUrl: "streamUrl
end if
end if
playbackTime = int(media.playbackTime)
if toRestart
playbackTime = 0
end if
this.player.SetContentList([CreateVideoContent(streamUrl,playbackTime)])
this.player.Play()
end Function
function CreateVideoContent(streamUrl,playbackTime)
bitrates =[128,384,882,1384,1500,1800]
print "----- Stream URL on CreateVideoContent: "streamUrl
content = {
Stream: { url: streamUrl, format: "hls" },
qualities:["HD"]
StreamFormat: "hls",
StreamBitrates:bitrates,
PlayStart:playbackTime,
SwitchingStrategy:"minimum-adaptation",
minBandWidth:64,
Live:true,
}
return content
end function
function SetupFullscreenCanvas()
m.canvas.AllowUpdates(false)
m.paint()
m.canvas.AllowUpdates(true)
End function
' -----+----- not sure if you need this -----+-----
Function EventLoop()
while true
msg = wait(GetGlobalAA().eventLoopTimeOut, m.port)
heartBeatSecs = m.timer.totalSeconds()
toSync = heartBeatSecs >= m.currentTime + GetGlobalAA().heartBeatRequest
if toSync
m.request.AsyncGetToString()
m.timer.mark()
m.currentTime = m.timer.totalSeconds()
end if
timeOut = m.clientTimeoutTimer.totalSeconds() >= GetGlobalAA().clientTimeoutSecs
timedOutCheck = GetGlobalAA().clientTimeoutSecs + GetGlobalAA().clientExitTimeout
if m.paused
print "This is videoplayer's Paused state"
if m.clientTimeoutTimer.totalSeconds() >= timedOutCheck
return "closeApp"
exit while
end if
if timeOut
m.clientTimeoutDialog = CreateObject("roMessageDialog")
m.clientTimeoutDialog.SetMessagePort(m.port)
m.clientTimeoutDialog.SetTitle(GetGlobalAA().DialogMsg.inactiveWarningMessage)
m.clientTimeoutDialog.addButton(1, "Yes")
m.clientTimeoutDialog.addButton(2, "No")
m.clientTimeoutDialog.EnableOverlay(true)
m.clientTimeoutDialog.show()
end if
else
m.clientTimeoutTimer.mark()
end if
if msg <> invalid
'dialog = CreateObject("roOneLineDialog")
'port = CreateObject("roMessagePort")
'dialog.SetTitle("Preparing video")
'dialog.ShowBusyAnimation()
'dialog.Show()
print "This is videoplayer's play state"
'If this is a startup progress status message, record progress
'and update the UI accordingly:
if type(msg) = "roMessageDialogEvent"
if msg.isButtonPressed()
if msg.getIndex() = 1
m.clientTimeoutTimer.mark()
m.clientTimeoutDialog.close()
else if msg.getIndex() = 2
return "closeApp"
exit while
end if
end if
end if
if type(msg) = "roUrlEvent"
'print "Response header failure" + msg.getFailureReason()
print "Response form server" + msg.getString()
print "Reponse header code" + Stri(msg.getResponseCode())
end if
'this will process video player events'
if type(msg) = "roVideoPlayerEvent"
if msg.isStatusMessage() and msg.GetMessage() = "startup progress"
m.paused = false
progress% = msg.GetIndex() / 10
if m.progress <> progress%
m.progress = progress%
m.paint()
end if
'Playback progress (in seconds):
else if msg.isStreamStarted()
m.isStreamStarted = true
m.isInterrupted = false
m.loadingDialog.close()
print "stream has started"
else if msg.isPartialResult()
print "partial result"
token = ""
successPlayback = false
'while m.tokenRetryCounter <> 0
tokenResponse = ParseJson(apiCallToken(GetGlobalAA().username,GetGlobalAA().password,GetGlobalAA().sessionid,m.mediaid.id))
print "tokenResponse: " + tokenResponse
if tokenResponse <> invalid
token = tokenResponse.token
streamHost = tokenResponse.url
session = Stri(GetGlobalAA().sessionid).trim()
mediaid = Stri(m.mediaid.id).trim() 'GetGlobalAA().iosStreaming
tokenid = token
streamUrl = streamHost+ "/" + mediaid + "/playlist.m3u8?sessionId=" + session+"&objectId="+ mediaid + "&token=" + tokenid
streamUrl = tokenResponse.url
'print "streamHost: "; streamHost
'print "mediaid: "; mediaid
'print "session: "; session
print "now got here 1"
m.player.SetContentList([CreateVideoContent(streamUrl,m.position)])
m.player.SetMessagePort(m.port)
m.player.play()
'm.player.show()
'exit while
end if
'else
' sleep(5000)
'' m.tokenRetryCounter = m.tokenRetryCounter - 1
'end if
'end while
print Stri(m.tokenRetryCounter)
if m.tokenRetryCounter = 0
displayErrorPlayBackDialog(GetGlobalAA().DialogMsg.watchExpiredHeader,GetGlobalAA().DialogMsg.watchExpired)
m.canvas.close()
exit while
end if
else if msg.isRequestFailed()
print "playback request failed"
token = ""
successPlayback = false
'while m.tokenRetryCounter <> 0
tokenResponse = ParseJson(apiCallToken(GetGlobalAA().username,GetGlobalAA().password,GetGlobalAA().sessionid,m.mediaid.id))
retries = 3
while retries <> 0
tokenResponse = ParseJson(apiCallToken(GetGlobalAA().username,GetGlobalAA().password,GetGlobalAA().sessionid,m.mediaid.id))
retries = retries - 1
if tokenResponse <> invalid
exit while
end if
end while
if tokenResponse <> invalid
'dialog = CreateObject("roOneLineDialog")
'port = CreateObject("roMessagePort")
'dialog.SetTitle("Restarting video")
'dialog.ShowBusyAnimation()
'dialog.Show()
token = tokenResponse.token
streamHost = tokenResponse.url
session = Stri(GetGlobalAA().sessionid).trim()
mediaid = Stri(m.mediaid.id).trim()
tokenid = token
streamUrl = ""
if session <> invalid and mediaid <> invalid and tokenid <> invalid
streamUrl = streamHost '+ "/" + mediaid + "/playlist.m3u8?sessionId=" + session+"&objectId="+ mediaid + "&token=" + tokenid
end if
print "restarting playback" + streamUrl
print "now got here 2"
m.player.SetContentList([CreateVideoContent(streamUrl,m.position)])
streamUrl = tokenResponse.url
m.player.SetMessagePort(m.port)
m.player.play()
m.isInterrupted = true
m.loadingDialog.SetTitle("Something went wrong...")
m.loadingDialog.ShowBusyAnimation()
m.loadingDialog.show()
'm.player.show()
'exit while
'dialog.close()
else
displayErrorPlayBackDialog(GetGlobalAA().DialogMsg.watchExpiredHeader,GetGlobalAA().DialogMsg.watchExpired)
m.canvas.close()
exit while
end if
'else
' sleep(5000)
'' m.tokenRetryCounter = m.tokenRetryCounter - 1
'end if
'end while
m.tokenRetryCounter = m.tokenRetryCounter - 1
print "Retry counter: " Stri(m.tokenRetryCounter)
if m.tokenRetryCounter = 0
displayErrorPlayBackDialog(GetGlobalAA().DialogMsg.watchExpiredHeader,GetGlobalAA().DialogMsg.watchExpired)
m.canvas.close()
exit while
end if
else if msg.isPlaybackPosition()
m.position = msg.GetIndex()
m.tokenRetryCounter = 3
m.paint()
else if msg.isFullResult()
print "is full result"
if m.isInterrupted = false
m.player.stop()
closeStream(m.mediaid.id,m.position)
m.canvas.close()
exit while
end if
else if msg.isPaused()
if m.paused <> true
m.paused = true
m.pauseTimer.mark()
end if
displaySeekBar(m)
else if msg.isResumed()
if m.streamClosed
m.loadingDialog = CreateObject("roOneLineDialog")
m.loadingDialog.SetTitle("Resuming")
m.loadingDialog.ShowBusyAnimation()
m.loadingDialog.Show()
tokenResponse = ParseJson(apiCallToken(GetGlobalAA().username,GetGlobalAA().password,GetGlobalAA().sessionid,m.mediaid.id))
token = ""
token = tokenResponse.token
streamHost = tokenResponse.url
session = Stri(GetGlobalAA().sessionid).trim()
mediaid = Stri(m.mediaid.id).trim()
tokenid = token
streamUrl = streamHost+ "/" + mediaid + "/playlist.m3u8?sessionId=" + session+"&objectId="+ mediaid + "&token=" + tokenid
print "restarting playback" + streamUrl
print "now got here 3"
'm.player.ClearContent(
m.player.SetContentList([CreateVideoContent(streamUrl,m.position)])
streamUrl = tokenResponse.url
m.player.play()
m.streamClosed = false
'm.player.show()
end if
m.paused = false
color = "#00000000"
m.canvas.SetLayer(1,{ Color: color, CompositionMode: "Source" })
m.canvas.ClearLayer(3)
end if
'Output events for debug
print "Message type, index, message"msg.GetType(); ","; msg.GetIndex(); ": "; msg.GetMessage()
'print "message content: "msg.GetInfo()
if msg.GetInfo() <> invalid print "If not invalid this is message "msg.GetInfo();
end if
'this will process Image Canvas Events '
if type(msg) = "roImageCanvasEvent"
if msg.isRemoteKeyPressed()
index = msg.GetIndex()
print "Remote button pressed: " + index.tostr()
if msg.GetIndex() = 0
m.player.stop()
m.mediaid.playbackTime = m.position
closeStream(m.mediaid.id,m.position)
m.canvas.close()
exit while
else if msg.GetIndex() = 13
if m.paused
if m.isrewind
m.player.Seek(m.position * 1000)
m.isrewind = false
else if m.isfastword
m.player.Seek(m.position * 1000)
m.isfastword = false
else
end if
m.player.Resume()
'm.paint()
else
m.isrewind = false
m.isfastword = false
m.player.Pause()
'm.paint()
end if
else if index = 4 or index = 8 '<LEFT> or <REV>
m.isRewind = true
m.isfastword = false
m.position = m.position - 10
if m.position <= 0
m.position = 0
end if
if Not m.paused
m.player.Pause()
m.paused = true
end if
displaySeekBar(m)
else if index = 5 or index = 9 '<RIGHT> or <FWD>
m.isrewind = false
m.isfastword = true
m.position = m.position + 10
if m.position >= m.player.getPlaybackDuration()
m.position = m.player.getPlaybackDuration()
end if
if Not m.paused
m.player.Pause()
m.paused = true
end if
displaySeekBar(m)
end if
end if
end if 'if type(msg) = "roImageCanvasEvent"'
'dialog.close()
end if 'if msg <> invalid'
if m.paused and m.streamClosed = false
toClose = m.pauseTimer.totalSeconds() >= m.pauseTimeout
if toClose
closeStream(m.mediaid.id,m.position)
m.streamClosed = true
end if
end if 'paused check'
'dialog.close()
end while
end function
Here is a debug for the https:
starting videoplayer 61237 with session 28413732
streamHost: https://onlinestg.com:1988/streaming/114563/playlist.m3u8
mediaid: 114563
session: 28413732
streamUrl: https://onlinestg.com:1988/streaming/114563/playlist.m3u8
----- Stream URL on CreateVideoContent: https://onlinestg.com:1988/streaming/114563/playlist.m3u8
Painting canvas
Painting canvas
This is videoplayer's play state
Message type, index, message 11, 0: startup progress
This is videoplayer's play state
Painting canvas
Message type, index, message 11, 66: startup progress
This is videoplayer's play state
Painting canvas
Message type, index, message 11, 132: startup progress
This is videoplayer's play state
Message type, index, message 11, 0: ConnectionContext failure
This is videoplayer's play state
Painting canvas
Message type, index, message 11, 198: startup progress
This is videoplayer's play state
Message type, index, message 11, 0: Unspecified or invalid track path/url.
This is videoplayer's play state
playback request failed
restarting playback https://onlinestg.com:1988/streaming/114563/playlist.m3u8
now got here 2
----- Stream URL on CreateVideoContent: https://onlinestg.com:1988/streaming/114563/playlist.m3u8
Retry counter: 2
Message type, index, message 9,-5:
If not invalid this is message MediaFormat: <Component: roAssociativeArray>
This is videoplayer's play state
is full result
Message type, index, message 16, 0: Playback completed.
This is videoplayer's play state
Message type, index, message 11, 0: end of playlist
This is videoplayer's play state
playback request failed
restarting playback https://onlinestg.com:1988/streaming/114563/playlist.m3u8
now got here 2
----- Stream URL on CreateVideoContent: https://onlinestg.com:1988/streaming/114563/playlist.m3u8
Retry counter: 1
Message type, index, message 9,-5: The format is not supported or the media is corrupt.
This is videoplayer's play state
is full result
Message type, index, message 16, 0: Playback completed.
This is videoplayer's play state
Message type, index, message 11, 0: end of playlist
This is videoplayer's play state
Painting canvas
Message type, index, message 11, 0: startup progress
This is videoplayer's play state
Painting canvas
Message type, index, message 11, 66: startup progress
This is videoplayer's play state
Painting canvas
Message type, index, message 11, 132: startup progress
This is videoplayer's play state
Painting canvas
Message type, index, message 11, 198: startup progress
This is videoplayer's play state
Painting canvas
Message type, index, message 11, 0: startup progress
This is videoplayer's play state
Painting canvas
Message type, index, message 11, 66: startup progress
This is videoplayer's play state
Painting canvas
Message type, index, message 11, 132: startup progress
This is videoplayer's play state
Message type, index, message 11, 0: ConnectionContext failure
This is videoplayer's play state
Painting canvas
Message type, index, message 11, 198: startup progress
This is videoplayer's play state
Message type, index, message 11, 0: Unspecified or invalid track path/url.
This is videoplayer's play state
playback request failed
restarting playback https://onlinestg.com:1988/streaming/114563/playlist.m3u8
now got here 2
----- Stream URL on CreateVideoContent: https://onlinestg.com:1988/streaming/114563/playlist.m3u8
Retry counter: 0
and an http debug (which is working)
----- Stream URL on CreateVideoContent: http://onlinestg.com:8080/streaming/114563/playlist.m3u8
Painting canvas
Painting canvas
This is videoplayer's play state
Message type, index, message 11, 0: startup progress
message content: invalid
This is videoplayer's play state
Painting canvas
Message type, index, message 11, 66: startup progress
message content: invalid
This is videoplayer's play state
Painting canvas
Message type, index, message 11, 132: startup progress
message content: invalid
This is videoplayer's play state
Painting canvas
Message type, index, message 11, 198: startup progress
message content: invalid
This is videoplayer's play state
Message type, index, message 0, 0:
message content: invalid
This is videoplayer's play state
Painting canvas
Message type, index, message 11, 264: startup progress
message content: invalid
This is videoplayer's play state
Painting canvas
Message type, index, message 11, 330: startup progress
message content: invalid
This is videoplayer's play state
stream has started
Message type, index, message 20, 2: Stream started.
message content: StreamBitrate: 0
MeasuredBitrate: 8145
Url: http://onlinestg.com:8080/streaming/114563/playlist.m3u8
IsUnderrun: false
If not invalid this is message StreamBitrate: 0
MeasuredBitrate: 8145
Url: http://onlinestg.com:8080/streaming/114563/playlist.m3u8
IsUnderrun: false
This is videoplayer's play state
Message type, index, message 11, 330: startup progress
message content: invalid
This is videoplayer's play state
Message type, index, message 37, 0: Segment download started
message content: Sequence: 0
SegBitrate: 3798410
StartTime: 0
EndTime: 10113
If not invalid this is message Sequence: 0
SegBitrate: 3798410
StartTime: 0
EndTime: 10113
This is videoplayer's play state
Message type, index, message 31, 0: Download segment info
message content: Bitrate: 3798410
Sequence: 0
Status: 0
SegBitrate: 3798
DownloadDuration: 0
SegUrl: http://onlinestg.com:8080/streaming/114563/playlist.m3u8
SegSize: 4785552
BufferSize: 0
BufferLevel: 0
SegType: 0
IPAddress:
If not invalid this is message Bitrate: 3798410
Sequence: 0
Status: 0
SegBitrate: 3798
DownloadDuration: 0
SegUrl: http://onlinestg.com:8080/streaming/114563/playlist.m3u8
SegSize: 4785552
BufferSize: 0
BufferLevel: 0
SegType: 0
IPAddress:
This is videoplayer's play state
Message type, index, message 31, 0: Download segment info
message content: Bitrate: 3798410
Sequence: 0
Status: 0
SegBitrate: 3798
DownloadDuration: 4099
SegUrl: http://onlinestg.com:8080/streaming/114563/playlist.m3u8
SegSize: 4785552
BufferSize: 62914560
BufferLevel: 4785552
SegType: 0
IPAddress:
If not invalid this is message Bitrate: 3798410
Sequence: 0
Status: 0
SegBitrate: 3798
DownloadDuration: 4099
SegUrl: http://onlinestg.com:8080/streaming/114563/playlist.m3u8
SegSize: 4785552
BufferSize: 62914560
BufferLevel: 4785552
SegType: 0
IPAddress:
This is videoplayer's play state
Message type, index, message 37, 0: Segment download started
message content: Sequence: 1
SegBitrate: 3798410
StartTime: 10113
EndTime: 21160
If not invalid this is message Sequence: 1
SegBitrate: 3798410
StartTime: 10113
EndTime: 21160
This is videoplayer's play state
Message type, index, message 31, 1: Download segment info
message content: Bitrate: 3798410
Sequence: 1
Status: 0
SegBitrate: 3798
DownloadDuration: 0
SegUrl: http://onlinestg.com:8080/streaming/114563/playlist.m3u8
SegSize: 3706800
BufferSize: 0
BufferLevel: 0
SegType: 0
IPAddress:
If not invalid this is message Bitrate: 3798410
Sequence: 1
Status: 0
SegBitrate: 3798
DownloadDuration: 0
SegUrl: http://onlinestg.com:8080/streaming/114563/playlist.m3u8
SegSize: 3706800
BufferSize: 0
BufferLevel: 0
SegType: 0
IPAddress:
This is videoplayer's play state
Message type, index, message 31, 1: Download segment info
message content: Bitrate: 3798410
Sequence: 1
Status: 0
SegBitrate: 3798
DownloadDuration: 3404
SegUrl: http://onlinestg.com:8080/streaming/114563/playlist.m3u8
SegSize: 3706800
BufferSize: 62914560
BufferLevel: 8492352
SegType: 0
IPAddress:
If not invalid this is message Bitrate: 3798410
Sequence: 1
Status: 0
SegBitrate: 3798
DownloadDuration: 3404
SegUrl: http://onlinestg.com:8080/streaming/114563/playlist.m3u8
SegSize: 3706800
BufferSize: 62914560
BufferLevel: 8492352
SegType: 0
IPAddress:
This is videoplayer's play state
Message type, index, message 33, 1:
message content: invalid
This is videoplayer's play state
Message type, index, message 37, 0: Segment download started
message content: Sequence: 2
SegBitrate: 3798410
StartTime: 21160
EndTime: 22101
If not invalid this is message Sequence: 2
SegBitrate: 3798410
StartTime: 21160
EndTime: 22101
This is videoplayer's play state
Painting canvas
Message type, index, message 11, 999: startup progress
message content: invalid
This is videoplayer's play state
Message type, index, message 11, 999: startup progress
message content: invalid
This is videoplayer's play state
Message type, index, message 31, 2: Download segment info
message content: Bitrate: 3798410
Sequence: 2
Status: 0
SegBitrate: 3798
DownloadDuration: 0
SegUrl: http://onlinestg.com:8080/streaming/114563/playlist.m3u8
SegSize: 90064
BufferSize: 0
BufferLevel: 0
SegType: 0
IPAddress:
If not invalid this is message Bitrate: 3798410
Sequence: 2
Status: 0
SegBitrate: 3798
DownloadDuration: 0
SegUrl: http://onlinestg.com:8080/streaming/114563/playlist.m3u8
SegSize: 90064
BufferSize: 0
BufferLevel: 0
SegType: 0
IPAddress:
This is videoplayer's play state
Message type, index, message 31, 2: Download segment info
message content: Bitrate: 3798410
Sequence: 2
Status: 0
SegBitrate: 3798
DownloadDuration: 167
SegUrl: http://onlinestg.com:8080/streaming/114563/playlist.m3u8
SegSize: 90064
BufferSize: 62914560
BufferLevel: 8582416
SegType: 0
IPAddress:
If not invalid this is message Bitrate: 3798410
Sequence: 2
Status: 0
SegBitrate: 3798
DownloadDuration: 167
SegUrl: http://onlinestg.com:8080/streaming/114563/playlist.m3u8
SegSize: 90064
BufferSize: 62914560
BufferLevel: 8582416
SegType: 0
IPAddress:
...
Highly appreciate your help,
Gary