Question

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?

Was it helpful?

Solution

  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().
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top