Paresh Dudhat
Paresh Dudhat

Reputation: 1246

Android VideoView not playing mp4 files

I have already seen most of the questions here but none of them helps.

Following is Streaming url it works perfectly on VLC and browser but it can't be played in android app.

Here is my code

public class VideoDemo extends Activity {
    private VideoView video;
    private MediaController ctlr;

    @Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        getWindow().setFormat(PixelFormat.TRANSLUCENT);
        setContentView(R.layout.main);

       /* File clip = new File(Environment.getExternalStorageDirectory(),
                "90.mp4");*/

       /* if (clip.exists()) {*/
            video = (VideoView) findViewById(R.id.video);
            //video.setVideoPath(clip.getAbsolutePath());
             video.setVideoURI(Uri.parse("http://103.50.152.102:9096/LubrizolWebPrj/service/getEnqVideo/90"));
            video.requestFocus();
            video.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
                @Override
                public void onPrepared(MediaPlayer mediaPlayer) {
                    video.start();
                }
            });
        //}
    }
}

Upvotes: 1

Views: 1791

Answers (1)

Shridutt Kothari
Shridutt Kothari

Reputation: 7394

MP4 is just a container - the video and audio stream inside it will both be encoded in different formats.

Android natively only supports certain types of formats. There is a list here:

http://developer.android.com/guide/appendix/media-formats.html

Make sure the video and audio encoding type is supported. Just because it says "mp4" doesn't automatically mean it should be playable.

Though if your format is not supported, Try using YoutubeVideoView

Upvotes: 3

Related Questions