WebMoviePlayer Seek

I am trying to build WEB APP which has WebMoviePlayer in Xojo 2018r3.

Regular play is working normally, but when I try to seek position in MoviePlayer, nothing happens, except when I seek on first frame.

Inside App folder, I am creating symbolic links which are targeting location of video files, so I can use them in my App. I am creating url like http://127.0.0.1:8080/music/attention.mp4

Since I have 2 locations where files could be placed, this is my HandleURL code:

// Call our static content handler. Each top level folder will require it's own handler.
If (App.HandleStaticContent(Request, App.ExecutableFile.Parent.Child("mediaProxy"), "video/mp4") = True) Then
  // We overrode the default MIMEType because all files in "static1" are PDF's. This gives the browser additional context like opening the PDF inside the browser window.
  Return True
else
  If (App.HandleStaticContent(Request, App.ExecutableFile.Parent.Child("media"), "video/mp4") = True) Then
    Return True
  End If
End If

And this is HandleStaticContent method

// Verify we have a valid path so as not to catch blank GET requests.
If (Request.Path = "") Then
  Return False
End If

// Determine if we have a file that matches this path.
Dim _filePath As String
_filePath = Request.Path
#If TargetWindows = True Then
  _filePath = _filePath.ReplaceAll("/", "\")
#EndIf

Dim _folderPath As String
_folderPath = Folder.NativePath
#If TargetWindows = True Then
  _folderPath = _folderPath + "\"
#ElseIf TargetLinux = True Or TargetMacOS = True Then
  _folderPath = _folderPath + "/"
#EndIf

dim f as FolderItem = GetFolderItem(_folderPath)
if f <> Nil then
  dim folPath As String
  folPath = f.URLPath
  dim fullPath as String = folPath + _filePath
  f = GetFolderItem(folPath + _filePath, FolderItem.PathTypeURL)
end if



Dim _fullPath As String
_fullPath = _folderPath + _filePath

Dim _fileInFolder As FolderItem
_fileInFolder = GetFolderItem(_folderPath + _filePath, FolderItem.PathTypeNative)

If  f = Nil Then
  Return False
End If

If f.Exists = false Then
  Return False
End If

// We got this far which means there is a file that matches this request path. Let's set the request MIME type.
If (_fileInFolder.Name.Lowercase().Right(4) = ".css") Then
  Request.MIMEType = "text/css"
Else
  Request.MIMEType = MIMEType
End If

// We should also update the status code because some browsers are picky about this.
Request.Status = 200 // HTTP OK

// Read the file contents and append to the request.
Dim _fileStream As BinaryStream
_fileStream = BinaryStream.Open(f)

Request.Print(_fileStream.Read(_fileStream.Length))

// Return True so Xojo Web sends the file down to the browser.
Return True

If I try to play same file, but from different location (from our website), seek is working normally.

Are there any settings in Xojo, or I’m missing something in this case?

Thank you.

Your other web server is probably capable of serving partial files and handling the things that go on when skipping to the middle of a streaming video.

Xojo Web is a pretty basic web server, and it wouldn’t surprise me if this is just not within it’s capabilities. Xojo Staff have always recommended to serve large files – and honestly any static files that you can – from outside the Xojo Web application.

For this reason, Lifeboat makes it super easy to set up serving Static Files (like videos and normal websites) for your Xojo Web apps using the same server.

5 Likes

Can this also be done from a local (lan) machine for a lan network that runs nginx or such ? With lifeboat?

My theory is that it’s the webserver not able to stream a partial file, so I would expect that nginx would help with the issue even on a local network. Lifeboat works great with a Raspberry Pi :slight_smile:

1 Like

Thanks for idea. I am working on Windows, and I did it with nginx which is serving files to XOJO. For now, seeking works great. :slight_smile: