Hi,
Now I have no idea how to implement repaly in red5.I find a flash code (with url: http://www.flashcomguru.com/index.cfm/2005/11/2/Streaming-flv-video-via-PHP-take-two).It can implement replay finely.I do not know how it works?Following is the code:

var nc:NetConnection = new NetConnection();
nc.connect(null);

var ns:NetStream = new NetStream(nc);

var _vidName = "golfers.flv";
var _vidURL = "http://www.yourdomain.com/"; + _vidName;
var _phpURL = "http://www.yourdomain.com/flvprovider.php";;
var ending = false;
var amountLoaded:Number;
var duration:Number;
var loaderwidth = loader.loadbar._width;

theVideo.attachVideo(ns);
ns.setBufferTime(2);

statusID = setInterval(videoStatus, 200);

ns.onStatus = function(info) {
        
        trace(info.code);       
        if(info.code == "NetStream.Buffer.Full") {
                bufferClip._visible = false;            
                ending = false;
                
                clearInterval( statusID );
                statusID = setInterval(videoStatus, 200);
        }
        if(info.code == "NetStream.Buffer.Empty") {
                if ( !ending ) {
                        bufferClip._visible = true;
                }
        }
        if(info.code == "NetStream.Play.Stop") {
                bufferClip._visible = false;
                //ending = true;
        }
        if(info.code == "NetStream.Play.Start") {
                ending = false;
        }
        if(info.code == "NetStream.Buffer.Flush") {
                ending = true;
        }
}

playButton.onRelease = function() {
        ns.pause();
}

play_btn.onRelease = function() {
        restartIt();
        this._visible = false;
}

rewindButton.onRelease = function() {
        restartIt();
}

ns["onMetaData"] = function(obj) {
        duration = obj.duration;
        //trace(obj.width);
        //trace(obj.height);
        // suck out the times and filepositions array, this was added by 
flvmdi27b
        times = obj.keyframes.times;
        positions = obj.keyframes.filepositions;
}

function videoStatus() {
        amountLoaded = ns.bytesLoaded / ns.bytesTotal;
        loader.loadbar._width = amountLoaded * loaderwidth;
        loader.scrub._x = ns.time / duration * loaderwidth;
}

loader.scrub.onPress = function() {
        clearInterval (statusID );
        ns.pause();
        this.startDrag(false,0,this._y,loaderwidth,this._y);
}

loader.scrub.onRelease = loader.scrub.onReleaseOutside = function() {   
        scrubit();
        this.stopDrag();
}

function scrubit() {
        var tofind = Math.floor((loader.scrub._x/loaderwidth)*duration);
        if (tofind <= 0 ) {
                restartIt();
                return;
        }

        for (var i:Number=0; i < times.length; i++){
                var j = i + 1;
                if( (times[i] <= tofind) && (times[j] >= tofind ) ){
                        trace("match at " + times[i] + " and " +  positions[i]);
                        bufferClip._visible = true;
                        ns.play( _phpURL + "?file=" + _vidName + "&position=" + 
positions[i]);
trace("play " + _phpURL + "?file=" + _vidName + "&position=" + positions[i]);
                        break;
                }
        }
}

function pauseIt() {
        ns.pause();
}

function stopIt() {
        ns.seek(0);
        ns.pause();
}

function restartIt() {
        ns.play( _vidURL );
}

//restartIt();

// holds sound
_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");
        }
}



/*
var theMenu:ContextMenu = new ContextMenu();
theMenu.hideBuiltInItems();
_root.menu = theMenu;

var item1:ContextMenuItem = new ContextMenuItem("::::: Video Controls :::::",trace);
theMenu.customItems[0] = item1;

var item2:ContextMenuItem = new ContextMenuItem("Play / Pause Video",pauseIt,true);
theMenu.customItems[1] = item2;

var item3:ContextMenuItem = new ContextMenuItem("Replay the Video",restartIt);
theMenu.customItems[2] = item3;
        
*/

yours tiger

_________________________________________________________________
享用世界上最大的电子邮件系统― MSN Hotmail。 http://www.hotmail.com

_______________________________________________
Red5 mailing list
[email protected]
http://osflash.org/mailman/listinfo/red5_osflash.org

Reply via email to