cr5315
Android Enthusiast
I'm making an app that plays a video right from the start and I'm trying to figure out how to get the app the choose the video from the res/raw folder. The example in my android book had streaming a .3gp video from a website and that worked, but I can't figure out how to have it choose from the video in the res/raw folder.
Activity.java
main.xml
I've seen it done before, I just can't remember how.
Activity.java
Code:
import android.app.Activity;
import android.net.Uri;
import android.os.Bundle;
import android.widget.MediaController;
import android.widget.VideoView;
public class fireActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
VideoView videoView = (VideoView) findViewById(R.id.VideoView);
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(videoView);
// Set video link (mp4 format )
Uri video = Uri.parse("www.example.com/video.3gp");
videoView.setMediaController(mediaController);
videoView.setVideoURI(video);
videoView.start();
}
}
main.xml
Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:id="@+id/LinearLayout01"
android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android"
android:paddingLeft="2px" android:paddingRight="2px"
android:paddingTop="2px" android:paddingBottom="2px"
android:layout_width="fill_parent" android:orientation="horizontal">
<VideoView android:layout_height="fill_parent"
android:layout_width="fill_parent" android:id="@+id/VideoView"></VideoView>
</LinearLayout>
I've seen it done before, I just can't remember how.
)