手机影音4--视频播放器的基本功能(1)
2016-11-13 18:13
218 查看
1 <LinearLayout 2 android:id="@+id/ll_bottom" 3 android:layout_width="match_parent" 4 android:layout_height="wrap_content" 5 android:layout_alignParentBottom="true" 6 android:orientation="vertical"> 7 8 <LinearLayout 9 android:layout_width="match_parent" 10 android:layout_height="wrap_content" 11 android:background="@drawable/bg_player_bottom_seekbar" 12 android:gravity="center_vertical" 13 android:orientation="horizontal"> 14 15 <TextView 16 android:id="@+id/tv_current_time" 17 android:layout_width="wrap_content" 18 android:layout_height="wrap_content" 19 android:layout_marginLeft="8dp" 20 android:text="0:00" 21 android:textColor="#ffffff" /> 22 23 <SeekBar 24 android:id="@+id/seekbar_video" 25 android:layout_width="match_parent" 26 android:layout_height="wrap_content" 27 android:layout_marginLeft="8dp" 28 android:layout_marginRight="8dp" 29 android:layout_weight="1" 30 android:maxHeight="6dp" 31 android:minHeight="6dp" 32 android:progressDrawable="@drawable/progress_horizontal" 33 android:thumb="@drawable/progress_thumb" /> 34 35 <TextView 36 android:id="@+id/tv_duration" 37 android:layout_width="wrap_content" 38 android:layout_height="wrap_content" 39 android:layout_marginRight="8dp" 40 android:text="20:00" 41 android:textColor="#ffffff" /> 42 43 </LinearLayout> 44 45 46 <LinearLayout 47 android:layout_width="match_parent" 48 android:layout_height="wrap_content" 49 android:background="@drawable/bg_player_bottom_control" 50 android:gravity="center_vertical" 51 android:orientation="horizontal"> 52 53 <Button 54 android:id="@+id/btn_exit" 55 android:layout_width="wrap_content" 56 android:layout_height="wrap_content" 57 android:layout_weight="1" 58 android:background="@drawable/btn_exit_selector" /> 59 60 <Button 61 android:id="@+id/btn_video_pre" 62 android:layout_width="wrap_content" 63 android:layout_height="wrap_content" 64 android:layout_weight="1" 65 android:background="@drawable/btn_video_pre_selector" /> 66 67 <Button 68 android:id="@+id/btn_video_start_pause" 69 android:layout_width="wrap_content" 70 android:layout_height="wrap_content" 71 android:layout_weight="1" 72 android:background="@drawable/btn_video_pause_selector" /> 73 74 <Button 75 android:id="@+id/btn_video_next" 76 android:layout_width="wrap_content" 77 android:layout_height="wrap_content" 78 android:layout_weight="1" 79 android:background="@drawable/btn_video_next_selector" /> 80 81 <Button 82 android:id="@+id/btn_video_siwch_screen" 83 android:layout_width="wrap_content" 84 android:layout_height="wrap_content" 85 android:layout_weight="1" 86 android:background="@drawable/btn_video_siwch_screen_full_selector" /> 87 </LinearLayout> 88 89 </LinearLayout>
View Code
4.视频seekBar进度更新
1.视频的总时长和SeekBar的setMaxt(总时长); 注意:准备好了的回调后
2.实例化Handler,每秒得到当前视频播放进度,SeekBar.setProgress(当前进度);
int duration = videoview.getDuration(); //把毫秒转换成 12:22.40 tv_duration.setText(utils.stringForTime(duration)); //设置视频的总长度为video_seekBar的多少等分 video_seekBar.setMax(duration); //发消息开始更新 handler.sendEmptyMessage(PROGRESS);
5.实现视频的拖动
video_seekBar.setOnSeekBarChangeListener(newOnSeekBarChangeListener() { //手指停止滑动的时候回调 @Override public void onStopTrackingTouch(SeekBar seekBar) { } //手指刚开始滑动的时候回调 @Override public void onStartTrackingTouch(SeekBar seekBar) { } //手指滑动状态发送变化的时候回调 @Override public void onProgressChanged(SeekBar seekBar, int progress,booleanfromUser) { if(fromUser){ // seekBar.setProgress(progress); videoview.seekTo(progress); } } });
相关文章推荐
- 手机影音6--视频播放器的基本功能(3)
- 手机影音8--视频播放器的高级功能(1)
- 手机影音9--视频播放器的高级功能(2)
- JavaScript HTML5 手机版手机版网站起码要实现一些基本的功能吧:
- 编写一个通讯录,功能与以前的诺基亚手机一样,可以通过键盘进行箭头的移动,回车进入选项,用“W”键代表手机手机左键,“backspace”键代表返回上一级。能够实现基本的人性化的增删改查及文件的导入导出
- 诺基亚塞班S60智能手机三大热门手机炒股软件评测-4、基本功能
- JavaScript HTML5 手机网站 基本功能
- 手机影音7--视频播放器的基本功能(4)
- 手机影音最终,软件退出功能的优化
- JavaScript HTML5 手机网站 基本功能
- 手机影音5--视频播放器的基本功能(2)
- 手机网页调用手机基本功能
- 手机影音第七天 视频的播放下一个视频功能实现,视频进度、电量变化的实现
- 封装了手机与服务器的数据交互的基本功能类
- JavaScript HTML5 手机网站 基本功能
- 用AVFoundation的AVPlayer做的一个小视频播放器,包含左滑快退,右滑快进,上滑音量加,下滑音量减等基本功能。
- 手机垃圾短信功能设想
- 完成MyJFrame的基本功能
- 基于SVG技术实现WebGIS的基本功能(1)
- 手机惊曝最新功能65分钟将生鸡蛋煮熟