Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
171 views
in Technique[技术] by (71.8m points)

javascript - VLC intent always returns result code 0 - RESULT_CANCELED

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...