Forum Discussion
SetContentList is the function mentioned in the documentation, although I have tried SetContent. In terms of observing the state of the Video player, I can observe that it is buffering, playing, paused, etc. my problem is that I can't detect if its getting a 404 when trying to buffer a non-existent video.
Thank you for help btw
I don't know why your "state" observer isn't working. I tried setting the URL to a nonexistent video on my server and my server returned a 404, my "state" observer fired, GetData() returned "error". and my video node "errorCode" was set to 404.
Edit: "errorCode" is set to -1. "errorStr" shows the 404.
- Helaman2 years agoChannel Surfer
Is that for a `roVideoPlayer` object or a `roSGNode` that represents a Video SceneGraph element? I have a "state" observer on the `roSGNode` for my video element, but it doesn't fire with errors, it just fires for states like "buffering", "paused", "playing", etc.
- renojim2 years agoCommunity Streaming Expert
That's for a Video node. My "onState" observer function fires first with "buffering" and then with "error" when I set the URL to a nonexistent file. I've also used observers with message ports and waited on the port in the main thread. That looks something like this:
Function displayVideo(video as Object) as Integer print "Displaying video: "; video["url"] vn = m.video_node vc = createObject("roSGNode", "ContentNode") vc.url = video.url vc.StreamFormat = video.StreamFormat print vn.observeField("position", m.port) print vn.observeField("control", m.port) print vn.observeField("state", m.port) vn.content = vc vn.setFocus(true) vn.control = "play" while true msg = wait(0,m.port) msgtype = type(msg) print msgtype if msgtype = "roSGNodeEvent" then node = msg.GetNode() field = msg.GetField() data = msg.GetData() print node, field, data if field = "position" then position = data else if field = "control" and data = "stop" then exit while else if field = "state" then if data = "finished" then exit while else if data = "buffering" then m.video_screen.visible = true else if data = "error" then print vn.errorCode print vn.errorMsg print vn.errorStr print vn.errorInfo else if data = "playing" then ' else if data = "paused" then ' end if end if else if msgtype = "roSGScreenEvent" then print msgtype, msg.GetData(), msg.isScreenClosed() vn.control = "stop" exit while end if end while vn.control = "stop" print vn.unobserveField("position") print vn.unobserveField("control") print vn.unobserveField("state") return position End Function
and produces this output:roSGNodeEvent video control play roSGNodeEvent video state buffering roSGNodeEvent video state error errorCode: -1 errorMsg: There was an error in the HTTP response. This could mean that malformed HTTP headers or an HTTP error code was returned. errorStr: reader pick stream error:HTTP error:HTTP server returned error code:404:extra:etype:buffer errorInfo: <Component: roAssociativeArray> = { category: "http" clipid: 1 dbgmsg: "reader pick stream error:HTTP error:HTTP server returned error code:404:extra:etype:buffer" drmerrcode: 0 errcode: 2 ignored: false source: "buffer:reader" }
- Helaman2 years agoChannel Surfer
Wow, I didn't realize you could observe a field and then have it go to a port instead of a function... I still have a lot to learn about Roku app development π So that works if I give the player a non-existent video to begin with, but say (and this is the issue I'm trying to resolve) that the video exists originally and then gets deleted while it's being played. That's when I can't detect that it's getting an error, it just thinks it's buffering.
However, I did find a workaround; every time the player starts buffering, I send a GET request to the same url and look at the response and then act accordingly. That way I can tell if the video stopped existing during playback. Really weird issue, I know.
I still wish I could get the `roVideoPlayer` working though, because the documentation says that when given a list of videos a `roVideoPlayer` will automatically pre-buffer the next video to make playback of a bunch of videos seamless. That would help me a lot, instead of taking videos and concatenating them on the server and then returning the result to the device. (I'm trying to basically show a bunch of ~15 second videos in a row on a TV seamlessly, almost like a slideshow).
Anyways, thank you renojim SO much for helping out!