So, here is the xml layout for this...
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 | <? xml version = "1.0" encoding = "utf-8" ?> android:layout_width = "fill_parent" android:layout_height = "fill_parent" android:orientation = "vertical" > < TextView android:layout_width = "fill_parent" android:layout_height = "wrap_content" android:text = "@string/hello" /> < LinearLayout android:id = "@+id/linearLayout1" android:layout_width = "match_parent" android:layout_height = "wrap_content" android:orientation = "vertical" > < Button android:id = "@+id/button1" android:layout_width = "wrap_content" android:layout_height = "wrap_content" android:text = "PLAY" /> < VideoView android:id = "@+id/videoView1" android:layout_width = "match_parent" android:layout_height = "wrap_content" /> </ LinearLayout > </ LinearLayout > |
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 43 44 45 46 47 48 49 | package com.myandroid.videoPlayer; import android.app.Activity; import android.graphics.PixelFormat; import android.net.Uri; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.MediaController; import android.widget.VideoView; public class VideoPlayActivity extends Activity { Button btPlay; VideoView vv; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super .onCreate(savedInstanceState); setContentView(R.layout.main); btPlay=(Button)findViewById(R.id.button1); vv=(VideoView)findViewById(R.id.videoView1); btPlay.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub playVideo(); } private void playVideo() { getWindow().setFormat(PixelFormat.TRANSLUCENT); VideoView videoHolder = new VideoView(VedioPlayActivity. this ); videoHolder.setMediaController( new MediaController(VedioPlayActivity. this )); videoHolder.setVideoURI(video); setContentView(videoHolder); videoHolder.start(); } }); } } |
No comments:
Post a Comment