I have sound files in a postgres database, and my goal is to copy the sound file out of the database to a local file and then use the local file url with the webaudioplayer to play the sound. This has not been working. Not only can I not play the sound from the database, but I can’t play any local sound with the webaudioplayer. If I give the webaudioplayer the url of a remote web file, it works perfectly. If I copy that same file to my computer and use the local url, it will not play.
Any ideas of how I could get this work? Alternatively, is there a better way of doing this than trying to use the webaudioplayer? Any suggestions are very much appreciated.
I’m not sure what you mean about the browser not having access to a local file. A local file has a URL, such as “file:///C:/Users/Kevin/AppData/Roaming/writing-signature-3.mp3”. If I paste that file URL into a browser window, it plays the file. You’d think you could use something like that as the URL for the webaudioplayer, but it doesn’t work.
Kevin you are right the browser can load a local file when you copy/paste it in.
Unless you plan your app to execute on the user machine, the web app has it’s own local file system on the host where it executes. For all intents and purposes, what you call “local files” with a path such as “file:///C:/Users/Kevin/AppData/Roaming/writing-signature-3.mp3” is only valid while you run your app in debug mode on your PC. Once the app is uploaded to the host, that path is as alien to the web app as a path on the host would be to your PC.
The browser can play files you put in it’s URL box, or simply drop into it, because the browser is an application that executes on the PC.
If you put the files coming from the database onto the host file system, would that be in a subfolder of specialfolder.appsupport or specialfolder.temporary, then you got a local file you can pass to the WebMoviePlayer with a WebFile URL.
Thanks to Michel and Phillip for pointing me in the right direction. It is working now. Here is the code I have:
Dim fileStream As TextOutputStream
Dim f as folderitem = GetTemporaryFolderItem
If f <> Nil Then
fileStream = TextOutputStream.Create(f)
'tmpstring is the data of the audio file
If f.Exists Then
webpage1.audiofile = WebFile.Open(f)
'I put this in a webfile object of webpage1 because it is persistent