Java代码部分:
import java.io.IOException;
import java.util.Random;
import android.app.Activity;
t.Context;
t.pm.PackageManager.NameNotFoundException;
dia.AudioManager;
dia.MediaPlayer;
dia.MediaPlayer.OnBufferingUpdateListener;
dia.MediaPlayer.OnCompletionListener;
import android.os.Bundle;
import android.os.Handler;
import android.view.GestureDetector.OnGestureListener;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.PopupWindow;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
import android.widget.TextView;
import android.widget.Toast;
public class PlayVideo extends Activity implements
OnGestureListener,
OnClickListener,// 监听
OnBufferingUpdateListener,// 当网络缓冲数据流变化的时候唤起的播放事件
OnCompletionListener,// 当媒体资源在播放的时候到达终点时唤起的播放事件
MediaPlayer.OnPreparedListener,
SurfaceHolder.Callback// 回调函数
{
// 视频高和宽
int videoWidth;
int videoHeight;
// 按钮
ImageButton play;
//定义快进按钮
ImageButton fastPlay;
//定义快退按钮
ImageButton fastBack;
// 控制栏
LinearLayout layout_control;
LinearLayout layout_prograss;
LinearLayout videoBack;
// 用来播放媒体
MediaPlayer mediaPlayer;
// 显示媒体
SurfaceView surView;
// 用来控制SurfaceView
SurfaceHolder surHolder;
// 路径
String path;
// 是否是播放状态
boolean boTing = true;
//获取播放的位置
int num;
//点击屏幕次数
int count;
//第一次点击
int firClick;
//第二次点击
int secClick;
//通过flag判断是否全屏短视频分享网站源码
boolean flag;
//播放进度条
SeekBar seekbar;
//显示时间组建
TextView showTime;
//播放文件的时间
int minute;
int second;
//进度条进度
int progress;
//线程控制
MyThread mt;
//声音控制
SeekBar sound;
//声音进度
int soundId;
//显示音量
TextView showSound;
//接取拖动进度条
int videoLength;
boolean f = true;
//播放尺寸
//按钮隐藏时间
int hint = 5000;
//用于接取点击ListView位置
int position;
//声称随机数
Random random;
//通过buttonFlag判断按钮背景
boolean buttonFlag = true;
//显示视频总时间
TextView allTime;
TextView distant;
PopupWindow popuWindow;
View view;
boolean popFlag ;
public void onCreate(Bundle savedInstanceState) {
Create(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
Window().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.video);
// 产生对象
view = LayoutInflater().inflate(R.layout.popuwindow, null);
//得到布局的ID
videoBack = (LinearLayout)view.findViewById(R.id.videoback);
// 产生对象
play = (ImageButton) view.findViewById(R.id.video_bu_bofang);
layout_control = (LinearLayout)findViewById(R.id.layout_control);
layout_prograss= (LinearLayout)findViewById(R.id.layout_prograss);
seekbar = (SeekBar)view.findViewById(R.id.seekbar);
showTime = (TextView)view.findViewById(R.id.showtime);
fastPlay = (ImageButton)view.findViewById(R.id.fastplay);
fastBack = (ImageButton)view.findViewById(R.id.fastback);
sound = (SeekBar)view.findViewById(R.id.sound);
showSound = (TextView)view.findViewById(R.id.showsound);
surView = (SurfaceView) findViewById(R.id.surfaceview_1);
allTime = (TextView)view.findViewById(R.id.alltime);
distant = (TextView)findViewById(R.id.distant);
surHolder = Holder();
popuWindow = new PopupWindow(view, LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT);
// 设置回调函数
surHolder.addCallback(this);
// 设置风格
surHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
//bu_boFang.setVisibility(View.INVISIBLE);
// 设置按键监听
play.setOnClickListener(this);
//快进监听
fastPlay.setOnClickListener(this);
//快退按钮监听
fastBack.setOnClickListener(this);
//new随机数对象
random = new Random();
//接取到播放列表中点击的位置
position = VideoList.position;
try {
//获取ShareActivity上下文
t = createPackageContext("cn.iotek", Context.CONTEXT_IGNORE_SECURITY);
VideoList.share = SharedPreferences("setupadapter", t.MODE_WORLD_READABLE);
VideoList.editor = VideoList.share.edit();
} catch (NameNotFoundException e) {
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论