A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: pause and unpause flv

  1. #1
    Senior Member
    Join Date
    Apr 2004
    Posts
    156

    pause and unpause flv

    Hi, everything works fine, the movie pauses fine but when I unpause it replays it from the beginning. How do I make it continue playing from where it was paused? Thanks!

    Code:
    import mx.utils.Delegate;
    #include "mc_tween2.as"
    
    var netConnection = new NetConnection();
    netConnection.connect(null);
    var netStream = new NetStream(netConnection);
    netStream.setBufferTime(2);
    VideoHolder.iVideo.attachVideo(netStream);
    
    netStream.onStatus = function(infoObject:Object) {
    
    	var statusCode = infoObject.code;
    	var netStartPlay:String = "NetStream.Play.Start";
    	var netStopPlay:String = "NetStream.Play.Stop";
    	var netBufferFull:String = "NetStream.Buffer.Full";
    
    	switch (statusCode) {
    
    		case netStartPlay :
    			VideoHolder.alphaTo(100,.5,"easeInSine");
    			break;
    
    		case netStopPlay :
    			VideoHolder.alphaTo(0,.5,"easeOutSine")
    			break;
    
    	}
    }
    
    var isPlaying = false;
    
    function playVideo(inURL:String) {
    	netStream.play(inURL);
    	isPlaying = true;
    }
    
    controls.playBtn.onRelease=function() {
    if( isPlaying == false ) {
    	playVideo("testmovie.flv");
    	controls.playBtn.gotoAndPlay(2);
    } 
    else {
        controls.playBtn.gotoAndPlay(1);
    	isPlaying = false;
    	netStream.pause();
    }
    
    }

  2. #2
    Senior Member
    Join Date
    Apr 2002
    Posts
    2,849
    play() starts the NetStream from the beginning. pause() stops or restarts play from where it was. You can also pass true or false i.e. pause(false).

  3. #3
    ninja army recruiter
    Join Date
    May 2008
    Location
    Austin, TX
    Posts
    6

    Unhappy not really

    actually as far as i can tell that advice is no good. pause() does nothing whatsoever to movieclips in my project. perhaps it doesn't work in 2.0?

    if (Key.isDown(Key.SPACE)) {
    if (pausing == false) {
    pausing = true;
    themesound.stop();
    Character_mc.pause(true);
    hitting the spacebar does nothing but stop the music in this example.

  4. #4
    Senior Member
    Join Date
    Apr 2002
    Posts
    2,849
    You stop movieclips with stop(), i.e. myMovieClip.stop();. You pause Netstream objects (video) with pause().

  5. #5
    ninja army recruiter
    Join Date
    May 2008
    Location
    Austin, TX
    Posts
    6
    yeah got it working finally! stop() and play() just had to make sure to put it on every single movie clip (needed a pause button in the game im making). definitely PITA but at least it works

  6. #6
    Senior Member
    Join Date
    Mar 2003
    Posts
    120
    I'm trying to pause/unpause an flv from the main timeline. Did this work, and can you please explain how to use the code? Like, if it goes on a button or keyframe. I'm not very good at this part...
    *brittany*

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