Android视频播放器代码Word格式.docx

上传人:b****5 文档编号:15841279 上传时间:2022-11-16 格式:DOCX 页数:22 大小:20.88KB
下载 相关 举报
Android视频播放器代码Word格式.docx_第1页
第1页 / 共22页
Android视频播放器代码Word格式.docx_第2页
第2页 / 共22页
Android视频播放器代码Word格式.docx_第3页
第3页 / 共22页
Android视频播放器代码Word格式.docx_第4页
第4页 / 共22页
Android视频播放器代码Word格式.docx_第5页
第5页 / 共22页
点击查看更多>>
下载资源
资源描述

Android视频播放器代码Word格式.docx

《Android视频播放器代码Word格式.docx》由会员分享,可在线阅读,更多相关《Android视频播放器代码Word格式.docx(22页珍藏版)》请在冰豆网上搜索。

Android视频播放器代码Word格式.docx

importandroid.view.SurfaceView;

importandroid.view.View;

importandroid.view.Window;

importandroid.view.WindowManager;

importandroid.view.View.OnClickListener;

importandroid.view.View.OnTouchListener;

importandroid.widget.ImageButton;

importandroid.widget.LinearLayout;

importandroid.widget.LinearLayout.LayoutParams;

importandroid.widget.PopupWindow;

importandroid.widget.SeekBar;

importandroid.widget.SeekBar.OnSeekBarChangeListener;

importandroid.widget.TextView;

importandroid.widget.Toast;

publicclassPlayVideoextendsActivityimplements

OnGestureListener,

OnClickListener,//监听

OnBufferingUpdateListener,//当网络缓冲数据流变化的时候唤起的播放事件

OnCompletionListener,//当媒体资源在播放的时候到达终点时唤起的播放事件

MediaPlayer.OnPreparedListener,

SurfaceHolder.Callback//回调函数

{

//视频高和宽

intvideoWidth;

intvideoHeight;

//按钮

ImageButtonplay;

//定义快进按钮

ImageButtonfastPlay;

//定义快退按钮

ImageButtonfastBack;

//控制栏

LinearLayoutlayout_control;

LinearLayoutlayout_prograss;

LinearLayoutvideoBack;

//用来播放媒体

MediaPlayermediaPlayer;

//显示媒体

SurfaceViewsurView;

//用来控制SurfaceView

SurfaceHoldersurHolder;

//路径

Stringpath;

//是否是播放状态

booleanboTing=true;

//获取播放的位置

intnum;

//点击屏幕次数

intcount;

//第一次点击

intfirClick;

//第二次点击

intsecClick;

//通过flag判断是否全屏

booleanflag;

//播放进度条

SeekBarseekbar;

//显示时间组建

TextViewshowTime;

//播放文件的时间

intminute;

intsecond;

//进度条进度

intprogress;

//线程控制

MyThreadmt;

//声音控制

SeekBarsound;

//声音进度

intsoundId;

//显示音量

TextViewshowSound;

//接取拖动进度条

intvideoLength;

booleanf=true;

//播放尺寸

//按钮隐藏时间

inthint=5000;

//用于接取点击ListView位置

intposition;

//声称随机数

Randomrandom;

//通过buttonFlag判断按钮背景

booleanbuttonFlag=true;

//显示视频总时间

TextViewallTime;

TextViewdistant;

PopupWindowpopuWindow;

Viewview;

booleanpopFlag;

publicvoidonCreate(BundlesavedInstanceState){

super.onCreate(savedInstanceState);

requestWindowFeature(Window.FEATURE_NO_TITLE);

this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,

WindowManager.LayoutParams.FLAG_FULLSCREEN);

setContentView(R.layout.video);

//产生对象

view=this.getLayoutInflater().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=surView.getHolder();

popuWindow=newPopupWindow(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=newRandom();

//接取到播放列表中点击的位置

position=VideoList.position;

try{

//获取ShareActivity上下文

VideoList.context=createPackageContext("

.iotek"

Context.CONTEXT_IGNORE_SECURITY);

VideoList.share=VideoList.context.getSharedPreferences("

setupadapter"

VideoList.context.MODE_WORLD_READABLE);

VideoList.editor=VideoList.share.edit();

}catch(NameNotFoundExceptione){

e.printStackTrace();

}

//对读取的信息进行判断

if(VideoList.share.getString("

hinttime"

"

5秒"

).equals("

)){

hint=5000;

}

10秒"

hint=10000;

15秒"

hint=15000;

//设置全屏播放

surView.setOnTouchListener(newOnTouc

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 初中教育 > 数学

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1