Skip to content Skip to sidebar Skip to footer

Can't Play Mp4 Video In My Android App

I very want to play mp4 video in my android app. I even wrote a bit of code for it: String sourceUrl = 'http://tvstream.cn.ru/storage/1kanal/20120530/' + '1kanal-20120530-01

Solution 1:

Probably your file is using an unsupported profile, notice that official media formats page only lists Baseline Profile as supported for H.264 AVC.

Try transcoding the video specifying Baseline Profile as suggested in this stackoverflow question, i.e. if your container is MP4 run:

ffmpeg -i yourfile.mp4 -c:v libx264 -profile:v baseline -level 1 yourfile_BaselineProfile.mp4

If this works it's not a issue in your code, you just have to use supported formats.

Solution 2:

Try this

File clip=newFile(Environment.getExternalStorageDirectory(),
                       "test.mp4");

    if (clip.exists()) {
      video=(VideoView)findViewById(R.id.video);
      video.setVideoPath(clip.getAbsolutePath());

      ctlr=newMediaController(this);
      ctlr.setMediaPlayer(video);
      video.setMediaController(ctlr);
      video.requestFocus();
      video.start();

Solution 3:

VideoView classes does not allow playing MP4 file format videos. Please go through this link for Android Media Formats. Try checking your video with Daroon Player

Post a Comment for "Can't Play Mp4 Video In My Android App"