Cita:
import flash.net.NetConnection;
import flash.net.NetStream;
import flash.media.Video;
import flash.media.SoundTransform;
var videoURL:String = "http://localhost/hasit/videos/Robotica.flv";
var conexion:NetConnection = new NetConnection();
conexion.connect(null);
var stream:NetStream = new NetStream(conexion);
stream.play(videoURL);
var video:Video = new Video();
video.height = 210;
video.width = 270;
video.x = (stage.stageWidth - video.width) / 2;
video.y = stage.stageHeight-245;
var obj:Object = new Object();
stream.client = obj;
obj.onMetaData = MetaData;
video.attachNetStream(stream);
var sound:SoundTransform = new SoundTransform();
stream.soundTransform = sound;
addChild(video);
var duracion:uint;
function MetaData(info:Object){
duracion = info.duration;
}
function Ahora(event){
var secNow:Number = Math.round(stream.time);
var secTotal:Number = Math.floor(duracion);
var reproducido:Number = stream.time / secTotal;
var cargado:Number = stream.bytesLoaded / stream.bytesTotal;
buffer_mc.width = 150*cargado;
play_mc.width = 150*reproducido;
display_txt.text = Conversor(secNow) + " | " + Conversor(secTotal);
buffer_mc.addEventListener(MouseEvent.CLICK, Seek1);
play_mc.addEventListener(MouseEvent.CLICK, Seek2);
}
this.addEventListener(Event.ENTER_FRAME,Ahora);
function Seek1(event){
var lugar = buffer_mc.mouseX;
stream.seek(duracion*lugar);
}
function Seek2(event){
var lugar = buffer_mc.mouseX;
stream.seek(duracion*lugar);
}
function Pausar(event){
stream.togglePause();
if(toogle_btn.currentFrame == 1){
toogle_btn.gotoAndStop(2);
}else if(toogle_btn.currentFrame == 2){
toogle_btn.gotoAndStop(1);
}
}
toogle_btn.addEventListener(MouseEvent.CLICK, Pausar);
var volMin:Number = 0;
var volMax:Number = barraVol_mc.barra_mc.width;
var volAct:Number = 1;
var volPorc:Number;
function Mute(event){
if(speaker_mc.currentFrame == 1){
sound.volume = volMin;
stream.soundTransform = sound;
speaker_mc.gotoAndStop(2);
}else if(speaker_mc.currentFrame == 2){
sound.volume = volAct;
stream.soundTransform = sound;
speaker_mc.gotoAndStop(1);
}
}
speaker_mc.addEventListener(MouseEvent.CLICK, Mute);
function Volumen(event){
barraVol_mc.boton_mc.x = barraVol_mc.barra_mc.mouseX;
volPorc = barraVol_mc.boton_mc.x / volMax;
if(barraVol_mc.boton_mc.x <= volMin){
barraVol_mc.boton_mc.x = volMin;
}else if(barraVol_mc.boton_mc.x >= volMax){
barraVol_mc.boton_mc.x = volMax;
}else if(speaker_mc.currentFrame == 1){
sound.volume = volPorc;
stream.soundTransform = sound;
}
}
function MouseDown(event){
stage.addEventListener(MouseEvent.MOUSE_MOVE, Volumen);
}
barraVol_mc.boton_mc.addEventListener(MouseEvent.M OUSE_DOWN, MouseDown);
function MouseUp(event){
stage.removeEventListener(MouseEvent.MOUSE_MOVE, Volumen);
}
stage.addEventListener(MouseEvent.MOUSE_UP, MouseUp);
function Conversor(tiempo):String{
var time = tiempo;
var min = Math.floor(tiempo/60);
var sec = tiempo-min*60
if(min < 10){
min = "0" + min;
}
if(sec < 10){
sec = "0" + sec;
}
var valConvertir = min + " : " + sec;
return valConvertir;
}
import flash.net.NetStream;
import flash.media.Video;
import flash.media.SoundTransform;
var videoURL:String = "http://localhost/hasit/videos/Robotica.flv";
var conexion:NetConnection = new NetConnection();
conexion.connect(null);
var stream:NetStream = new NetStream(conexion);
stream.play(videoURL);
var video:Video = new Video();
video.height = 210;
video.width = 270;
video.x = (stage.stageWidth - video.width) / 2;
video.y = stage.stageHeight-245;
var obj:Object = new Object();
stream.client = obj;
obj.onMetaData = MetaData;
video.attachNetStream(stream);
var sound:SoundTransform = new SoundTransform();
stream.soundTransform = sound;
addChild(video);
var duracion:uint;
function MetaData(info:Object){
duracion = info.duration;
}
function Ahora(event){
var secNow:Number = Math.round(stream.time);
var secTotal:Number = Math.floor(duracion);
var reproducido:Number = stream.time / secTotal;
var cargado:Number = stream.bytesLoaded / stream.bytesTotal;
buffer_mc.width = 150*cargado;
play_mc.width = 150*reproducido;
display_txt.text = Conversor(secNow) + " | " + Conversor(secTotal);
buffer_mc.addEventListener(MouseEvent.CLICK, Seek1);
play_mc.addEventListener(MouseEvent.CLICK, Seek2);
}
this.addEventListener(Event.ENTER_FRAME,Ahora);
function Seek1(event){
var lugar = buffer_mc.mouseX;
stream.seek(duracion*lugar);
}
function Seek2(event){
var lugar = buffer_mc.mouseX;
stream.seek(duracion*lugar);
}
function Pausar(event){
stream.togglePause();
if(toogle_btn.currentFrame == 1){
toogle_btn.gotoAndStop(2);
}else if(toogle_btn.currentFrame == 2){
toogle_btn.gotoAndStop(1);
}
}
toogle_btn.addEventListener(MouseEvent.CLICK, Pausar);
var volMin:Number = 0;
var volMax:Number = barraVol_mc.barra_mc.width;
var volAct:Number = 1;
var volPorc:Number;
function Mute(event){
if(speaker_mc.currentFrame == 1){
sound.volume = volMin;
stream.soundTransform = sound;
speaker_mc.gotoAndStop(2);
}else if(speaker_mc.currentFrame == 2){
sound.volume = volAct;
stream.soundTransform = sound;
speaker_mc.gotoAndStop(1);
}
}
speaker_mc.addEventListener(MouseEvent.CLICK, Mute);
function Volumen(event){
barraVol_mc.boton_mc.x = barraVol_mc.barra_mc.mouseX;
volPorc = barraVol_mc.boton_mc.x / volMax;
if(barraVol_mc.boton_mc.x <= volMin){
barraVol_mc.boton_mc.x = volMin;
}else if(barraVol_mc.boton_mc.x >= volMax){
barraVol_mc.boton_mc.x = volMax;
}else if(speaker_mc.currentFrame == 1){
sound.volume = volPorc;
stream.soundTransform = sound;
}
}
function MouseDown(event){
stage.addEventListener(MouseEvent.MOUSE_MOVE, Volumen);
}
barraVol_mc.boton_mc.addEventListener(MouseEvent.M OUSE_DOWN, MouseDown);
function MouseUp(event){
stage.removeEventListener(MouseEvent.MOUSE_MOVE, Volumen);
}
stage.addEventListener(MouseEvent.MOUSE_UP, MouseUp);
function Conversor(tiempo):String{
var time = tiempo;
var min = Math.floor(tiempo/60);
var sec = tiempo-min*60
if(min < 10){
min = "0" + min;
}
if(sec < 10){
sec = "0" + sec;
}
var valConvertir = min + " : " + sec;
return valConvertir;
}