A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: getting the time of a streaming video

  1. #1
    Confused
    Join Date
    Jul 2000
    Location
    washington DC
    Posts
    64

    getting the time of a streaming video

    having difficulty getting the current runtime of a previously-recorded streaming video. i need it so i can trigger events to happen at certain times during the video.

    i've got a movieclip with this script attached to it:

    Code:
    onClipEvent (enterFrame) {
    	currentTime=_root.myInputStream.time
    	trace(myInputStream.time);	
    }
    this resides in the same movieclip as my video and the big movieplaying script. once the video is playing i can trace 'myInputStream.time' inside the main script, but i can't seem to detect it from that outside source.

    as a reference, here's what i'm using to play the video:

    Code:
    stop();
    
    // create connection to server
    serverName = "rtmp://www.server.com";
    videoToLoad = "XWCA01_Broadband";
    totalBuffer = 5;
    endtime = 79;
    nc = new NetConnection();
    nc.connect(serverName+"/xacta");
    nc.onStatus = function(returnObj) {
    	
    	if (returnObj.code == "NetConnection.Connect.Success") {
    		startVideo();
    	} else if (returnObj.code == "NetConnection.Connect.Rejected") {
    		gotoAndStop("server busy");
    		nc.onStatus = null;
    	} else if (returnObj.code == "NetConnection.Connect.Closed") {
    		gotoAndStop("closed connection");
    	}
    };
    
    function startVideo() {
    	myInputStream = new NetStream(nc);
    	vidBoxPlay.attachVideo(myInputStream);
    	myInputStream.setBufferTime(totalBuffer);
    	myInputStream.play(videoToLoad);
    	myInputStream.onStatus = function(infoObject) {
    	
    		if (infoObject.code == "NetStream.Play.Start" || infoObject.code == "NetStream.Buffer.Empty") {
    			if (myInputStream.time<endtime) {
    				buffer_mc._visible = 1;
    				isBuffering = 1;
    			} else if (myInputStream.time>=endtime) {
    			_root.play();
    			}
    		} else if (infoObject.code == "NetStream.Buffer.Full") {
    			buffer_mc._visible = 0;
    			isBuffering = 0;
    			
    		}
    	};
    }
    function bufferStatus() {
    	if (isBuffering) {
    		
    		currentBuffer = myInputStream.bufferLength;
    		bufferPercent = currentBuffer/totalBuffer;
    		if (bufferPercent>1) {
    			bufferPercent=1, buffer_mc._visible=0;
    		}
    		buffer_mc.bar_mc._xscale = bufferPercent*100;
    		trace(bufferPercent);
    	}
    }
    
    
    
    
    
    _root.navBar.pause_btn.onRelease = function() {
    	pauseMovie();
    };
    _root.navBar.play_btn.onRelease = function() {
    	playMovie();
    };
    function pauseMovie() {
    	myInputStream.pause(true);
    }
    function playMovie() {
    	myInputStream.pause(false);
    }
    thanks!

    - corey

  2. #2
    Undefined Null
    Join Date
    Oct 2000
    Location
    trace(planet[i].name)
    Posts
    50
    hi

    try to put this code in the same frame of your code.


    Code:
    function timer() {
        currentTime = myInputStream.time;
        timeLeft = endtime-currentTime;
        trace(currentTime);
    }
    
    
    setInterval(timer, 200);
    hope this will help u

    PS: sorry for my bad english


    Rubira
    Last edited by rubira; 01-16-2003 at 08:42 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center