I'm trying to give an option to the user to play video in MX Player but seems like it just opens the app instead of actually playing the video, so can someone help me out here, please?
My Code:
String videoStreamUrl = null;
Intent intent;
if (type.equals("movie")) {
if (listDirector.get(0).getStremURL() != null) {
videoStreamUrl = commonVideoUrl;
}
}else{
videoStreamUrl = commonVideoUrl;
}
if(videoStreamUrl!=null) {
PackageManager packageManager=getPackageManager();
try {
intent= packageManager.getLaunchIntentForPackage("com.mxtech.videoplayer.pro");
if (null != intent)
intent.setDataAndType(Uri.parse(videoStreamUrl), "video/*");
startActivity(intent);
}
catch (ActivityNotFoundException e) {
//MX Player pro isn't installed
try{
intent= packageManager.getLaunchIntentForPackage("com.mxtech.videoplayer.ad");
if (null != intent)
intent.setDataAndType(Uri.parse(videoStreamUrl), "video/*");
startActivity(intent);
}
catch (ActivityNotFoundException er) {
//No version of MX Player is installed.You should let the user know
}
}
}