I am started learning android from a few days and I have a problem with the video file I tried to use many video files but the problem still,when I copy the file to the raw files the icon type like xml file instead of question mark and when I try call the file I can't because the type file changed from media file to xml file so please help me .
Thank in advance ]1]1
If I am able to get your question right, you are not able to play a video file. There are several ways one can play a video in android and the easiest would be to place a video file (.mp4 extension recommended) in a raw folder (create one if you don't have it) inside of your res folder. And please get a video from here.
Place the video in your raw folder as mentioned above.
You can play the video by placing a
VideoView in your xml.
<?xml version="1.0" encoding="utf-8"?> <LinearLayout android:id="@+id/LinearLayout01" android:layout_height="fill_parent" android:paddingLeft="2px" android:paddingRight="2px" xmlns:android="http://schemas.android.com/apk/res/android" android:paddingTop="2px" android:paddingBottom="2px" android:layout_width="fill_parent" android:orientation="vertical"> <VideoView android:layout_height="fill_parent" android:layout_width="fill_parent" android:id="@+id/VideoView" /> </LinearLayout>
VideoView view = (VideoView)findViewById(R.id.videoView); String path = "android.resource://" + getPackageName() + "/" + R.raw.video_file; view.setVideoURI(Uri.parse(path)); view.start();
where video_file in
R.raw.video_file is your video file name. If your video file name is
boom.mp4 then you can write