tiempo; //------------------------------------------------------------------------------------- // REPRODUCTOR DE VIDEO para FLASH - Version 1.0 // por: Equipo Multimedia y desarrollo CEET // carveg@eltiempo.com.co // CASA EDITORIAL EL TIEMPO //------------------------------------------------------------------------------------- Stage.scaleMode = "noScale"; Stage.align = "TL"; var clip = this; var root = this._parent; var scrubbing:Boolean; var t:Number; var ns_seconds:Number; // current playhead time (in seconds) var totalTime:Number; // length of FLV (in seconds) var playing:Boolean = false; var scrubberLength:Number = clip.tools.movieScrubber.clipTimeline._width; var scrubRange:Number = scrubberLength-clip.tools.movieScrubber.scrubDot._width+5; var volumeRange:Number = clip.tools.volumeSlider.volumeWedge._width-clip.tools.volumeSlider.volumeWedge.volumeDot._width; // NetConnection object var video_nc:NetConnection; // NetStream object var video_ns:NetStream; // Sound object var oSound:Sound; var soundLevel:Number; var intID:Number; var numVideo:Number; var archivosFLV = new Array(); var ot:Boolean; numVideo = 0; var vlow_mode:Boolean; //Variable que Indica si se vió la pauta o no var see_pauta = false; //Archivo de video file_video = _root.file ? _root.file : ' '; file_video2 = _root.file2 ? _root.file2 : ''; pauta_video = _root.file3 ? _root.file3 : ''; pauta_video2 = _root.file4 ? _root.file4 : ''; img_root = _root.imge ? _root.imge : ''; spon = _root.sp ? _root.sp : 'http://ads.us.e-planning.net/ei/3/c1e/b6b6ab1d50d2c984?it=0&p=0a0f7e232d121865&pb=31526411954a4b8f&rnd=$RANDOM'; vlow_mode = (_root.mode_low == "true") ? true : false; //Variable que indica si el video debe tener pauta o no con_pauta = _root.file3 ? true : false; //archivosFLV[0] = (clip.mode_low=="true") ? file_video2 : file_video; (_root.mode_low == "true") ? high_mode_sel._visible=false : low_mode_sel._visible=false; //Comenzar automáticamente o no //Tiempo del buffer buffer = clip.buffer ? clip.buffer : 15; var owner:MovieClip = this; // -------------------------------------------------- // Preferencias cargadas por parámetros HTTP en archivo param.txt // -------------------------------------------------- var Parametros = new LoadVars(); var auto:Boolean; var buffer:Number; var cuantos:Number; var flvPrefijo = ""; var relVideos:String; var loop:Boolean; var volume:Number; var cargaInicial:Boolean; // Cargar los parámetros generales del player var mi_formato = new TextFormat(); mi_formato.color = 0xffffff; mi_formato.font = "Verdana"; mi_formato.size = 11; clip.screen.cargando_mc.show_text.setTextFormat(mi_formato); autoPlay = (_root.autoplay == "true") ? _root.autoplay : false; if (vlow_mode) { redim_low(); } loop = false; //Cargar pauta //loadVariablesNum("http://ads.us.e-planning.net/ei/3/c1e/33be3bb17cee3169?it=0&p=12400d2d2659e983&pb=cd2727de7accbc78&rnd=$RANDOM", 2); //getURL("http://ads.us.e-planning.net/ei/3/c1e/33be3bb17cee3169?it=0&p=f7d13e19e2d20da5&pb=10bde19f76733ce2&rnd=$random", "_blank"); //Parametros.load("param.txt?uniqueID=" + getTimer()); //Parametros.load("dummy.txt"); //Parametros.load("param.txt"); Parametros.onLoad = function() { //Asignar valore spor defecto ni no está presente el parametro //autoPlay = Parametros.autoPlay_p ? Parametros.autoPlay_p : true; //buffer = Parametros.buffer_p ? Parametros.buffer_p : 15; //cuantos = Parametros.cuantos; cuantos = 1; //trace("Cuantos: " + cuantos); //relVideos = Parametros.relVideos; // Cargar el array de videos //tmp = relVideos.split("|"); //tam = tmp.length; /* for(var i=0; i " + archivosFLV[tmp2[0]]); } */ //archivosFLV[0]=file_video; //Arrancar el video //clip.screen.cargando_mc.show_text.text='aaaaa'; if (autoPlay) { // Opción de Modem if (vlow_mode) { to_low_mode(); } else { to_high_mode(); } //Opción de Banda Ancha // Opción de Banda Ancha clip.tools.boton_play_btn._visible = false; } //setupVideo(); //porc_lbl.text += relVideos + "---"; //trace('Acá debería arrancar el video') }; // -------------------------------------------------- // Event handlers // -------------------------------------------------- // display FLV download progress function updateProgress():Void { var bl:Number = video_ns.bytesLoaded; var bt:Number = video_ns.bytesTotal; var bu:Number = video_ns.time; var bytes_buffer:Number; var porc:Number; clip.tools.movieScrubber.loadProgress._width = Math.round(bl/bt*clip.tools.movieScrubber.clipTimeline._width); if (bl>4 && bt>4 && bl>=bt) { clearInterval(intID); intID = null; } clip.debug2_txt.text += "******* totaltime "+totalTime; clip.debug2_txt.text += "******* cargaInicial "+cargaInicial; if ((totalTime != 1000) && (totalTime>0) && (cargaInicial == true)) { bytes_buffer = (buffer*bt)/totalTime; clip.debug2_txt.text += "******** Bytes de buffer : "+bytes_buffer; clip.debug2_txt.text += "******** totalTime : "+totalTime; porc = (bl*100)/bytes_buffer; clip.debug2_txt.text += "*******"+bytes_buffer; } } video_onStatus = function (info:Object):Void { for (var i in info) { //trace("onStatus: "+i+" = "+info[i]); } clip.debug2_txt.text += i+" = "+info[i]+"\n"; if (info.code == "NetStream.Play.Start") { clip.screen.cargando_mc._visible = true; cargaInicial = true; } else { clip.screen.cargando_mc._visible = false; clip.debug2_txt.text += info.code; cargaInicial = false; } if (info.code == "NetStream.Play.Stop") { // video is over videoCompleted(); _root.ini(); } }; video_onMetaData = function (info:Object):Void { for (var i in info) { //trace("onMetaData: "+i+" = "+info[i]); clip.debug2_txt.text += i+" = "+info[i]+"\n"; } totalTime = info.duration; /* video_ns.pause(autoPlay ? false : true); playing = autoPlay; */ video_ns.pause(false); playing = true; }; // -------------------------------------------------- // Play/Pause button handlers // -------------------------------------------------- clip.tools.boton_play_btn.onRollOver = function() { showTip("Reproducir"); }; clip.tools.boton_play_btn.onRollOut = function() { removeTip(); }; clip.tools.boton_stop_btn.onRollOver = function() { showTip("Detener"); }; clip.tools.boton_stop_btn.onRollOut = function() { removeTip(); }; clip.tools.boton_play_btn.onRelease = function():Void { if (video_nc == undefined) { clip.screen.cargando_mc.show_text.text = 'Cargando ...'; clip.screen.cargando_mc.show_text.setTextFormat(mi_formato); if (vlow_mode) { to_low_mode(); } else { to_high_mode(); } } clip.tools.boton_play_btn._visible = 0; clip.screen.cargando_mc._visible = 0; video_ns.pause(false); playing = true; }; clip.screen.cargando_mc.playd.onRelease = function():Void { if (video_nc == undefined) { clip.screen.cargando_mc.show_text.text = 'Cargando ...'; clip.screen.cargando_mc.show_text.setTextFormat(mi_formato); if (!con_pauta || see_pauta) { } else { } if (vlow_mode) { to_low_mode(); } else { to_high_mode(); } } clip.screen.cargando_mc._visible = 0; clip.tools.boton_play_btn._visible = 0; video_ns.pause(false); playing = true; }; clip.tools.boton_stop_btn.onRelease = function():Void { clip.screen.cargando_mc.show_text.text = 'Pelicula detenida'; clip.screen.cargando_mc.show_text.setTextFormat(mi_formato); clip.tools.boton_play_btn._visible = 1; clip.screen.cargando_mc._visible = 1; video_ns.pause(true); playing = false; }; function to_low_mode():Void { vlow_mode = true; //Redimensionamos la pantalla de video del player redim_low(); archivosFLV[0] = (!con_pauta || see_pauta) ? file_video : pauta_video; setupVideo(); } function to_high_mode():Void { vlow_mode = false; //Redimensionamos la pantalla de video del player redim_high(); archivosFLV[0] = (!con_pauta || see_pauta) ? file_video2 : pauta_video2; setupVideo(); } function redim_low():Void { clip.tools.baja.gotoAndStop(2); clip.tools.alta.gotoAndStop(1); } function redim_high():Void { clip.tools.baja.gotoAndStop(1); clip.tools.alta.gotoAndStop(2); } // -------------------------------------------------- // Video scrubber // -------------------------------------------------- clip.tools.movieScrubber.scrubDot.onPress = function():Boolean { if (con_pauta && !see_pauta) { return false; } this.startDrag(false, 0, 0, scrubRange, 0); scrubbing = true; playing = false; // mute volume while scrubbing oSound.setVolume(0); return true; }; clip.tools.movieScrubber.scrubDot.onRelease = clip.tools.movieScrubber.scrubDot.onReleaseOutside=function ():Boolean { if (con_pauta && !see_pauta) { return false; } this.stopDrag(); scrubbing = false; video_ns.pause(false); // restore volume clip.setVolume(soundLevel); playing = true; clip.screen.cargando_mc._visible = 0; clip.tools.boton_play_btn._visible = 0; return true; }; clip.tools.movieScrubber.onEnterFrame = function():Void { //togglePlay(); if (scrubbing) { t = (this.scrubDot._x/scrubberLength)*totalTime; // this pauses video until scrubber is released video_ns.pause(true); video_ns.seek(t); } else { // NetStream.time method returns current playhead time var scrubFactor:Number = video_ns.time/totalTime; this.scrubDot._x = scrubRange*scrubFactor; this.loadA._width = Math.round(video_ns.time/totalTime*this.clipTimeline._width); } }; // -------------------------------------------------- // Volume controls // -------------------------------------------------- clip.tools.volumeSlider.volumeWedge.volumeDot.onPress = function():Void { this.startDrag(false, 0, -4, volumeRange, -4); clip.tools.volumeSlider.volumeWedge.onEnterFrame = function():Void { var v:Number = Math.round((this.volumeDot._x/volumeRange)*100); clip.soundLevel = v; clip.oSound.setVolume(v); }; }; clip.tools.volumeSlider.volumeWedge.volumeDot.onRelease = function():Void { this.stopDrag(); delete clip.tools.volumeSlider.volumeWedge.onEnterFrame; }; clip.tools.volumeSlider.speakerIcon.onRelease = function():Void { var muted:Boolean = oSound.getVolume() == 0; clip.setVolume(muted ? soundLevel : 0); }; // -------------------------------------------------- // Functions // -------------------------------------------------- function setupVideo():Void { // set volume properties oSound = new Sound(video_nc); soundLevel = volume ? volume : 60; clip.setVolume(soundLevel); // create a NetConnection object that can be used with a // NetStream object to play back external video (FLV) files video_nc = new NetConnection(); // open local connection video_nc.connect(null); // create a NetStream object to play FLV files // through the specified NetConnection object video_ns = new NetStream(video_nc); // buffer X seconds of video before playing video_ns.setBufferTime(buffer); // specifies NetStream instance to be displayed within // the boundaries of the Video object on the Stage clip.screen.myVideo.attachVideo(video_ns); // start playback of external video (FLV) file //porc_lbl.text += "///" + numVideo; //porc_lbl.text += "***" + flvPrefijo + archivosFLV[numVideo] + "***"; video_ns.play(flvPrefijo+archivosFLV[numVideo]); // update FLV download progress bar intID = setInterval(updateProgress, 100); // this is a workaround: define temp value for // totalTime variable until onMetaData is called totalTime = 1000; // set event handlers video_ns.onStatus = video_onStatus; video_ns.onMetaData = video_onMetaData; } function setVolume(v:Number):Void { clip.tools.volumeSlider.volumeWedge.volumeDot._x = Math.round((volumeRange*v)/100); oSound.setVolume(v); var speakerLevel:Number = Math.round(((clip.tools.volumeSlider.volumeWedge.volumeDot._x/volumeRange)*100)/33)+1; clip.tools.volumeSlider.speakerIcon.speaker_mc.gotoAndStop(speakerLevel); } function videoCompleted():Void { if (!con_pauta || see_pauta) { // if video has ended, go to beginning video_ns.seek(0); video_ns.pause(loop ? false : true); playing = loop; _root.vare = 10; clip.tools.boton_play_btn._visible = true; } else { archivosFLV[0] = (vlow_mode) ? file_video : file_video2; see_pauta = true; setupVideo(); } } function togglePlay():Void { playpauseClip.pause_btn._visible = playing; playpauseClip.play_btn._visible = !playing; } // -------------------------------------------------- // // -------------------------------------------------- var time_interval:Number = setInterval(checkTime, 500, video_ns); function checkTime(my_ns:NetStream) { var my_fmt:TextFormat = new TextFormat(); my_fmt.bold = true; my_fmt.font = "Verdana"; my_fmt.size = 8; my_fmt.color = 0x999999; my_fmt.align = "center"; clip.tools.time_.html = true; clip.tools.time_.multiline = true; clip.tools.time_.wordWrap = true; clip.tools.time_.border = false; clip.tools.time_.selectable = false; clip.tools.time_.htmlText = "0:00"; ns_seconds = video_ns.time; if (playing || ot) { ot = true; var minutes:Number = Math.floor(ns_seconds/60); var seconds:Number = Math.floor(ns_seconds%60); var ns_secondsT:Number = totalTime; if (totalTime != 1000) { var minutesT:Number = Math.floor(ns_secondsT/60); var secondsT:Number = Math.floor(ns_secondsT%60); var min:Number = minutesT-minutes; var sec = Math.abs(secondsT-seconds); if (sec<10) { sec = "0"+sec; } clip.tools.time_.htmlText = min+":"+sec; } } clip.tools.time_.setTextFormat(my_fmt); } //////////////////////////////////////////////////////// clip.tools.alta.onPress = function():Boolean { removeTip(); clip.activo(true); if (!playing) { clip.tools.boton_play_btn._visible = 0; } this.gotoAndStop(2); clip.tools.baja.gotoAndStop(1); if (!clip.vlow_mode) { return false; } clip.to_high_mode(); getURL("javascript:cambiar_global_conn(0)"); return true; }; clip.tools.baja.onPress = function() { clip.activo(true); if (!playing) { clip.tools.boton_play_btn._visible = 0; } this.gotoAndStop(2); clip.tools.alta.gotoAndStop(1); if (clip.vlow_mode) { return false; } clip.to_low_mode(); getURL("javascript:cambiar_global_conn(1)"); return true; }; bt.onPress = function() { getURL(spon, "_blank "); }; loadMovie(img_root, img); if (autoPlay) { if (video_nc == undefined) { clip.screen.cargando_mc.show_text.text = 'Cargando ...'; clip.screen.cargando_mc.show_text.setTextFormat(mi_formato); if (vlow_mode) { to_low_mode(); } else { to_high_mode(); } } clip.tools.boton_play_btn._visible = 0; clip.screen.cargando_mc._visible = 0; video_ns.pause(false); playing = true; } clip.screen.cargando_mc.show_text.setTextFormat(mi_formato); function fullScreen() { Stage["displayState"] = Stage["displayState"] == "normal" ? "fullScreen" : "normal"; if (Stage["displayState"] == "normal") { clip.tools.full.gotoAndStop(1); clip.screen._width = clip.tamx; clip.screen._height = clip.tamy; clip.img._width = clip.tamx; clip.img._height = clip.tamy; clip.bg._width = clip.tamx; clip.bg._height = clip.tamy; clip.logo._x = clip.tamx-40; clip.logo._y = 12; clip.logo._xscale = clip.logo._yscale=100; clip.tools._y = clip.tamy; clip.tools._x = 0; } else { clip._x = 0; clip._y = 0; clip.screen._width = Stage.width; clip.screen._height = Stage.height; clip.img._width = Stage.width; clip.img._height = Stage.height; clip.bg._width = Stage.width; clip.bg._height = Stage.height; clip.logo._x = Stage.width-140; clip.logo._y = 70; clip.logo._xscale = clip.logo._yscale=200; clip.tools._y = Stage.height-30; clip.tools._x = (Stage.width/2)-(clip.tools._width/2); Stage.scaleMode = "noScale"; Stage.align = "TL"; clip.tools.full.gotoAndStop(2); } } var keyListener:Object = new Object(); keyListener.onKeyDown = function() { if (Key.isDown(Key.ESCAPE)) { clip.tools.full.gotoAndStop(1); clip.screen._width = clip.tamx; clip.screen._height = clip.tamy; clip.img._width = clip.tamx; clip.img._height = clip.tamy; clip.bg._width = clip.tamx; clip.bg._height = clip.tamy; clip.logo._x = clip.tamx-40; clip.logo._y = 12; clip.logo._xscale = clip.logo._yscale=100; clip.tools._y = clip.tamy; clip.tools._x = 0; } }; Key.addListener(keyListener); clip.tools.full.fullnormal.onRelease = fullScreen; /////////////////////////////////////// clip.tooltip._visible = false; var ti:Number; function showTip(datext) { ti = getTimer(); clip.tooltip.datext.autoSize = true; clip.tooltip.datext.border = false; clip.tooltip.onEnterFrame = function() { clip.tooltip.datext.text = " "+datext+""; var tempti = getTimer(); if (tempti-ti>19) { this._x = Math.round(clip._xmouse); this._y = Math.round(clip._ymouse); clip.tooltip._visible = true; } }; } function removeTip() { clip.tooltip._visible = false; delete clip.tooltip.onEnterFrame; } function fullScreenToolTips() { if (Stage["displayState"] == "normal") { showTip("Normal"); } else { showTip("Pantalla Completa"); } } clip.tools.full.fullnormal.onRollOver = fullScreenToolTips; clip.tools.full.fullnormal.onRollOut = clip.tools.full.fullnormal.onPress=function () { removeTip(); };