Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't play this video. Android videoView mp4 recorded by android device

enter image description here

I've looked for existing potential solutions with other formats and those still responds with mentioned error.

Finally, recorded the video with the same device and used it as a resource for this app and it still doesn't work.

Devices: SGS2, lenovo a820

Video type: MPEG-4 video (video/mp4)

    videoView = (VideoView)findViewById(R.id.videoView);
    videoView.setVideoPath("android.resource://raw/sample.mp4");
    videoView.start();
like image 481
Jacob Avatar asked Jul 14 '14 05:07

Jacob


2 Answers

Please refer below code snippet...problem was with the path declaration..

 String uriPath = "android.resource://"+getPackageName()+"/"+R.raw.aha_hands_only_cpr_english;
        Uri uri = Uri.parse(uriPath);
        mVideoView.setVideoURI(uri);

Thats it...

like image 194
Jayesh Khasatiya Avatar answered Oct 02 '22 12:10

Jayesh Khasatiya


I tried everything mentioned before but it turns out that internet permission is needed to play a mp4 file.

<uses-permission android:name="android.permission.INTERNET" />
like image 40
Vol-i Avatar answered Oct 02 '22 14:10

Vol-i