VLC intent always returns result code 0 - RESULT_CANCELED

三世轮回 提交于 2019-12-25 17:49:31

问题


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());
}    

回答1:


Replace

vlcIntent.setPackage("org.videolan.vlc");

with

vlcIntent.setComponent(new ComponentName("org.videolan.vlc", "org.videolan.vlc.gui.video.VideoPlayerActivity"));

This should give the result you are looking for.



来源:https://stackoverflow.com/questions/45426840/vlc-intent-always-returns-result-code-0-result-canceled

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!