views:

98

answers:

2

How to play video present in local file system (ex:in res/a.3gp) using VideoView . I need Sample code. I am trying to play as below:

import android.app.Activity;
import android.os.Bundle;
import android.widget.MediaController;
import android.widget.VideoView;

public class videoSample extends Activity {
/** Called when the activity is first created. */
String path="D:/mApp2/videoSample/res/drawable-hdpi/adf.mp4";
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
VideoView videoView = (VideoView) findViewById(R.id.VideoView01);
MediaController mediaController = new MediaController(this);
mediaController.setMediaPlayer(videoView);
videoView.setVideoPath(path);
videoView.setMediaController(mediaController);
videoView.requestFocus();
videoView.start();
mediaController.show();
}
}
I am getting error as Video cant be played. Can any one help me in sorting out this issue? Thanks in Advance.

A: 

Afaik it's not possible to play videos from the internal app storage, see http://stackoverflow.com/questions/3038474/can-a-videoview-play-a-video-stored-on-internal-storage

I faced similar issue and already searched about it.

http://www.anddev.org/multimedia-problems-f28/videoview-cannot-play-video-from-internal-storage-t16636.html

http://groups.google.com/group/android-developers/browse_thread/thread/a01d415c8e48e0d3

Workaround is to copy the video to sdcard temporarily and play it from there.

Mathias Lin
+1  A: 

String path="D:/mApp2/videoSample/res/drawable-hdpi/adf.mp4";

There is no D: drive in Android. Android is not Windows.

CommonsWare