-
//url del video, en este caso lo levantamos de apple
-
var URLvideo:String = "http://movies.apple.com/movies/disney/wall-e/wall-e-vignette_h480p.mov";
-
//definimos variables
-
var duracion:Number = 0;
-
var ancho:Number = 0;
-
var alto:Number = 0;
-
var anchoInicial:Number = Stage.width;
-
var anchoMax:Number = System.capabilities.screenResolutionX;
-
//escuchador para nuestro Stage
-
var escuchador:Object = new Object();
-
var escala:Number = 100;
-
//nuestro campo de texto y posicion
-
datos_txt.html = true;
-
datos_txt.wordWrap = true;
-
datos_txt._x = datos_txt._y=10;
-
//creamos un objeto para la recepcion del flujo de video
-
var mi_nc:NetConnection = new NetConnection();
-
mi_nc.connect(null);
-
//creamos un controlador para el video
-
var stream_ns:NetStream = new NetStream(mi_nc);
-
stream_ns.setBufferTime(10);
-
//
-
mi_video.attachVideo(stream_ns);
-
//suavizamos el video
-
mi_video.smoothing = true;
-
//posicionamos al centro de la pantalla el video
-
mi_video._x = (Stage.width/2)-(mi_video._width/2);
-
mi_video._y = (Stage.height/2)-(mi_video._height/2);
-
stream_ns.play(URLvideo);
-
//leemos la duracion del video, ancho y alto del video
-
stream_ns.onMetaData = function(infoObject:Object) {
-
duracion = Number(Math.floor(infoObject.duration));
-
ancho = Number(Math.floor(infoObject.width));
-
alto = Number(Math.floor(infoObject.height));
-
};
-
//calculamos buffer, tiempo, fps y segundos reproducidos
-
var bufferInterval:Number = setInterval(checkBufferTime, 100, stream_ns);
-
function checkBufferTime(stream_ns:NetStream):Void {
-
var bufferPorc:Number = Math.min(Math.round(stream_ns.bufferLength/stream_ns.bufferTime*100), 100);
-
datos_txt.htmlText = "<span style="color: #ff0000;"><strong><span style="text-decoration: underline;">ESTADISTICAS</span></strong></span>";
-
datos_txt.htmlText += "<strong>Tiempo de buffer: </strong>"+stream_ns.bufferTime+"''";
-
datos_txt.htmlText += "<strong>Porcentaje en buffer: </strong> "+bufferPorc+"%";
-
datos_txt.htmlText += "<strong>FPS: </strong>"+Math.floor(stream_ns.currentFps);
-
datos_txt.htmlText += "<strong>Segundos transcurridos: </strong>"+Math.floor(stream_ns.time)+"'' de "+duracion+"''";
-
datos_txt.htmlText += "<strong>Ancho: </strong>"+ancho+"px | <strong>Alto: </strong>"+alto+"px";
-
}
-
//accion para el boton pantalla completa
-
full_btn._x = Stage.width-(full_btn._width+10);
-
full_btn._y = 10;
-
full_btn.onRelease = function() {
-
Stage.displayState = Stage.displayState == "normal" ? "fullScreen" : "normal";
-
};
-
//acciones si se cambio el estado de la pantalla
-
escuchador.onResize = function() {
-
//porcentaje de escala para el video
-
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);
-
//reacomodar los elementos segun el estado de la pantalla
-
function reacomodar() {
-
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);
-
}