1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
| import android.widget.*; import android.view.View.*; import android.view.*; import android.net.*; import java.io.*; public class MainActivity extends Activity { private Button bn1,bn2,bn3; private VideoView vv; @Override protected void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.main); bn1=(Button) findViewById(R.id.mainButton1); bn2=(Button) findViewById(R.id.mainButton2); bn3=(Button) findViewById(R.id.mainButton3); vv=(VideoView) findViewById(R.id.mainVideoView); vv.setVideoURI(Uri.parse("[url]file:///sdcard/123.mp4")); //视频的路径 vv.setMediaController(new MediaController(this)); bn1.setOnClickListener(new OnClickListener(){ @Override public void onClick(View p1){ vv.start(); } }); bn2.setOnClickListener(new OnClickListener(){ @Override public void onClick(View p1) { vv.pause(); } }); bn3.setOnClickListener(new OnClickListener(){ @Override public void onClick(View p1) { vv.stopPlayback(); } }); } }
|