lucky android
lucky android

Reputation: 111

How play video from /data/data/package_name/files

I want to play video file from /data/data/package_name/files in Android. I used Eclipse IDE to develop the android application.

How i can achieve this ?

Thanks.

Upvotes: 0

Views: 1046

Answers (1)

user370305
user370305

Reputation: 109237

Use this code lines,

FileInputStream fileInputStream = new FileInputStream("/data/data/com.mypackage/myfile");
mediaPlayer.setDataSource(fileInputStream.getFD());

OR:

MediaController mc = new MediaController(this);
mc.setAnchorView(videoView);
mc.setMediaPlayer(videoView);
Uri video = Uri.parse(path); // Here path is your video file path place in internal storage
videoView.setMediaController(mc);
videoView.setVideoURI(video);
videoView.start();

But make sure your video file in internal storage has Context.MODE_WORLD_READABLE permission.. Bco'z MediaPlayer requires that the file being played has world-readable permissions.

Upvotes: 2

Related Questions