Hi,
I'm currently using the Recorderjs<https://github.com/mattdiamond/Recorderjs>
library
in my GWT project and have got the client side bits all working by writing
a wrapper class using JSNI to make the calls to the library.
I know want to retrieve the recorded audio and store it on the server. The
library has a method which can do this which required a callback to return
the result:
rec.getBuffer([callback])
I've created two JSNI methods to handle this, one to call getBuffer and
pass the callback method:
public native void StoreAudioJSNI() /*-{
var audiorec = this;
var storeAudioCallback = $entry(function(buffers) {
[email protected]::storeAudioCallback(Lcom/example/audiorecord/shared/MyJSObject;)(buffers);
});
$wnd.audioRecorder.getBuffer(storeAudioCallback);
}-*/;
and the callback method to be executed:
public native void storeAudioCallback(MyJSObject buffers) /*-{
[email protected]::StoreAudio(Lcom/example/audiorecord/shared/MyJSObject;)(buffers);
}-*/;
Both of these methods are in my main GWT class (the one with the same name
as my project containing onModuleLoad)
I want the callback method storeAudioCallback to call a Java method
StoreAudio which will pass the buffers object to the service by making an
RPC call:
public void StoreAudio(MyJSObject mjo) {
AsyncCallback<Void> callback = new AsyncCallback<Void>() {
public void onSuccess(Void result) {
// do some UI stuff to show success
}
public void onFailure(Throwable caught) {
// do some UI stuff to show failure
}
};
audioRecordService.StoreAudio(mjo, callback);
}
I then just have some buttons on the UI that record the audio and button
with a click event that calls the JSNI method StoreAudioJSNI()
The JSNI methods and callback methods work fine and the buffers is passed
all the way down to the final line of StoreAudio. However, when the RPC
call is made, the code in my AudioRecordSeriveImpl.StoreAudio class isn't
being hit (which stores the object into a HashMap on the server). It seems
that because of the JavaScript callback, something is being disconnected
and the RPC call doesn't get made after the JavaScript callback.
I made a seperate direct call to StoreAudio within the same click event by
passing null and this works fine so it only doesn't work in the following
flow: StoreAudioJSNI -> StoreAudioCallback -> StoreAudio.
I've also compared the value of audioRecordService when StoreAudio is
called directly compared to when it is called via the callback and the data
appears to be the same so not sure why the RPC call isn't being made after
the callback?
Hope someone can help, I've spent several hours trying to fix this.
Your help will be greatly appreciated!
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.