Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7278677
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T22:54:26+00:00 2026-05-28T22:54:26+00:00

I have a problem that I have been trying to find a solution for

  • 0

I have a problem that I have been trying to find a solution for a long time. My situation is as follows:

I have an app that downloads zipped videos and unzips them at the application’s private folder and more specifically at a subfolder. For example at /data/data/my.app.package.name.here/files/assets/assets-955.

Inside this folder the video is unzipped. The unzipping process is completed successfully since I can pull and view the video without problems when running the app on the emulator.

I then have another activity that is accessing this folder, finds the video file and tries to open it. At this point I get an error that “Sorry, this video cannot be played” with the following error stack:

01-30 17:36:17.770: D/ContentDemoActivity(6757): File: /data/data/xxxx/files/assets/assets-955/bank_2.mp4
01-30 17:36:17.830: I/MediaPlayer(6757): prepareAsync called in state 4
01-30 17:36:17.830: E/MediaPlayer(6757): error (1, -2147483648)
01-30 17:36:17.860: E/MediaPlayer(6757): Error (1,-2147483648)
01-30 17:36:17.860: D/VideoView(6757): Error: 1,-2147483648
01-30 17:36:19.370: E/MediaPlayer(6757): stop called in state 0
01-30 17:36:19.370: E/MediaPlayer(6757): error (-38, 0)
01-30 17:36:19.370: W/MediaPlayer(6757): mediaplayer went away with unhandled events

The code with which I am trying to play the video is pretty basic:

mView = (VideoView) findViewById(R.id.videoView);

mMediaPlayer = new MediaPlayer();

mView.requestFocus();
mHolder = mView.getHolder();

Log.d(tag, "Populating content. Assets path: " + mAssetsPath);
File f = new File(mAssetsPath);
File[] files = f.listFiles();
Log.d(tag, "File: " + files[0].toString());

mView.setVideoURI(Uri.parse(files[0].toString()));

mView.setMediaController(new MediaController(this));

and the layout of the activity has a plain VideoView, nothing fancy there.

The strangest thing is that for testing purposes I used the same video, this time loading it from the “raw” folder and it runs smoothly without problem. In that case though I had to load it with:

Uri video = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.bank_2);
mVideoView.setVideoURI(video);
mVideoView.start();

I would do the same with the downloaded videos but there doesn’t seem to be any function at the API that will allow me to load a video Uri from the application’s private folder.

I have found various solutions by using file descriptors, listeners for the videoView, flags indicating MODE_WORLD_READABLE, pre-calculation of the dimensions of the videoView, etc but none of them had positive results.

In a nutshell, my questions are:

  • Why do I get those errors which according to what I have found online are errors that are related with problematic encoding of the video file ?
  • What is the best things to use in my case, a VideoView or a surfaceView ?
  • Which is the ideal method to load a video from the application’s private folder and be able to play it?

Thanks.

EDIT

After CommonsWare suggestion, I went with the following implementation:

File f = new File(mAssetsPath);
File[] files = f.listFiles();
Log.d(tag, "File: " + files[0].toString());

URI uri = URI.create("file://" + (files[0].toString()));
File file = new File(uri);
try {
    Log.d(tag, "1");
    ParcelFileDescriptor parcel = ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_WRITE);
   Log.d(tag, "2");
    mMediaPlayer.setDataSource(parcel.getFileDescriptor());
    Log.d(tag, "3");
    mMediaPlayer.start();
    Log.d(tag, "4");
} catch (FileNotFoundException e) {
    e.printStackTrace();
} catch (IllegalArgumentException e) {
    e.printStackTrace();
} catch (IllegalStateException e) {
    e.printStackTrace();
} catch (IOException e) {
    e.printStackTrace();
}

 Log.d(tag, "5");

Unfortunately, this time I get the following errors:

01-31 12:40:11.480: D/ContentDemoActivity(15896): File: /data/data/com.houseofradon.meb/files/assets/assets-955/bank_2.mp4
01-31 12:40:11.480: D/ContentDemoActivity(15896): 1
01-31 12:40:11.480: D/ContentDemoActivity(15896): 2
01-31 12:40:11.500: D/ContentDemoActivity(15896): 3
01-31 12:40:11.500: E/MediaPlayer(15896): start called in state 2
01-31 12:40:11.500: E/MediaPlayer(15896): error (-38, 0)
01-31 12:40:11.500: D/ContentDemoActivity(15896): 4
01-31 12:40:11.500: D/ContentDemoActivity(15896): 5
01-31 12:40:11.530: E/MediaPlayer(15896): Error (-38,0)

So, something happens when the media player starts. Error code -38 doesn’t seem to mean anything specific as I found here.

Any idea what I am missing ???

EDIT #2

I now use a mediaPlayer and a SurfaceView to do the whole process along with a surfaceHolder listener. Here is the code:

mMediaPlayer = new MediaPlayer();

mSurfaceView = (SurfaceView) findViewById(R.id.surface);
mHolder = mSurfaceView.getHolder();
mHolder.addCallback(this);


public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
    Log.d(tag, "surfaceChanged");

    try {
        mMediaPlayer.setDisplay(mHolder);
        Log.d(tag, "7");
        mMediaPlayer.start();
        Log.d(tag, "8");
    } catch (IllegalStateException e) {
        e.printStackTrace();
    }

    Log.d(tag, "9");
}



public void surfaceCreated(SurfaceHolder holder) {
    Log.d(tag, "surfaceCreated");
    File f = new File(mAssetsPath);
    File[] files = f.listFiles();
    Log.d(tag, "File: " + files[0].toString());

    URI uri = URI.create("file://" + (files[0].toString()));
    File file = new File(uri);
    try {
        Log.d(tag, "1");
        ParcelFileDescriptor parcel = ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_WRITE);
        Log.d(tag, "2");
        mMediaPlayer.setDataSource(parcel.getFileDescriptor());
        Log.d(tag, "3");
        mMediaPlayer.setVolume(100, 100);
        Log.d(tag, "4");
        mMediaPlayer.prepare();
        Log.d(tag, "5");

    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
    } catch (IllegalStateException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

    Log.d(tag, "6");
}

I can listen to the audio of the video but the picture is just a plain black color. I also get an error almost at the end of the video playback that says:

01-31 14:26:01.300: W/AudioSystem(17165): AudioFlinger server died!
01-31 14:26:01.300: W/IMediaDeathNotifier(17165): media server died
01-31 14:26:01.300: E/MediaPlayer(17165): error (100, 0)
01-31 14:26:01.300: E/MediaPlayer(17165): Error (100,0)

I am using an actual device, Samsung Galaxy Tab 10.1. Any ideas ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T22:54:26+00:00Added an answer on May 28, 2026 at 10:54 pm

    Why do I get those errors which according to what I have found online are errors that are related with problematic encoding of the video file ?

    Because the media playback engine runs in its own process, and it does not have rights to read your file.

    What is the best things to use in my case, a VideoView or a surfaceView ?

    A VideoView contains a SurfaceView. Whether you use VideoView or a combination of MediaPlayer and SurfaceView is up to you.

    Which is the ideal method to load a video from the application’s private folder and be able to play it?

    Either create a ContentProvider that can serve up your local file and use the provider Uri instead of the Uri to a local file, or create the local file using openFileOutput() and MODE_WORLD_READABLE.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have searched a long time and cannot find a solution to my problem.
I have been Googling a problem that I have with trying to integrate the
I have been trying for about an hour now to find an elegant solution
I've been trying all night to find a solution to this problem and haven't
I have a tricky problem that I've been messing about with for a few
This is a really weird problem that I have been having. When I download
I have been optimizing my website but the one problem that stands in my
I've been searching a lot for this problem and I can't find a solution.
I have been trying to track down a problem with an installation of RAD
I'm asking this question because I finally solved a problem that I have been

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.