-
//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);
-
}
2nd Agosto, 2008 at 12:28 pm
¿Que hay que tener en el escenario? ¿un componente de video?¿de que tipo?. Tengo instalado Flash Player 10 y no consigo ver el video aunque si oigo el sonido.
3rd Agosto, 2008 at 10:11 pm
Como veras en el ejemplo se coloca un video linqueado creado en la galeria y por medio de las clases netstream y netconnetion se hace que se pueda reproducir el video, pero tu problema debe estar en la versión de flash player que usas, ya que la 10 es una beta
23rd Agosto, 2008 at 3:44 pm
[...] Fuente: Leo Baraldi http://www.leobaraldi.com.ar/2008/04/06/video-h264-o-de-alta-definicion-hd-en-flash-player-9/ [...]
10th Septiembre, 2008 at 1:44 pm
Antes que nada Gracias Leo, por estos codigos que me facilitaron mucho poner videos en mi web, pero estoy intentando sumarle a este codigo de videos h264 un preloader y un controlador y todo lo que intente no me funciono... alguna idea de como sumarle esos dos temitas?
Gracias de antemano
11th Septiembre, 2008 at 1:38 pm
Hola Esteban, si te fijas ya esa funcionalidad esta puesta en esta funcion checkBufferTime()
como veras solo lo que hace es imprimir el tiempo de buffer que cargo del vídeo, lo que puedes hacer es mostrarlos en una barra o un iconito que diga cargando, puedes mostrarlo o no dicho icono utilizando la funcion onStatus (controlador NetStream.onStatus)con esto pudras desencadenar eventos según el vídeo este cargado, sin buffer, si finalizo o si no se pudo encontrar el archivo, si sigues sin conseguirlo envíame un mail.