Two-way communication for audio

I am trying to get the following functions to work for playing back an mp3 in a web page: play, pause, and get playback position. I am using the audio tag in a WebHTMLViewer as follows (I named the component splashaudio):

me.LoadPage("

That works fine. Then, in a button Action I am trying to pause using this line:

ExecuteJavaScript(“Xojo.get(’”+splashaudio.ControlID+"’).pause();")

I don’t know how to refer to the splash id; nothing seems to work. I tried wading through the DOM and based on that I have tried a lot of different names but nothing works. I think I need event listeners. I read the tutorial “WebControlSDK.pdf” which helped but it isn’t specific enough to help out for this example.

Can someone just let me know if I am on the right track trying to put get and set events for the mp3 in the WebHTMLViewer?

You want something like this:
WebAudio Class for Web Edtion

Thanks for the suggestion. I did see that but I am trying to learn how to do this myself.

I think the audio player example gets me about halfway there. I am going to work through the two-way communication example today which should get me a little farther. One piece to the puzzle that I think I am missing is how to send the “pause()” or “play()” to the server. From the audio player example:

<audio id=“splash” controls=“controls” %autoplay%>

Your browser does not support the audio tag.

The example loads the audio but it doesn’t use the .pause() or play() commands (like this in regular Javascript: document.GetControlByID(“splash”).pause()).

From the WebSDK manual I know I need to do something similar to this in Xojo:

ExecuteJavascript(“Xojo.get(’” + Self.ControlID +"’).pause();")

When I do, I get the message “Invalid source” in the audio player window.

The documentation is awesome but I haven’t found what I am looking for (yet).

You can’t send to the server unless you use the WebControlSDK. (wich you have found)
I have the full source of the SWORT_WebAudio class as i’ve written it myself…:wink:

It shows how you use the WebControlSDK and communications from client to server.
If you want to do that you probably want to create a new control. Perhaps subclassing the WebControlWrapper (from WebControlSDK) helps you understand how it works.

The examples should be somewhere in your installation of xojo.
Use them to help you get to where you want. It helped me alot more then the PDF did. I like online docs more…:wink: