**Subject**: Assistance Required with Posting Video Playback Position to Local Server
Hello BrightSign Support,
I am using an LS424 player with a Web Folder deployment for my presentation. Everything is set up on a local network.
**Objective**:
I have a looping video presentation that works perfectly. However, for content synchronization across multiple devices in our building (Phones and Tablets), I need the video's current playback position. I aim to send this position to a local ASP.NET Core website with an endpoint prepared to receive the data.
**Attempted Solution**:
- I tried leveraging BrightAuthor: Connected, but couldn't find a way to achieve this.
- I decided to modify the `autorun.brs` file post-publishing to the web folder, ensuring file hash accuracy, and making necessary updates to `pool` and `current-sync.json`.
- Within the code, I saved the reference to the `roVideoPlayer` and made several custom modifications to the Event Loop and introduced a `PostPosition` subroutine.
**Problem**:
The presentation still loads and the video plays after my changes, but the local server isn't receiving the expected messages.
**Code Snippets for Reference**:
In main sub, store global references:
Library "autoplugins.brs"
Sub Main()
autorunVersion$ = "10.0.98" 'Bacon in development
customAutorunVersion$ = "10.0.0"
' create global registry section to be used throughout script
globalAA = GetGlobalAA()
globalAA.registrySection = CreateObject("roRegistrySection", "networking")
' -----------------------------------
' Custom Video Playback Support
' -----------------------------------
globalAA.videoPlayer = invalid
localServerURL = "https://OurLocalWebsite.com/api/videoposition"
urlTransfer = CreateObject("roURLTransfer")
urlTransfer.SetURL(localServerURL)
globalAA.urlTransfer = urlTransfer
' -----------------------------------
Next, I found in the code where roVideoPlayer is created and save the reference like so:
videoPlayer = CreateObject("roVideoPlayer")
' -----------------------------------
' Custom Video Playback Support
' -----------------------------------
globalAA.videoPlayer = videoPlayer
' -----------------------------------
Then in the EventLoop, I added the following:
Sub EventLoop()
SQLITE_COMPLETE = 100
previousPositionInMillis = -1
' -----------------------------------
' Custom Video Playback Support
' -----------------------------------
globalAA = GetGlobalAA()
videoPlayer = globalAA.videoPlayer
urlTransfer = globalAA.urlTransfer
' -----------------------------------
while true
if videoPlayer = invalid then
videoPlayer = globalAA.videoPlayer
end if
msg = wait(0, m.msgPort)
m.diagnostics.PrintTimestamp()
m.diagnostics.PrintDebug("msg received - type=" + type(msg))
if type(msg) = "roControlDown" and stri(msg.GetSourceIdentity()) = stri(m.svcPort.GetIdentity()) then
if msg.GetInt() = 12 then
stop
end if
end if
eventHandled = false
' -----------------------------------
' Custom Video Playback Support
' -----------------------------------
if videoPlayer <> invalid then
positionInMillis = videoPlayer.GetPlaybackPosition()
if positionInMillis - previousPositionInMillis > 1000 then
m.diagnostics.PrintDebug("Post Position: " + positionInMillis.ToStr())
previousPositionInMillis = positionInMillis
positionInSeconds = positionInMillis / 1000
PostPosition(urlTransfer, positionInSeconds)
end if
end if
' -----------------------------------
Here is my post code:
' -----------------------------------
' Custom Video Playback Support
' -----------------------------------
' The following is called from the Event Loop
Sub PostPosition(urlTransfer, position As Integer)
postData = CreateObject("roAssociativeArray")
postData.AddReplace("id", 3) ' Special Exhibit ID
postData.AddReplace("position", position)
response = urlTransfer.AsyncPostFromString(postData.ToJsonString())
end sub
' -----------------------------------
**Request**:
Having invested significant effort, I believe I am close to a solution. Could you please review the steps and code snippets provided to identify any potential errors or missing elements?
Your assistance is much appreciated.
Warm Regards,
Bobby Ortiz