开发者

How do you make internal files world readable on Honeycomb?

开发者 https://www.devze.com 2023-04-06 03:42 出处:网络
I am trying to load video files from my internal storage to a VideoView. I download these video files from a server and then store them locally using this code:

I am trying to load video files from my internal storage to a VideoView. I download these video files from a server and then store them locally using this code:

FileOutputStream out = openFileOutput(filename, Context.MODE_WORLD_READABLE);

The documentation here: http://developer.android.com/guide/topics/data/data-storage.html#filesInternal made me believe that these files would be created as world readable, but I don't think that is true.

Here is the code I use to load the file into the ViewView:

开发者_如何学Python
videoView.setVideoPath(getFilesDir() +"/"+ filename);

And here is the output I get from DDMS:

ERROR/MediaPlayer(4264): error (1, -2147483648)
ERROR/MediaPlayer(4264): Error (1,-2147483648)
DEBUG/VideoView(4264): Error: 1,-2147483648

If I change the code to load the same video from my raw resources directory, everything runs fine. However, I need to be able to download these videos and play them locally.

Are my only options to use external data or is there a way to make internal data public to something like a VideoView?


CommonsWare solution in the comments is repeated below, as it is the one I ended up using:

Note that you can always use MediaPlayer and SurfaceView if you don't like the interface of VideoView. Or, implement a simple ContentProvider with openFile() to return the FileDescriptor and use the content:// Uri with VideoView. - CommonsWare

0

精彩评论

暂无评论...
验证码 换一张
取 消