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

android使用videoview播放視頻

 更新時間: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)文章

最新評論

江口县| 黎平县| 武川县| 宁化县| 洪江市| 都兰县| 监利县| 高安市| 兴隆县| 宜州市| 大丰市| 邵武市| 定兴县| 饶阳县| 萝北县| 辽阳县| 南丹县| 化州市| 类乌齐县| 奇台县| 辽源市| 临江市| 五寨县| 轮台县| 禄丰县| 民权县| 隆化县| 丰顺县| 嵊泗县| 鄂尔多斯市| 海安县| 元阳县| 阿尔山市| 浦县| 余江县| 万全县| 南木林县| 房产| 睢宁县| 永德县| 海晏县|