Android多媒体开发【2】-- 利用VideoView开发最简单的视频播放器
2014-06-23 10:10
435 查看
http://blog.csdn.net/tx3344/article/details/8016240
接下来贴出main.xml的源码:
[html] view
plaincopy
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<VideoView
android:id="@+id/videoView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
接下来贴出程序源码:
[java] view
plaincopy
package com.example.mpy;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.app.Activity;
import android.view.Menu;
import android.widget.VideoView;
public class MainActivity extends Activity {
VideoView videoView ;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
videoView = (VideoView)this.findViewById(R.id.videoView1);
Uri uri = Uri.parse(Environment.getExternalStorageDirectory().getPath()+"/Movies/run_to_you.3gp");
//Log.d(ALARM_SERVICE, Environment.getExternalStorageDirectory().getPath());
videoView.setVideoURI(uri);
videoView.start();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}
运行结果截图:
接下来贴出main.xml的源码:
[html] view
plaincopy
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<VideoView
android:id="@+id/videoView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
接下来贴出程序源码:
[java] view
plaincopy
package com.example.mpy;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.app.Activity;
import android.view.Menu;
import android.widget.VideoView;
public class MainActivity extends Activity {
VideoView videoView ;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
videoView = (VideoView)this.findViewById(R.id.videoView1);
Uri uri = Uri.parse(Environment.getExternalStorageDirectory().getPath()+"/Movies/run_to_you.3gp");
//Log.d(ALARM_SERVICE, Environment.getExternalStorageDirectory().getPath());
videoView.setVideoURI(uri);
videoView.start();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}
运行结果截图:
相关文章推荐
- Android多媒体开发【2】-- 利用VideoView开发最简单的视频播放器
- Android多媒体开发【1】-- 利用SurfaceView + MediaPlayer开发最简单的视频播放器
- Android多媒体开发【1】-- 利用SurfaceView + MediaPlayer开发最简单的视频播放器
- Android:利用VideoView实现视频播放器
- Android开发06_VideoView、SurfaceView两种视频播放器
- 【Android开发】多媒体应用开发-使用VideoView播放视频
- Android_利用SurfaceView + MediaPlayer开发最简单的播放器
- 【Android游戏开发十六】Android Gesture之【触摸屏手势识别】操作!利用触摸屏手势实现一个简单切换图片的功能!
- 【Android2D游戏开发十八】解放手指,利用传感器开发游戏!(本文讲解在SurfaceView中用重力传感器控制圆球的各方向移动)
- Android利用WebView开发browser中flash无法播放的问题
- 【Android游戏开发十六】Android Gesture之【触摸屏手势识别】操作!利用触摸屏手势实现一个简单切换图片的功能!
- android应用开发全程实录-用户界面部分章节-你真的会用最简单的TextView么?
- Android腾讯微博客户端开发5:利用FootView实现ListView滑动动态加载实现分页
- Android利用WebView开发Web App
- 27、从头学Android之多媒体--使用VideoView播放视频
- Android的NDK开发(2)————利用Android NDK编写一个简单的HelloWorld
- 【Android游戏开发十八】解放手指,利用传感器开发游戏!(本文讲解在SurfaceView中用重力传感器控制圆球的各方向移动)
- 【Android游戏开发十八】解放手指,利用传感器开发游戏!(本文讲解在SurfaceView中用重力传感器控制圆球的各方向移动)
- android应用开发全程实录-用户界面部分章节-你真的会用最简单的TextView么? 推荐
- 【Android游戏开发十八】解放手指,利用传感器开发游戏!(本文讲解在SurfaceView中用重力传感器控制圆球的各方向移动)