Android Programming Tutorials

(Romina) #1
Media

video.setVideoPath(clip.getAbsolutePath());

ctlr=new MediaController(this);
ctlr.setMediaPlayer(video);
video.setMediaController(ctlr);
video.requestFocus();
video.start();
}
}
}

Here, we simply configure the VideoView, including the MediaController to


give us buttons to control playback of the video. At the end, we call start(),


to begin playback automatically.


And, as always, when we add an activity to our project, we need to add it to


AndroidManifest.xml, so add the following element alongside the


others:


<activity android:name=".HelpCast">
</activity>

Step #3: Launch the Helpcast from the Menu


Finally, we need to integrate HelpCast into Patchy overall, so users can


display the help video. As we have done in previous tutorials, we will


accomplish this by extending the option menu with another menu item.


First, add the following to Patchy/res/menu/option.xml:


<item android:id="@+id/help"
android:title="Help"
android:icon="@drawable/ic_menu_help"
/>

You will also need a suitable menu icon, such as the ic_menu_help.png image


from the Android SDK.


Then, update onOptionsItemSelected() in Patchy to launch HelpCast when


our item is selected:


247
Free download pdf