Ver Mensaje Individual
  #2 (permalink)  
Antiguo 11/02/2009, 16:02
Avatar de Lynxcraft
Lynxcraft
 
Fecha de Ingreso: noviembre-2007
Ubicación: yecla murcia
Mensajes: 1.346
Antigüedad: 16 años, 5 meses
Puntos: 51
Respuesta: Detener video antes que se reproduzca

Código PHP:
//conección del video

 
var nc:NetConnection = new NetConnection();
 
nc.connect(null);
 
var 
ns:NetStream = new NetStream(nc);
 
miVideo.attachVideo(ns);
 
//carga el video de la carpeta flv, tambien puede ser del servidor, en ese caso, colocar ruta
  
ns.play("videop.flv");
ns.pause(); 
//este es el tiempo del buffer en segundos
 
ns.setBufferTime(10);
 
//mensaje cargando video dentro del mc bufferclip
 
ns.onStatus = function(info) {

if(
info.code == "NetStream.Buffer.Full") {
 
bufferclip._visible false;
 
}else{
 
bufferclip._visible true;
 
}
 
}
 
//para el tiempo transcurrido del video
 
var time_interval:Number setInterval(checkTime0ns);
function 
checkTime(mi_ns:NetStream) {
var 
ns_seconds:Number mi_ns.time;
var 
minutes:Number Math.floor(ns_seconds/60);
var 
seconds Math.floor(ns_seconds%60);
if (
seconds 10) {
seconds "0" seconds;
}
timevid_txt.text "0" minutes ":" seconds;
}
//botones
_root.createEmptyMovieClip("vSound",_root.getNextHighestDepth());
vSound.attachAudio(ns);
 
var 
so:Sound = new Sound(vSound);
 
so.setVolume(100);
 
mute.onRollOver = function() {
    if(
so.getVolume()== 100) {
        
this.gotoAndStop("onOver");
    }
    else {
        
this.gotoAndStop("muteOver");
    }
}
 
mute.onRollOut = function() {
    if(
so.getVolume()== 100) {
        
this.gotoAndStop("on");
    }
    else {
        
this.gotoAndStop("mute");
    }
}
 
mute.onRelease = function() {
    if(
so.getVolume()== 100) {
        
so.setVolume(0);
        
this.gotoAndStop("muteOver");
    }
    else {
        
so.setVolume(100);
        
this.gotoAndStop("onOver");
    }
}
 
playButton._visiblefalse;
playButton.onPress = function() {
    
ns.pause();
    
this._visiblefalse;
    
pauseButton._visibletrue;
}
pauseButton.onPress = function() {
    
ns.pause();
    
this._visiblefalse;
    
playButton._visibletrue;
}
 
//barra de desplazamiento
this.createEmptyMovieClip("vFrame",this.getNextHighestDepth());
vFrame.onEnterFrame videoStatus;
 
var 
amountLoaded:Number;
var 
duration:Number;
 
ns["onMetaData"] = function(obj) {
    
duration obj.duration;
}
 
function 
videoStatus() {
    
amountLoaded ns.bytesLoaded ns.bytesTotal;
    
barra.progreso._width amountLoaded 140;
    
barra.scrub._x ns.time duration 140;
}
 
var 
scrubInterval;
 
barra.scrub.onPress = function() {
    
vFrame.onEnterFrame scrubit;
    
this.startDrag(false,0,this._y,140,this._y);
}
 
barra.scrub.onRelease barra.scrub.onReleaseOutside = function() {
    
vFrame.onEnterFrame videoStatus;
    
this.stopDrag();
}
 
function 
scrubit() {
    
ns.seek(Math.floor((barra.scrub._x/140)*duration));
}
 
//por ultimo el menu
var elMenu:ContextMenu = new ContextMenu();
elMenu.hideBuiltInItems();
_root.menu elMenu;
 
var 
item1:ContextMenuItem = new ContextMenuItem("::::: Control de video :::::",trace);
elMenu.customItems[0] = item1;
 
var 
item2:ContextMenuItem = new ContextMenuItem("Play / Pause",pauseIt,true);
elMenu.customItems[1] = item2;
 
var 
item3:ContextMenuItem = new ContextMenuItem("Replay Video",restartIt);
elMenu.customItems[2] = item3;
 
 
//funciones, aquí establecemos lo que queremos que el menú haga
 

function pauseIt() {
    
ns.pause();
    if(
pauseButton._visible false){
    
playButton._visibletrue;
    }else{
        
playButton._visiblefalse;
    }
}
 
function 
restartIt() {
    
ns.seek(0);

linea de codigo añadida
Código PHP:
 
//carga el video de la carpeta flv, tambien puede ser del servidor, en ese caso, colocar ruta
  
ns.play("videop.flv");
ns.pause();   // si esto pausa en los botones aqui también debería pausar lo 
//este es el tiempo del buffer en segundos
 
ns.setBufferTime(10); 
__________________
Sobran las ideas cuando faltan ganas de trabajar en ellas
Lynxcraft