el Original lo publique en DesignerMx
Ejemplo video
Iniciaremos con lo siguiente creamos una instancia de video, esto se logra importando un video a tu biblioteca, y te aparece un iconode video, lo arrastras al escenario y tendras tu instancia, la nombramos mi_video.
Creamos una clip con nombre de instancia controles y dentro de el creamos dos botones para el volumen y un campo de texto llamado volumen.
OJO el video nose verá cuando lo abrimos directamente en flash, o sea cuando le das CTRL+ENTERo CMD+ENTER,lo veras cuando lo exportes con un html, solo es visible en navegadores, y si no lo ves solo instala el plugin de flash en su ultima version
El código sera el siguiente:
Código :
//Código con el que cargaremos el video .mov
//cargamos la pelicula en formato.mov en este caso se llama peli
var URLvideo:String = "peli.mov";
var duracion:Number = 0;
var ancho:Number = 0;
var alto:Number = 0;
var anchoInicial:Number = Stage.width;
var anchoMax:Number = System.capabilities.screenResolutionX;
var escuchador:Object = new Object();
var escala:Number = 100;
datos_txt.html = true;
datos_txt.wordWrap = true;
//asignamos la posicion para los datos
datos_txt._x = datos_txt._y=10;
var mi_nc:NetConnection = new NetConnection();
mi_nc.connect(null);
var stream_ns:NetStream = new NetStream(mi_nc);
stream_ns.setBufferTime(10);
mi_video.attachVideo(stream_ns);
mi_video.smoothing = true;
//asignamos posicion para los controles
controles._y = (mi_video._y+mi_video._height + 20);
controles._x = (mi_video._x+10);
mi_video._x = (20);
mi_video._y = (Stage.height/2)-(mi_video._height/2);
stream_ns.play(URLvideo);
stream_ns.onMetaData = function(infoObject:Object) {
duracion = Number(Math.floor(infoObject.duration));
ancho = Number(Math.floor(infoObject.width));
alto = Number(Math.floor(infoObject.height));
};
var bufferInterval:Number = setInterval(checkBufferTime, 100, stream_ns);
//función para obtener la información del video
function checkBufferTime(stream_ns:NetStream):Void {
var bufferPorc:Number = Math.min(Math.round(stream_ns.bufferLength/stream_ns.bufferTime*100), 100);
datos_txt.htmlText = "<font color='#FF0000'><b>Datos de carga</b></font>";
datos_txt.htmlText += "<b>Tiempo de buffer: </b>"+stream_ns.bufferTime+"''";
datos_txt.htmlText += "<b>Porcentaje en buffer: </b> "+bufferPorc+"%";
datos_txt.htmlText += "<b>FPS: </b>"+Math.floor(stream_ns.currentFps);
datos_txt.htmlText += "<b>Segundos transcurridos: </b>"+Math.floor(stream_ns.time)+"'' de "+duracion+"''";
datos_txt.htmlText += "<b>Ancho: </b>"+ancho+"px | <b>Alto: </b>"+alto+"px";
}
escuchador.onResize = function() {
escala = Math.floor((Stage.width/848)*100);
if (Stage.displayState == "normal") {
mi_video._width = ancho;
mi_video._height = alto;
} else {
mi_video._width = (ancho*escala)/100;
mi_video._height = (alto*escala)/100;
}
reacomodar();
};
Stage.addListener(escuchador);
///cuando escalemos el html el video y los controles se escalaran y reposicionaran
function reacomodar() {
controles._y = (mi_video._y+mi_video._height + 10);
controles._x = (mi_video._x + 10);
full_btn._x = Stage.width-(full_btn._width+10);
full_btn._y = 10;
mi_video._x = (Stage.width/2)-(mi_video._width/2);
mi_video._y = (Stage.height/2)-(mi_video._height/2);
}
//Código que controlara el volumen del video:
s1 = new Sound();
var sonido_actual = "s1";
var tiempo_actual = 1;
var ejecutando = 0;
tiempo.restrict = "0-9";
this.onEnterFrame = function() {
if (ejecutando == 1) {
total = Math.floor(eval(sonido_actual).duration/1000);
duracion = Math.floor(eval(sonido_actual).position/1000);
}
};
//Botón para bajar el volumen
on (press) {
if (vol>=10) {
vol = Number(vol)-10;
eval(sonido_actual).setVolume(vol);
barra_mc.gotoAndStop(vol/5);
}
}
//Botón para subir el volumen
on (press) {
if (vol<=90) {
vol = Number(vol)+10;
eval(sonido_actual).setVolume(vol);
barra_mc.gotoAndStop(vol/5);
}
}
Los archivos se encuentran aqui
