使用VideoView播放、暂停、快进视频
<FrameLayout 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"
tools:context="com.example.videoview.MainActivity" > <VideoView
android:id="@+id/videoView"
android:layout_width="match_parent"
android:layout_height="416dp" /> <LinearLayout
android:id="@+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:orientation="horizontal" > <Button
android:id="@+id/start"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="开始" /> <Button
android:id="@+id/pause"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="暂停" /> <Button
android:id="@+id/seekto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="3秒处" />
</LinearLayout> </FrameLayout>
activity_main.xml
测试主代码:
package com.example.videotest; import java.io.File; import android.app.Activity;
import android.os.Bundle;
import android.os.Environment;
import android.provider.MediaStore.Video;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.VideoView; public class MainActivity extends Activity implements OnClickListener { private VideoView videoView; @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); videoView = (VideoView) findViewById(R.id.videoView); File path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM); File f = new File(path, "/Camera/test.mp4"); videoView.setVideoPath(f.getAbsolutePath()); Button start = (Button) findViewById(R.id.start);
start.setOnClickListener(this);
Button pause = (Button) findViewById(R.id.pause);
pause.setOnClickListener(this);
Button seekto = (Button) findViewById(R.id.seekto);
seekto.setOnClickListener(this); } @Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.start:
videoView.start();
break;
case R.id.pause:
videoView.pause();
break;
case R.id.seekto:
videoView.seekTo(3*1000);
break;
}
} }
使用VideoView播放、暂停、快进视频的更多相关文章
- JS控制Video播放器(快进、后退、播放、暂停、音量大小)
思路: 一.首先监听触发事件. 比如:向上键对应的keyCode为38,向下键对应的keyCode为40,向左键对应的keyCode为37,向右键对应的keyCode为39,空格键对应的keyCode ...
- 关于jwplayer 处理进度条禁止快进的处理方法。
今天在处理一个关于jwplayer 第一次播放禁止快进,但是可以后退的一个需求.开始在网上去查一些方法,有几个方法是换皮肤,禁止点击,但是和我的初衷不是很一致,还有一种方式是官网查看了API接口的方 ...
- MediaElement视频控制:播放、暂停、停止、后退、快进、跳转、音量
/* ================================================= * Author: Micro * Date: 2016=03-25 ...
- Android--使用VideoView播放视频
承香墨影 Android--使用VideoView播放视频 前言 之前有讲过如何使用SurfaceView配合MediaPlayer播放视频,其实Android还为开发人员提供了另外一种更简单 ...
- Android 视频播放器 (一):使用VideoView播放视频
一.简介 作为Android开发,我们不可避免的会接触到视频播放,VideoView做为最简单的播放器,我们是不应该不会的. 下面简单介绍一下VideoView: VideoView是使用MediaP ...
- videoview 播放视频
-videoVIew 继承SurfaceView 使用android的VideoView来播放一个视频,步骤是: 1,在xml中创建一个videoView, 2,在java中导入,然后创建一个Medi ...
- Android开发之使用VideoView播放视频
Android提供了 VideoView组件.它的作用与ImageView类似,仅仅是ImageView用于显示图片.而VideoView用于播放视频. 使用VideoView播放视频的过程例如以下: ...
- html5 vedio 播放器,禁掉进度条快进快退事件
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- VideoView播放视频——Android
Android为开发人员提供了一种简单的播放视频媒体的方式,那就是VideoView,本篇博客就来讲讲VideoView如何播放视频,最后将以一个简单的Demo演示. VideoView VideoV ...
随机推荐
- 基于 Equinox 的 OSGi Console 的研究和探索
自定制 OSGi Console 进行组建和服务生命周期管理模块化编程的好处已经很好地被理解了约 40 年,但在 OSGi 之前,开发人员不得不自己发明模块化设计和系统.随着软件应用体系结构的不断发展 ...
- iOS中的网络请求 和 网络监测
1.网络监测 //根据主机名判断网络是否连接 Reachability *reach = [Reachability reachabilityWithHostName:@"www.baidu ...
- easyui window自动居中(修复了iframe弹窗被遮盖问题)
$.extend($.fn.window.defaults, { onOpen:function(left, top){ var iframeWidth = $(this).parent().pare ...
- uboot在s3c2440上的移植(1)
一.移植环境 主 机:VMWare--Fedora 9 开发板:Mini2440--64MB Nand,Kernel:2.6.30.4 编译器:arm-linux-gcc-4.3.2.tgz u-b ...
- Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
执行远程shell,启动远程机器的tomat时遇到次错误.后来发现原来是远程机器的.profile被人改掉了! 在.profile里加入 export JAVA_HOME=/home/evans/jd ...
- eclipse启动问题
今天在公司正上班,突然跳出来一个windows update补丁更新,然后就确认呗,结果更新完成之后, eclipse打不开了,启动报错: could not find the main class, ...
- .net4.0中使用ODP.net访问Oracle数据库(无需安装oracle客户端部署方法)
1.在没有安装oracle客户端的设备上也能访问服务器上的oracle (通俗的讲就是:开发的应用程序 和 oracle数据库服务器分别在两台电脑上)2.不需要配置TnsNames.Ora文件 开发环 ...
- Terminate program hitting CTRl+C within GDB
Q: My program is determined to stop its execution by hitting CTRL+C in command window. By now, i hav ...
- 转: Android入门及效率开发
评注: android第三方开源框架介绍不错 转:https://segmentfault.com/a/1190000004495351 入门 Android官方培训课程中文版:http://huka ...
- IT技术方案最佳实践方案的收集
一.图片鉴别服务 1. 阿里云,腾讯云等公开的服务. 2. 图谱科技提供的API 二. 网络直播服务器 1. SRS2 开源服务器 (https://github.com/ossrs/srs/wiki ...