android学习之视频播放
来源:互联网 发布:2016年网络搜索话题 编辑:程序博客网 时间:2024/05/17 06:54
果断这几篇文章都是写的多媒体的,这篇文章就谈谈如果使用VideoView来播放视频,其实感觉和播放音乐差不多的,直接贴代码,因为感觉也蛮简单的,对了,,在后面我继承了VideoView写了一个自己的VideoView,这样我们方便设置Video来适配自己的屏幕。
package com.example.videoviewdemo;import android.net.Uri;import android.os.Bundle;import android.app.Activity;import android.view.Menu;import android.widget.MediaController;import android.widget.VideoView;public class MainActivity extends Activity {// declar a VideoViewprivate VideoView myVideoView;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);myVideoView = (VideoView) findViewById(R.id.my_video);// get the pathString path = "/sdcard/fcar.3gp";// set the path for VideoViewmyVideoView.setVideoPath(path);// Uri// MyUri=Uri.parse("android.resource://"+getPackageName()+"/"+R.raw.aa);// myVideoView.setVideoURI(MyUri);// MediaController is used for us to control the progressMediaController mc = new MediaController(this);// bind the MediaController with the VideoViewmyVideoView.setMediaController(mc);// get the focusmyVideoView.requestFocus();// play the VideomyVideoView.start();}}package com.example.videoviewdemo;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.VideoView;
public class MyVideoView extends VideoView {
// those three constructor will be use for the different way to create view
public MyVideoView(Context context) {
super(context);
// TODO Auto-generated constructor stub
}
public MyVideoView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
// TODO Auto-generated constructor stub
}
public MyVideoView(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
// TODO Auto-generated method stub
// measure the width of the screen
int width = getDefaultSize(0, widthMeasureSpec);
// measure the height of the screen
int height = getDefaultSize(0, heightMeasureSpec);
// set the size that we use to play the video
setMeasuredDimension(width, height);
}
}
0 0
- android学习之视频播放
- Android视频播放器之学习MediaPlayer
- Android学习之二:视频播放器
- Android学习之MediaPlayer视频播放
- Android之视频播放
- android之视频播放
- android之播放视频
- android 之 视频播放
- Android应用开发学习笔记之播放视频
- OpenCV学习之播放视频
- Android视频播放学习笔记
- android之视频播放器
- Android开发之视频播放
- Android之VideoView播放视频
- Android之VideoView播放视频
- Android之VideoView播放视频
- Android开发之播放视频
- Android视频播放之MediaPlayer
- 广播和自定义广播事件
- Core Animation - CATextLayer和富文本
- 状态栏一体化及其带来的软键盘自适应问题(二)
- Java使用Protocol Buffers入门四步骤
- MFC检测网络连接和ping IP地址
- android学习之视频播放
- Xcode调试方法
- Swift笔记:类和结构体
- Java泛型的理解
- 如何修改MySQL监听IP地址
- Android 银行卡扫描识别获取卡号
- Centos 搭建NFS
- Qt5.3.2在ARM-Linux平台的移植
- [HDU 4565] So Easy! (数学)