Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Play Video Using External Media Player in Android

Well, I've used VideoView to play my Video. It only support .mp4 format(Correct me if I'm wrong), I need to play .flv video. I've MX Player/VLC player installed on my Android phone. How do I load the list of available Media Players when I click Play Video Button in my Activity.

Below is the code I've written using Video View, if it helps

public void onClick(View v) {
            File root = Environment.getExternalStorageDirectory();                
            String externalFilesDir = getExternalFilesDir(null).toString();       
            String videoResource = externalFilesDir +"/" + "VID_20160115_215637181.mp4";
            mediaController.setAnchorView(videoView);
            videoView.setMediaController(mediaController);
            videoView.setVideoPath(videoResource);
            videoView.requestFocus();
            videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
                @Override
                public void onPrepared(MediaPlayer mp) {
                    videoView.seekTo(0);
                    videoView.start();
                }
            });
        }
like image 702
Spark Avatar asked Mar 23 '26 06:03

Spark


1 Answers

If You want to play video in some other player, you can use ACTION_VIEW intent

Example in this question: Android intent for playing video?

like image 52
bartexsz Avatar answered Mar 24 '26 20:03

bartexsz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!