Search code examples
androidandroid-intentandroid-video-player

How can i play my video files using intent in android


This code works if mx player is installed if i uninstalled no application will be listed and showing(i have my default player in my phone) EXCEPTION : No Activity found to handle Intent { act=android.intent.action.VIEW in the logical

try {
    Intent mVideoWatch = new Intent(Intent.ACTION_VIEW);
    mVideoWatch.setDataAndType(Uri.parse(mVideosPath[i]), "video/*");
    startActivity(mVideoWatch);
}
catch(Exception e) {
    Log.e(TAG,e.getMessage());
}

Solution

  • Thank you everyone for your answers

    Got the solution

             try {
                    mVideosPath[i] = "file://"+mVideosPath[i];
                      // mVideosPath[i] = /storage/emulated/0/Movies/test.mp4 
    
                    Intent mVideoWatch = new Intent(Intent.ACTION_VIEW);
                    mVideoWatch.setDataAndType(Uri.parse(mVideosPath[i]),mVideostype[i]);
                    startActivity(mVideoWatch);
                }
                catch(Exception e)
                {
                    Log.e(TAG,e.getMessage());
                }