Wael Sarmini
Wael Sarmini

Reputation: 9

How to Add MX Player as the default player in an android application?

I want a way to set up a MX Player to play videos in my application.

Upvotes: 0

Views: 1538

Answers (1)

Bertram Gilfoyle
Bertram Gilfoyle

Reputation: 10235

This will launch any installed version of MX Player(Not tested).You need to add data to the intent to play videos. Good luck with your app.

Intent intent;
PackageManager packageManager=getPackageManager();
try {
    intent= packageManager.getLaunchIntentForPackage("com.mxtech.videoplayer.pro");
    if (null != intent)this.startActivity(intent);
}
catch (ActivityNotFoundException e) {
    //MX Player pro isn't installed
    try{
        intent= packageManager.getLaunchIntentForPackage("com.mxtech.videoplayer.ad");
        if (null != intent)this.startActivity(intent);
       }
       catch (ActivityNotFoundException e) {
       //No version of MX Player is installed.You should let the user know
       }
}

Upvotes: 0

Related Questions