I am creating a GWT client application which interacts with a server and I am getting a开发者_JAVA技巧ll my response data from the server in JSON format.
Amongst others there are wave data on the server's database which I would like to retrieve and then playback on the client. I am able to get the wave data as an array of bytes in the JSON format.
My problem is, how do I playback the wave array data in a browser? Is it even possible or do I have to find another solution?
I've searched the web and found some GWT packages which are able to playback sound, but they are all playing back directly from an url.
Have you looked at HTML5 <audio>
tags with the data URI scheme? For example:
<audio src="data:audio/wav;base64,[base64 encoded data]"></audio>
There are downsides to doing this, including:
- Not all browsers support the new HTML5
<audio>
tag at all - Browsers can limit the size of data URI's (see the linked SO question)
As an alternative solution, if you can generate the audio data on the server you can of course point your the solutions you've already found to a URL that activates a servlet that generates the audio data.
精彩评论