1

While save mp4 file to /data/data/mypackage/files/my.mp4, then call VideoView's setVideoPath(); it can not work.

For the same file, if I save the file to /mnt/sdcard/my.mp4, then call the same VideoView's setVideoPath, it plays correctly.

Is there any way I can play mp4 file under /data/data/mypackage/files/?

David Guo
  • 1,749
  • 3
  • 20
  • 30

1 Answers1

4

The MP or VideoView uses a native player which cannot access non-worldreadable files.

So you have to options basically:

1) Make the created files world-readable

2) Open an input stream to the file in your program and just hand over the file descriptor to the media player:

FileInputStream fi = new FileInputStream(file);
MediaPlayer pl = new MediaPlayer();
pl.setDataSource(fi.getFD());
pl.prepare();
pl.start();

Also look at this thread VideoView/MediaPlayer doesn't play video from internal storage And find a Custom VideoView class code from here also look at this SO question Can a videoview play a video stored on internal storage?

Community
  • 1
  • 1
user370305
  • 108,599
  • 23
  • 164
  • 151