最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

android使用videoview播放視頻

 更新時(shí)間:2014年02月28日 16:46:39   作者:  
這篇文章主要介紹了Android利用自帶VideoView控件播放視頻的示例,需要的朋友可以參考下

復(fù)制代碼 代碼如下:

public class Activity01 extends Activity
{
 /** Called when the activity is first created. */
 @Override
 public void onCreate(Bundle savedInstanceState)
 {
  super.onCreate(savedInstanceState);

  setContentView(R.layout.main);


  final VideoView videoView = (VideoView) findViewById(R.id.VideoView01);

  Button PauseButton = (Button) this.findViewById(R.id.PauseButton);
  Button LoadButton = (Button) this.findViewById(R.id.LoadButton);
  Button PlayButton = (Button) this.findViewById(R.id.PlayButton);

  // load
  LoadButton.setOnClickListener(new OnClickListener() {
   public void onClick(View arg0)
   {
//    videoView.setVideoPath("/sdcard/test.mp4");
    videoView.setVideoPath("android.resource://com.homer/"+R.raw.china);
    videoView.setMediaController(new MediaController(Activity01.this));
    videoView.requestFocus();
   }
  });

  // play
  PlayButton.setOnClickListener(new OnClickListener() {
   public void onClick(View arg0)
   {
    videoView.start();
   }
  });

  // pause
  PauseButton.setOnClickListener(new OnClickListener() {
   public void onClick(View arg0)
   {
    videoView.pause();
   }
  });
 }
}

main.xml

復(fù)制代碼 代碼如下:

<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
    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" />

    <VideoView
        android:id="@+id/VideoView01"
        android:layout_width="320px"
        android:layout_height="240px" />

    <Button
        android:id="@+id/LoadButton"
        android:layout_width="80px"
        android:layout_height="wrap_content"
        android:layout_x="30px"
        android:layout_y="300px"
        android:text="裝載" />

    <Button
        android:id="@+id/PlayButton"
        android:layout_width="80px"
        android:layout_height="wrap_content"
        android:layout_x="120px"
        android:layout_y="300px"
        android:text="播放" />

    <Button
        android:id="@+id/PauseButton"
        android:layout_width="80px"
        android:layout_height="wrap_content"
        android:layout_x="210px"
        android:layout_y="300px"
        android:text="暫停" />

</AbsoluteLayout>

相關(guān)文章

最新評(píng)論

盈江县| 藁城市| 体育| 襄垣县| 来宾市| 丹棱县| 桂林市| 永福县| 丰城市| 民县| 巴彦淖尔市| 遂宁市| 雷州市| 汝南县| 宁都县| 博爱县| 汪清县| 呈贡县| 瑞安市| 建昌县| 高陵县| 成武县| 麻阳| 渝中区| 招远市| 体育| 平潭县| 疏附县| 龙南县| 商城县| 铜川市| 玉田县| 柳林县| 苍南县| 滕州市| 隆子县| 贵南县| 伊春市| 宝丰县| 胶州市| 玉溪市|