VLC intent始终返回结果代码0 - RESULT_CANCELED

时间:2017-07-31 23:40:36

标签: javascript android cordova android-intent vlc

此代码工作正常并按预期启动视频播放,但在我们的Cordova应用程序中退出VLC时,返回正确的requestCode(42),但resultCode始终为0(RESULT_CANCELLED)并且返回的Intent为null。如果视频完成播放并且VLC自行退出,则会发生同样的情况。根据{{​​3}},我们应该得到RESULT_OK,并返回含有extra_position等信息的Intent(以便在退出时获取视频位置)。

其他意图工作正常,例如选择联系意图。

在Android电视模拟器,Nvidia Shield Tablet和Android手机上进行了测试(注4)。试过VLC 2.0.6,最新的Betas和夜间版本。

   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 个答案:

答案 0 :(得分:2)

替换

function nes(){ if (document.getElementById('nes').style.display == 'block'){ document.getElementById('nes').style.display = 'none'; } else if (document.getElementById('snes').style.display == 'block') { document.getElementById('snes').style.display = 'none'; } else if (document.getElementById('gba').style.display == 'block') { document.getElementById('gba').style.display = 'none'; } else if (document.getElementById('sega').style.display == 'block') { document.getElementById('sega').style.display = 'none'; } else if (document.getElementById('flash').style.display == 'block') { document.getElementById('flash').style.display = 'none'; } else if (document.getElementById('n64').style.display == 'block') { document.getElementById('n64').style.display = 'none'; } else if (document.getElementById('all').style.display == 'block') { document.getElementById('all').style.display = 'none'; } document.getElementById('snes').style.display = 'block'; } <input id=nesdot type="image" src="C:\Users\Me\Documents\Website\Assets\Home Page\selection dot.png", onclick='nes()'/> <div id=nes> <input type="image" src="C:\Users\Sam Scolari\Documents\Totally Not An Arcade\Assets\Home Page\Adjusted Logos\NES.png"/> </div> <div id=all> <input type="image" src="C:\Users\Sam Scolari\Documents\Totally Not An Arcade\Assets\Home Page\Adjusted Logos\A2Z.png"/> </div>

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

这应该给出你想要的结果。