当前位置:操作系统 > 安卓/Android >>

Android ApiDemos示例解析(88):Media->VideoView

除了使用MediaPlayer来播放视频外,Android还提供了一个VideoView可以更方便的来播放视频。VideoView 是View 的子类,可以用在所有支持View的地方,包括定义在AndroidManifest.xml文件中:

<LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android”
android:orientation=”vertical”
android:layout_width=”match_parent”
android:layout_height=”match_parent”
>

<VideoView
android:id=”@+id/surface_view”
android:layout_width=”320px”
android:layout_height=”240px”
/>

</LinearLayout>

VideoView可以播放来自资源文件,网络或是Content provider, 并可以是图像自适应屏幕,并提供缩放等功能。同时可以在屏幕上提供“前进”,“后退”,“播放”,“暂停”等按钮。


[java] 
path = "/sd card/dcim/camera/test.3gp"; 
//path = "http://www.imobilebbs.com/download/android/boy.3gp";  
mVideoView.setVideoPath(path); 
mVideoView.setMediaController(new MediaController(this)); 
mVideoView.requestFocus(); 

path = "/sd card/dcim/camera/test.3gp";
//path = "http://www.imobilebbs.com/download/android/boy.3gp";
mVideoView.setVideoPath(path);
mVideoView.setMediaController(new MediaController(this));
mVideoView.requestFocus();

 

\

作者:mapdigit

 


补充:移动开发 , Android ,
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,