PDA

View Full Version : NetStream.pause() and NetStream.resume() Issues


laaptu
03-08-2009, 11:10 AM
Dear users,
I have developed a live recorder and player. Once my application records and the recording time is stopped,it begans to play.The playing portion works well. I have used flash IDE and red5 0.7 server.
My play pause function looks like this:

private var bolLoaded:Boolean = false;

private function buttonListeners():void
{
play_btn.addEventListener(MouseEvent.CLICK,playPau se);
pause_btn.addEventListener(MouseEvent.CLICK,playPa use);
}
private function playPause(evt:MouseEvent):void
{

if(evt.target.name=="play_btn")
{
play_btn.visible = false;
pause_btn.visible = true;
if(!bolLoaded)
{
nsStream.play("myVideos.flv");
bolLoaded = true;
}
else
{
nsStream.resume( );
}
else
{
play_btn.visible = true;
pause_btn.visible = false;
nsStream.pause( );
}

}

Further when I do pause following NetStatus event are called
NetStream.Pause.Notify
NetStream.Buffer.Flush

And when I do play again after pausing

NetStream.Unpause.Notify

So in my application pausing is done but unpausing doesn't happen.
While going through some of the forums what I got is that pause and unpause issues must be resolved in both client and server.Means that pausing is triggered in server side but after unpause,the same effect can't be seen.
Do you have any idea on this? Your guidance will be well appreciated

lg101
03-09-2009, 06:20 AM
one doubt on your problem, r u trying to play after pause??
ideally when u play after pause, wht exactly happens is.. the play header is moved to the position mentioned in play field but the Status of Pause is still applied..
till you trigger unPause/resume, the subscribe wil not be able to see the stream.

so you need to apply unpause rather than play


private function playPause(evt:MouseEvent):void
{

if(evt.target.name=="play_btn")
{
play_btn.visible = false;
pause_btn.visible = true;
nsStream.play("myVideos.flv");
}
else if(evt.target.name=="pause_btn")
{

if(pause_btn.label=="pause")
{
play_btn.visible = false;
pause_btn.visible = true;
pause_btn.label="unpause";
nsStream.pause( );
}
else if(pause_btn.label=="unpause")
{
play_btn.visible = false;
pause_btn.visible = true;
pause_btn.label="pause";
nsStream.resume( );
}
}

}

laaptu
03-09-2009, 06:55 AM
Thanks for your reply.
But I have done the same thing as you have given in the code.And to verify ,I just copied and pasted your code,and as it is the same process we both are following,the solution didn't come.
Further, when I press pause at first NetStream.Pause.Notify is given and when I go for resume NetStream.Unpause.Notify is also given.
Again,thanks for the reply

Yui
03-24-2010, 10:56 AM
i have the exact same problem, the resume() method just seems to be dead for some reason (not working).

did you find a solution to this? if so, would you be so kind to share it?

edit: or if someone esle can help me out, this is my code:
(togglePause for pausing works perfectly, but resuming it never happens)

this.customClient = new Object();
this.customClient.onMetaData = metaDataHandler;

this.nsPlay = new NetStream(this.nc);
this.nsPlay.client = this.customClient;
this.videoRemote.attachNetStream(this.nsPlay);
this.nsPlay.play(this.MOVIE_NAME);

/** play/pause btn CLICK **/
private function onPlayPause(evt:MouseEvent):void
{
this.nsPlay.togglePause();
}