0

I want to play a video from my sdcard on my android device inside a VideoView but I always get the Error: 1,-2147483648. My code looks like this:

private VideoView video_view;
private MediaController ctlr;

//define video and play it if it exists
    File clip = new File(Environment.getExternalStorageDirectory().getPath()
            +feed.getStep(current_step).getPathToVideo());

    if (clip.exists()) {
        Log.d(TAG, "Video exists");

        video_view.setVideoPath(clip.getAbsolutePath());

        ctlr = new MediaController(this);
        ctlr.setMediaPlayer(video_view);
        video_view.setMediaController(ctlr);
        video_view.requestFocus();
        video_view.start();
    }else{
        Log.d(TAG, "Video DOES NOT exist, path is: "+Environment.getExternalStorageDirectory()
                .getPath()+feed.getStep(current_step).getPathToVideo());
    }

In LogCat I get this output:

Video DOES NOT exist, path is: /storage/sdcard0/video/lvl1/documentariesandyou.mp4

The video is located at my sdcard in /video/lvl1/documentariesandyou.mp4

The video is compatible I took it from this post.

What can I do to play the movie on my device?

Community
  • 1
  • 1
Mokkapps
  • 2,028
  • 9
  • 42
  • 67
  • Refer this http://stackoverflow.com/questions/18833537/android-mediaplayer-videoview-error-1-2147483648?rq=1 – Hari_krish4 Apr 07 '14 at 13:09
  • Hello, how you can fix this issue? Please update answer. Thank you Mr.Mojo. – Huy Tower Mar 27 '15 at 07:24
  • @HuyTower: I have posted the solution as comment in the marked answer. My SD card was mounted from my OS (Ubuntu) so Android couldn't mount it. – Mokkapps Mar 27 '15 at 08:10
  • Where is this `marked answer`? This one "The problem was that the storage was mounted by my OS (ubuntu) and so I could not access the files on the sdcard! " ??? I don't understand what u said. Not related to Android device? no need modify codes or permission, something else related to Android device? – Huy Tower Mar 27 '15 at 08:20
  • Yes the problem was not the code, the problem was that I already mounted my SD card inside my operating system. After I dismounted it from Ubuntu, it worked – Mokkapps Mar 27 '15 at 11:25

1 Answers1

0
  1. Make sure your manifest have a READ_EXTERNAL_STORAGE permission.
  2. Check the availability of the external storage using getExternalStorageState().
  3. Try getAbsolutePath() instead of just getPath().