Reputation: 387
I'm trying to display video in a defined VideoView in the .xml file, but the way I followed represented in the below code, doesnt work.
Please check the code and guide me.
code:
final String VIDEO_FILE_PATH = "C:\\Users\\Amr\\Downloads\\3aeshen ElLa7za.avi";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
VideoView vv =
(VideoView) findViewById(R.id.video_view);
mp = new MediaPlayer();
try {
mp.setDataSource(VIDEO_FILE_PATH);
mp.prepare();
mp.start();
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
vv.setVideoPath(MEDIA_FILE_PATH);
vv.start();
}
Upvotes: 0
Views: 317
Reputation: 54330
Yeah, as userIsAMonkeysays you cannot refer to a Video in your PC. It has to be placed in your SDCARD or in your phone memory. If you are using a emulator, push the file to your sdcard by following the below steps,
1) Go to DDMS.
2) Go to Devices tab.
3) Click on your Emulator which will be listed in the Devices.
4) Now go to File Explorer-> click on "mnt" folder-> click on SDCard.
5) Now you will be able to see two icons on top right corner of your File Explorer tab. One is to push a file and other one is to pull a file. Click on push a file icon, and select your file and done.
6) Now as userIsAMonkey has suggested,
final String VIDEO_FILE_PATH = Environment.getExternalStorageDirectory() + "/3aeshen ElLa7za.avi"
That's it.
Upvotes: 2
Reputation: 3255
Your video file path should be on a SD CARD:
final String VIDEO_FILE_PATH = Environment.getExternalStorageDirectory() + "/yourappdirectory/3aeshen ElLa7za.avi"
Upvotes: 0