Media
Step #2: Create the Stub Helpcast Activity
Now, we need to add an activity that will use the VideoView widget to
display our video clip.
First, add the following layout as Patchy/res/layout/helpcast.xml:
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
android:id="@+id/video"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
Then, create Patchy/src/apt/tutorial/two/HelpCast.java with the following
code:
package apt.tutorial.two;
import android.app.Activity;
import android.graphics.PixelFormat;
import android.os.Bundle;
import android.os.Environment;
import android.view.View;
import android.widget.MediaController;
import android.widget.VideoView;
import java.io.File;
public class HelpCast extends Activity {
private VideoView video;
private MediaController ctlr;
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
getWindow().setFormat(PixelFormat.TRANSLUCENT);
setContentView(R.layout.helpcast);
File clip=new File(Environment.getExternalStorageDirectory(),
"helpcast.mp4");
if (clip.exists()) {
video=(VideoView)findViewById(R.id.video);
246
Subscribe to updates at http://commonsware.com
Special Creative Commons BY-NC-SA 3.0 License Edition
Step #2: Create the Stub Helpcast Activity
Now, we need to add an activity that will use the VideoView widget to
display our video clip.
First, add the following layout as Patchy/res/layout/helpcast.xml:
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
Then, create Patchy/src/apt/tutorial/two/HelpCast.java with the following
code:
package apt.tutorial.two;
import android.app.Activity;
import android.graphics.PixelFormat;
import android.os.Bundle;
import android.os.Environment;
import android.view.View;
import android.widget.MediaController;
import android.widget.VideoView;
import java.io.File;
public class HelpCast extends Activity {
private VideoView video;
private MediaController ctlr;
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
getWindow().setFormat(PixelFormat.TRANSLUCENT);
setContentView(R.layout.helpcast);
File clip=new File(Environment.getExternalStorageDirectory(),
"helpcast.mp4");
if (clip.exists()) {
video=(VideoView)findViewById(R.id.video);
246
Subscribe to updates at http://commonsware.com
Special Creative Commons BY-NC-SA 3.0 License Edition
