Android Multimedia Playback code:
The code is as follows |
Copy Code |
Import android.app.Activity; Import Android.os.Bundle; Import Android.view.View; Import Android.view.View.OnClickListener; Import Android.widget.Button; Import Android.widget.VideoView; public class Videoplayer extends activity { /** called the activity is a. */ @Override public void OnCreate (Bundle icicle) { Super.oncreate (Icicle); Setcontentview (R.layout.main); Final Videoview w = (videoview) Findviewbyid (R.id.vdoplayer); Button Cmdload = (button) This.findviewbyid (r.id.cmd_load); Cmdload.setonclicklistener (New Onclicklistener () { public void OnClick (View arg0) { TODO auto-generated Method Stub W.setvideopath ("/sdcard/android/kongfu.mp4"); } } ); Button Cmdplay = (button) This.findviewbyid (R.id.cmd_play); Cmdplay.setonclicklistener (New Onclicklistener () { public void OnClick (View arg0) { TODO auto-generated Method Stub W.start (); } } ); Button Cmdpause = (button) This.findviewbyid (R.id.cmd_pause); Cmdpause.setonclicklistener (New Onclicklistener () { public void OnClick (View arg0) { TODO auto-generated Method Stub W.pause (); } } ); } |
Android Multimedia playback Implementation code:
XML file:
code is as follows |
copy code |
<? 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 " < Button android:id=" @+id/cmd_load " android:layout_width=" fill_parent " Android:layout_ height= "Wrap_content" android:text= "Load"/> < button android:id= "@+id/cmd_play" Android:layout_ Width= "Fill_parent" android:layout_height= "wrap_content" android:text= "Play"/> < Button android: Id= "@+id/cmd_pause" android:layout_width= "fill_parent" android:layout_height= "Wrap_content" Android: text= "Pause"/> < Videoview android:id= "@+id/vdoplayer" android:layout_width= "Fill_parent" Android : layout_height= "300px"/> </linearlayout> |