i’m trying to play a video with the sample of Video Player from Android developers: http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/media/VideoViewDemo.html
I have a mp4 video (1.mp4) stored on the assets folder, but i dont know how to specify the path variable to point into that file
THis is the code i have:
public class DemoVideoActivity extends Activity {
/**
* TODO: Set the path variable to a streaming video URL or a local media
* file path.
*/
private String path = "";
private VideoView mVideoView;
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.videoview);
mVideoView = (VideoView) findViewById(R.id.surface_view);
if (path == "") {
// Tell the user to provide a media file URL/path.
Toast.makeText(
DemoVideoActivity.this,
"Please edit VideoViewDemo Activity, and set path"
+ " variable to your media file URL/path",
Toast.LENGTH_LONG).show();
} else {
/*
* Alternatively,for streaming media you can use
* mVideoView.setVideoURI(Uri.parse(URLstring));
*/
mVideoView.setVideoPath(path);
mVideoView.setMediaController(new MediaController(this));
mVideoView.requestFocus();
}
}
}
OK, This is solution for video from /res/raw folder, (Actually I got it from somewhere in SO and it works in my case)
And video from asset I never try that but, If you are use MediaPlayer then I think this will help you,
Here player is media player’s object.
Thanks.