as3.0视频的快进有拖动条
package com{
import flash.display.MovieClip;
import flash.events.MouseEvent;
import fl.video.FLVPlayback;
import fl.video.MetadataEvent;
import flash.events.AsyncErrorEvent;
import flash.net.NetConnection;
import flash.net.NetStream;
import flash.media.Video;
import flash.utils.Timer;
import flash.events.TimerEvent;
import fl.video.VideoPlayer;
import flash.media.SoundTransform;
import flash.display.SimpleButton;
import flash.geom.Rectangle; public class MyFlv extends MovieClip { private var dragMc:MovieClip;
private var lineMc:MovieClip;
private var backBtn:SimpleButton;
private var stageMc:Object;
private var emptyMc:MovieClip;
private var progressMc:MovieClip; private var bounds:Rectangle; private var lineMcWidth:Number;
private var lineMcX:Number;
private var mcN:uint; //private var mm:MyMusic=new MyMusic(); public function MyFlv(_emptyMc:MovieClip) { emptyMc=_emptyMc;
//MyMusic.initialSound("看一看");
}
public function FlvFun(_dragMc:MovieClip ,_lineMc:MovieClip ,_stageMc:Object ,_progressMc:MovieClip ){ progressMc=_progressMc;
dragMc=_dragMc;
lineMc=_lineMc;
stageMc=_stageMc; lineMcX=lineMc.x;
bounds=new Rectangle(lineMc.x,lineMc.y,lineMc.width,0); dragMc.buttonMode=true;
dragMc.addEventListener(MouseEvent.MOUSE_DOWN,dragFun);
dragMc.addEventListener(MouseEvent.MOUSE_UP,dragFun);
stageMc.addEventListener(MouseEvent.MOUSE_UP,dragFun); }
private function dragFun(e:MouseEvent):void {
if (e.type=="mouseDown") {
e.target.startDrag(false,bounds);
dragMc.addEventListener(MouseEvent.MOUSE_MOVE,dragFun);
timer.stop();
} else if (e.type=="mouseUp") {
stopDrag();
timer.start();
dragMc.removeEventListener(MouseEvent.MOUSE_MOVE,dragFun);
} else if (e.type=="mouseMove") { vidProgressNum=vidTotalTime*(dragMc.x-lineMc.x)/lineMc.width ;
ns.seek(vidProgressNum); var i:int=progressMc.totalFrames*(dragMc.x-lineMc.x)/lineMc.width;
progressMc.gotoAndStop(i);
}
} //video=====================================================
private var videoPath:String;
private var vid:VideoPlayer;
private var timer:Timer=new Timer(25);
private var vidNowTime:Number;
private var vidTotalTime:Number;
private var vidProgressNum:Number; private var nc:NetConnection;
public var ns:NetStream;
private var soundTF:SoundTransform; private var obj:Object =new Object (); public function VideoFun() { vid=new VideoPlayer(1435.55,808.4);
vid.x=241
vid.y=205.4
vid.smoothing=true;
nc= new NetConnection();
nc.connect(null);
ns=new NetStream(nc); ns.play("sdfsd.mp4");
vidTotalTime=vid.totalTime;
vid.attachNetStream(ns);
//ns.pause();
ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler); function asyncErrorHandler(event:AsyncErrorEvent):void {
// 忽略错误
} obj.onMetaData=onMetaData;
ns.client=obj;
function onMetaData(data:Object):void {
vidTotalTime=data.duration;
}
emptyMc.addChild(vid);
timer.addEventListener(TimerEvent.TIMER,tiemrFun);
//timer.start(); //声音=========================
//soundTF=ns.soundTransform;//控制的目标
//soundTF.volume=0;//设置目标的声音为0
//ns.soundTransform=soundTF; }
private function tiemrFun(e:TimerEvent) { vidNowTime=ns.time;
dragMc.x = (lineMc.width) * vidNowTime / vidTotalTime + (lineMc.x); var i:int=progressMc.totalFrames*(dragMc.x-lineMc.x)/lineMc.width;
progressMc.gotoAndStop(i);
} //================togglePause
private var togglePause:SimpleButton;
public function togglePauseFun(_togglePause:SimpleButton) {
togglePause=_togglePause;
togglePause.alpha=1;
togglePause.addEventListener(MouseEvent.CLICK,ontogglePause);
}
private function ontogglePause(e:MouseEvent) {
//MyMusic.pauseFuntion()
//MyMusic.isSoundPlay=false
if (togglePause.alpha==0) {
togglePause.alpha=1;
} else {
togglePause.alpha=0;
}
ns.togglePause();
} //===============up.down
private var nextBtn:SimpleButton;
private var prevBtn:SimpleButton;
public function nextOrPrev(_nextBtn:SimpleButton,_prevBtn:SimpleButton) {
prevBtn=_prevBtn;
nextBtn=_nextBtn;
nextBtn.addEventListener(MouseEvent.CLICK,onBtn);
prevBtn.addEventListener(MouseEvent.CLICK,onBtn);
}
private function onBtn(e:MouseEvent) {
if (e.target.name=="nextBtn") {
ns.seek(vidNowTime+=5);
} else {
ns.seek(vidNowTime-=5);
}
} public function backFun(_backBtn:SimpleButton ) {
backBtn=_backBtn;
backBtn.addEventListener(MouseEvent.CLICK ,backBtnFun);
}
public function backBtnFun(e:MouseEvent ) {
timer.removeEventListener(TimerEvent.TIMER,tiemrFun);
dragMc.removeEventListener(MouseEvent.MOUSE_MOVE,dragFun);
dragMc.removeEventListener(MouseEvent.MOUSE_DOWN,dragFun);
dragMc.removeEventListener(MouseEvent.MOUSE_UP,dragFun);
stageMc.removeEventListener(MouseEvent.MOUSE_UP,dragFun);
emptyMc.removeChild(vid);
}
}
}//ns.close();
as3.0视频的快进有拖动条的更多相关文章
- jwplayer 禁止视频的快进,但是可以后退(已实现)
一直在研究.net 的视频播放,最近做起了jwplayer,然后项目要求是视频不能快进,但是可以重复观看已经看过的视频资源. 很简单 在标签<script> 中定义两个变量 var max ...
- As3.0 视频缓冲、下载总结
来源:http://www.cuplayer.com/player/PlayerCodeAs/2012/0913404.html 利用NetStream的以下属性: bufferTime — 缓冲区大 ...
- 修改CKplayer.js 源码解决移动端浏览器全屏不能限制快进的问题
原文地址:https://www.cnblogs.com/jying/p/9642445.html,转载请说明出处. 最近项目需要播放视频且限制未观看部分的快进功能,找了两款js插件ckplayer和 ...
- MediaElement视频控制:播放、暂停、停止、后退、快进、跳转、音量
/* ================================================= * Author: Micro * Date: 2016=03-25 ...
- 解决 Asp.Net5 在视频文件下载预览时无法快进的问题
前情提要 https://www.cnblogs.com/puzhiwei/p/15265005.html 在解决.Net5 如何修改Content-Disposition实现在线预览的功能后,我又遇 ...
- video字幕无法显示,video视频在google中无法控制快进
video字幕(track)无法显示: 直接用关闭同源策略的浏览器打开你的HTML文件可以请求到字幕文件并显示字幕: 从hbuilder中打开html文件,在从里面打开google浏览器去浏览HTML ...
- “AS3.0高级动画编程”学习:第一章高级碰撞检测
AdvancED ActionScript 3.0 Animation 是Keith Peters大师继"Make Things Move"之后的又一力作,网上已经有中文翻译版本了 ...
- 关于jwplayer 处理进度条禁止快进的处理方法。
今天在处理一个关于jwplayer 第一次播放禁止快进,但是可以后退的一个需求.开始在网上去查一些方法,有几个方法是换皮肤,禁止点击,但是和我的初衷不是很一致,还有一种方式是官网查看了API接口的方 ...
- android开发之GestureDetector手势识别(调节音量、亮度、快进和后退)
写UI布局: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:andro ...
随机推荐
- UE常用快捷键使用
进入列模式Alt+c 小写转大写Alt+F5
- 利用STM32CubeMX来生成USB_HID_host工程
修改时钟(备注这边使用25mhz的主晶振) 选择debug_level等级为3
- Vue.js Failed to resolve filter: key
转自:https://stackoverflow.com/questions/35835214/vue-js-failed-to-resolve-filter-key I am following t ...
- linux 源码编译php的参数
./configure --prefix=/usr/local/php-5.3.5 --with-config-file-path=/usr/local/php-5.3.5/etc --with-co ...
- 反射机制(java)
反射机制 反射机制可通过在运行时加载类名而获取类,并对其进行操作.工厂模式,动态代理中较常用到. 在实际场景中:由于有好多类具有共同的接口样式,而他们又用的不是很频繁,如果在服务器中保有这些类会占用资 ...
- WDA-2-事件执行先后
WebDynpro 中事件执行顺序 一:WebDynpro 启动时的 hokeMethod 执行顺序 (这里观察一个 view)从上至下,依次进行 如果这个 view 上还有一个 button(能触发 ...
- Leetcode 题解 Jump Game
一,笨方法 o(n^2).果然看完别人的解法就自惭形秽啊!! 我用的动态规划方法. 比如输入 i: 0 1 2 3 4 ———————————————— a[i]: 2 3 1 0 4 直接利用原来 ...
- 伪AJAX
<h3>3,伪ajax</h3> <h6>学习iframe(嵌套别人家网站的)</h6> <div> <input id=" ...
- Django 之Form
具体可参考:http://www.liujiangblog.com/course/django/153 https://www.cnblogs.com/liuguniang/p/7141837.htm ...
- 基于官方镜像MySQL做自定义业务扩充镜像
转自:https://www.cnblogs.com/jsonhc/p/7809571.html 首先从https://hub.docker.com/_/mysql/拉取官方镜像,如果速度缓慢,建议添 ...