This code works fine and starts video playback as expected, but when backing out of VLC in our Cordova app, the correct requestCode (42) is returned, but resultCode is always 0 (RESULT_CANCELLED) and returned Intent is null. The same thing occurs if the video finishes playing and VLC exits on its own. According to the documentation, we should be getting RESULT_OK with a return Intent containing information such as extra_position (to get the video position upon exit).
Other Intents work fine, such as pick contact intent.
Tested on Android TV emulator, Nvidia Shield Tablet and an Android phone (Note 4). Tried VLC 2.0.6, latest Betas and nightly builds.
public void start(String uri, long position) {
int vlcRequestCode = 42;
Uri parsedUri = Uri.parse(uri);
Intent vlcIntent = new Intent(Intent.ACTION_VIEW);
vlcIntent.setPackage("org.videolan.vlc");
vlcIntent.setDataAndTypeAndNormalize(parsedUri, "video/*");
vlcIntent.putExtra("position", position);
this.cordova.startActivityForResult(this, vlcIntent, vlcRequestCode);
}
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
JSONObject json = new JSONObject();
json.put("requestCode", requestCode);
json.put("resultCode", resultCode);
json.put("intentIsNull", intent == null);
this.callbackContext.success(json.toString());
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…