I have seen few questions similar to this one, but I wanted to make sure.. I fail running video on my emulator. Is it consistent? Does anyone succeeded running a video on the emulator?
The following is the code I use:
import android.app.Activity;
import android.net.Uri;
import android.os.Bundle;
import android.widget.MediaController;
import android.widget.VideoView;
public class TTTTest extends Activity {
/** Called when the activity is first created. */
private MediaController mc;
VideoView vd;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
vd = (VideoView) findViewById(R.id.VideoView);
Uri uri = Uri.parse("android.resource://" + getPackageName() + R.raw.samplevideo);
mc = new MediaController(this);
vd.setMediaController(mc);
vd.setVideoURI(uri);
vd.start();
}
}
"samplevideo" is either mp4 or 3gp (in both cases its not working)
main.xml is as follows:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<VideoView android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:id="@+id/VideoView"></VideoView>
</LinearLayout>
and the manifest is the default one. Can anyone please tell me if I have a problem with my code? p.s. I am running the emulator using android 2.2 environment.