VLC意向始终返回结果代码0-RESULT_CANCELED [英] VLC intent always returns result code 0 - RESULT_CANCELED

查看:114
本文介绍了VLC意向始终返回结果代码0-RESULT_CANCELED的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此代码可以正常工作,并按预期方式开始视频播放,但是在我们的Cordova应用程序中退出VLC时,返回正确的requestCode(42),但resultCode始终为0(RESULT_CANCELLED),并且返回的Intent为null.如果视频结束播放并且VLC自行退出,则会发生相同的情况.根据文档,我们应该获得带有包含诸如extra_position(在退出时获取视频位置.

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.

已在Android TV模拟器,Nvidia Shield Tablet和Android手机(注4)上进行了测试.尝试使用VLC 2.0.6,最新的Beta和每晚构建.

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

推荐答案

替换

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

使用

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

这应该给出您想要的结果.

This should give the result you are looking for.

这篇关于VLC意向始终返回结果代码0-RESULT_CANCELED的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆