2017-09-06 2 views
1

J'ai du mal à appeler certaines méthodes d'une bibliothèque Java Android pour ffmpeg. Je pense que je la bibliothèque chargé succčs parce que je peux console.log l'objet bibliothèque:Comment implémenter des méthodes Java dans Nativescript?

JS: BuildConfig -> function() { [native code] } 
JS: ExecuteBinaryResponseHandler -> function() { [native code] } 
JS: FFmpeg -> function() { [native code] } 
JS: FFmpegExecuteResponseHandler -> function() { [native code] } 
JS: FFmpegLoadBinaryResponseHandler -> function() { [native code] } 
JS: LoadBinaryResponseHandler -> function() { [native code] } 

C'est de savoir jusqu'où je suis arrivé (using this nativescript guide):

// [...] 
 

 
var MyCustomLoadBinaryResponseHandler = 
 
com.github.hiteshsondhi88.libffmpeg 
 
.LoadBinaryResponseHandler.extend({ 
 
    onStart: function() { 
 
    console.log('Started loading ffmpeg'); 
 
    }, 
 
    onFailure: function() { 
 
    console.log('Failed loading ffmpeg'); 
 
    }, 
 
    onSuccess: function() { 
 
    console.log('Successfully loaded ffmpeg'); 
 
    }, 
 
    onFinish: function() { 
 
    console.log('Finished loading ffmpeg'); 
 
    } 
 
}); 
 

 
console.dir(MyCustomLoadBinaryResponseHandler); 
 
//^ this logs the following 
 
//~ JS: === dump(): dumping members === 
 
//~ JS: "()function() { [native code] }" 
 
//~ JS: === dump(): dumping function and properties names === 
 
//~ JS: extend() 
 
//~ JS: null() 
 
//~ JS: === dump(): finished === 
 

 
var context = app.android.context; 
 

 
var ffmpeg = 
 
com.github.hiteshsondhi88.libffmpeg.FFmpeg.getInstance(context); 
 

 
console.dir(ffmpeg); 
 
//^ this logs the following 
 
//~ JS: === dump(): dumping members === 
 
//~ JS: { 
 
//~ JS:  "constructor": "constructor()function() { [native code] 
 
//}" 
 
//~ JS: } 
 
//~ JS: === dump(): dumping function and properties names === 
 
//~ JS: constructor() 
 
//~ JS: concatenate() 
 
//~ JS: execute() 
 
//~ JS: getDeviceFFmpegVersion() 
 
//~ JS: getLibraryFFmpegVersion() 
 
//~ JS: isFFmpegCommandRunning() 
 
//~ JS: killRunningProcesses() 
 
//~ JS: loadBinary() 
 
//~ JS: setTimeout() 
 
//~ JS: <init>() 
 
//~ JS: clone() 
 
//~ JS: equals() 
 
//~ JS: finalize() 
 
//~ JS: getClass() 
 
//~ JS: hashCode() 
 
//~ JS: notify() 
 
//~ JS: notifyAll() 
 
//~ JS: toString() 
 
//~ JS: wait() 
 
//~ JS: === dump(): finished === 
 

 

 
ffmpeg.loadBinary(
 
    new MyCustomLoadBinaryResponseHandler() 
 
); 
 

 
var MyCustomExecuteBinaryResponseHandler = 
 
com.github.hiteshsondhi88.libffmpeg 
 
.ExecuteBinaryResponseHandler.extend({ 
 
    onStart: function() { 
 
    console.log('Started running ffmpeg'); 
 
    }, 
 
    onProgress: function(thisMessage) { 
 
    console.log(' ffmpeg running'); 
 
    console.log(thisMessage); 
 
    }, 
 
    onFailure: function(thisMessage) { 
 
    console.log('Failed running ffmpeg'); 
 
    console.log(thisMessage); 
 
    }, 
 
    onSuccess: function(thisMessage) { 
 
    console.log('Successfully run ffmpeg'); 
 
    console.log(thisMessage); 
 
    }, 
 
    onFinish: function() { 
 
    console.log('Finished running ffmpeg'); 
 
    } 
 
}); 
 

 
//this is where it crashes 
 
ffmpeg.execute('-version', new 
 
MyCustomExecuteBinaryResponseHandler());

Malheureusement, l'application entière se bloque sans message d'erreur l'application et je ne peux pas continuer ue sauf si j'ai plus d'informations sur ce qui se passe. Est-ce que je mets en œuvre les méthodes d'une manière incorrecte? Comment suggérez-vous que je continue?

edit: ce sont les derniers journaux sur la console

09-06 11:22:58.884 31522 31522 F art  : art/runtime/java_vm_ext.cc:470]  from java.lang.Object com.tns.Runtime.callJSMethodNative(int, int, java.lang.String, int, boolean, java.lang.Object[]) 
09-06 11:22:58.884 31522 31522 F art  : art/runtime/java_vm_ext.cc:470] at com.tns.Runtime.callJSMethodNative(Native method) 
09-06 11:22:58.884 31522 31522 F art  : art/runtime/java_vm_ext.cc:470] at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1043) 
09-06 11:22:58.884 31522 31522 F art  : art/runtime/java_vm_ext.cc:470] at com.tns.Runtime.callJSMethodImpl(Runtime.java:925) 
09-06 11:22:58.884 31522 31522 F art  : art/runtime/java_vm_ext.cc:470] at com.tns.Runtime.callJSMethod(Runtime.java:912) 
09-06 11:22:58.884 31522 31522 F art  : art/runtime/java_vm_ext.cc:470] at com.tns.Runtime.callJSMethod(Runtime.java:896) 
09-06 11:22:58.884 31522 31522 F art  : art/runtime/java_vm_ext.cc:470] at com.tns.Runtime.callJSMethod(Runtime.java:888) 
09-06 11:22:59.021 31522 31522 F art  : art/runtime/runtime.cc:403] at com.tns.Runtime.callJSMethodNative(Native method) 
09-06 11:22:59.021 31522 31522 F art  : art/runtime/runtime.cc:403] at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1043) 
09-06 11:22:59.021 31522 31522 F art  : art/runtime/runtime.cc:403] at com.tns.Runtime.callJSMethodImpl(Runtime.java:925) 
09-06 11:22:59.021 31522 31522 F art  : art/runtime/runtime.cc:403] at com.tns.Runtime.callJSMethod(Runtime.java:912) 
09-06 11:22:59.021 31522 31522 F art  : art/runtime/runtime.cc:403] at com.tns.Runtime.callJSMethod(Runtime.java:896) 
09-06 11:22:59.021 31522 31522 F art  : art/runtime/runtime.cc:403] at com.tns.Runtime.callJSMethod(Runtime.java:888) 
09-06 11:22:59.022 31522 31522 F art  : art/runtime/runtime.cc:403] at com.tns.Runtime.callJSMethodNative(Native method) 
09-06 11:22:59.022 31522 31522 F art  : art/runtime/runtime.cc:403] at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1043) 
09-06 11:22:59.022 31522 31522 F art  : art/runtime/runtime.cc:403] at com.tns.Runtime.callJSMethodImpl(Runtime.java:925) 
09-06 11:22:59.022 31522 31522 F art  : art/runtime/runtime.cc:403] at com.tns.Runtime.callJSMethod(Runtime.java:912) 
09-06 11:22:59.022 31522 31522 F art  : art/runtime/runtime.cc:403] at com.tns.Runtime.callJSMethod(Runtime.java:896) 
09-06 11:22:59.022 31522 31522 F art  : art/runtime/runtime.cc:403] at com.tns.Runtime.callJSMethod(Runtime.java:888) 
+0

JavaScript est pas Java – Acidic

+0

Si vous ne voyez pas une activité d'erreur, il est une exception JNI qui ne peut être retracé dans la BAD Logcat. Cependant, cela pourrait trouver de meilleures réponses dans les forums nativescript. De plus, partager un référentiel où le problème peut être reproduit serait idéal. – pkanev

+0

En fait, pour être précis, il y a des messages sur la console, des exceptions JNI peut-être comme vous l'avez suggéré? Je vais les inclure dans la question –

Répondre

0

Selon l'échantillon de dépôt GitHub https://github.com/WritingMinds/ffmpeg-android-java/blob/master/app/src/main/java/com/github/hiteshsondhi88/sampleffmpeg/Home.java#L80

la méthode execute accepte une collection de chaînes/tableau en tant que premier paramètre. Par conséquent, votre code devrait ressembler à:

ffmpeg.execute(['-version'], new MyCustomExecuteBinaryResponseHandler()); 
+1

En effet, c'était le problème! Le crash est parti après la construction et les gestionnaires journalisent les informations, ainsi que la sortie ffmpeg. Merci beaucoup! –