Macromedia Flash Server - Re: NetStream.Play.Stop not triggered withprogressivevideo

This is Interesting: Free IT Magazines  
Home > Archive > Macromedia Flash Server > June 2005 > Re: NetStream.Play.Stop not triggered withprogressivevideo





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Re: NetStream.Play.Stop not triggered withprogressivevideo
adam

2005-06-15, 7:45 am

Hi Stefan,

yeah, hehe, my old approach was to use onStatus only as well depending on
what im working with. it worked great when the events triggered when
expected, heh. in this cause im using both, play.stop triggers callback, and
if that doesnt happen, one of the checks in the onEnterFrame will execute
that same callback function.

things in they way they work changed a little for netstreams after i applied
the current fcom patch. i cant say for sure this is the reason but
definately did not experience the problem before and definately did
immediately afterwards.

when playing back what appears to be a currupt flv ~with~ fcom, even though
the ns.time never equals the duration, its a heck of a lot closer in which,
both times are the same second, but they are off on the milliseconds, which
i would still consider a problem but at least in that case the values can be
rounded etc. i noticed yours is off by milliseconds. u can round the times
and trigger a callback. if things vary beyond milliseconds you will run into
problems. my solution accounts for differences greater then milliseconds and
factors in buffering as well.

i encode using fcom. the problem doesnt occur every recording, seems
something like 1 in between 15 and 30 times, which as far as im concerned
is quite a lot because it means to me its going to happen quite frequently
when users record their streams.

my approach works with onEnterFrame. i use it to update a progressbar using
ns.time & ns.duration. when they equal each other the progressbar needs to
be reset and next instructions need to be executed.

here is sample code, let me know if something isnt clear

-adam

------------------------------------------------------------------------------


function nsStatus(info)
{
trace("stream :: "+this.name+" info: "+info.code);
if (info.code == "NetStream.Play.Start" && this.startCB) {
this.startCB();
} else if (info.code == "NetStream.Play.Stop" && this.stopCB) {
this.stopCB();
} else if (info.code == "NetStream.Unpublish.Success" &&
this.unpublishSuccessCB) {
this.unpublishSuccessCB();
} else if (info.code == "NetStream.Publish.Start" && this.publishStartCB) {
this.publishStartCB();
} else if (info.code == "NetStream.Record.Start" && this.recordStartCB) {
this.recordStartCB();
} else if (info.code == "NetStream.Buffer.Empty" && this.bufferEmptyCB) {
this.bufferEmptyCB();
} else if (info.code == "NetStream.Buffer.Full" && this.bufferFullCB) {
this.bufferFullCB();
}
}

function init()
{
nc = new NetConnection();
nc.connect(null);
ns = new NetStream(nc);
mc.vid.attachVideo(ns);
ns.onStatus = nsStatus;
ns.setBufferTime(5);
//here i set onStatus event callback function checked in nsStatus function.
ns.startCB = myStartCB;
ns.stopCB = myStopCB;
ns.bufferFullCB = myBufferFullCB;
ns.bufferEmptyCB = myBufferEmptyCB;
ns["onMetaData"] = setMetaData;
ns.i = 0;
ns.play("myFile.flv");
}

function myStartCB()
{
mc.onEnterFrame = function()
{
ns.i++;
//counter for the onEnterFrame timer
if (Math.ceil(ns.duration)>0) {
//i update my progress bar here
if (Math.ceil(ns.time)>=Math.floor(ns.duration)) {
//i reset my progress bar here etc
delete this.onEnterFrame;
ns.myStopCB();
} else if (ns.i%24 == 0) {
//enterframe timer check. fps = 12, this checks about once in 2 seconds.
if (ns.time == ns.lastTime && !ns.buffering &&
ns.time>(1+ns.bufferTime)) {
//above says if play time is equal to ns.lastTime and buffering isnt
//occuring and if the play time is greater than at least one second
plus
//buffertime if any, then things are stuck and
//if (Math.ceil(ns.time)>=Math.floor(ns.duration)) { will never happen
//nor will play.stop or buffer.empty so do a manual end process.
//
//i reset my progress bar here etc
delete this.onEnterFrame;
ns.myStopCB();
}
ns.lastTime = ns.time;
}
}
};
}

function nsBufferFullCB()
{
ns.buffering = 0;
}

function nsBufferEmptyCB()
{
ns.buffering = 1;
}

function myStopCB()
{
delete mc.onEnterFrame;//delete my onEnterFrame here just in case play.stop
does work.
ns.play(false);
ns.close();
delete ns;
//reset progress bar etc
doOtherStuff()
}



----- Original Message -----
From: "Stefan Richter" <stefan-fMeCE+ULXElEfu+5ix1nRw@public.gmane.org>
To: "'FlashComm Mailing List'" <flashcomm-1Ss2GqJETD3yZ38Mhd3e/9ZfFG6BLHNm@public.gmane.org>
Sent: Wednesday, June 15, 2005 12:01 PM
Subject: RE: [FlashComm] NetStream.Play.Stop not triggered
withprogressivevideo


> Hi adam,
> Thanks for replying. I'll test later as you suggested monitoring time and
> duration.
>
> My old approach was actually similar to yours - I needed to track play
> times
> of my flvs so I monitored them with an interval. Shame, the onstatus
> approach seemed much more robust - until now.
>
> Please post your code if you could.
> What do you do with an apparently 'corrupt' flv file? And have you seen
> many
> files behave in this way? What did you use for encoding? I think I used
> Sorenson 4 for mine - most of the files seem to work fine...
>
> Stefan
>
>
>
> -----Original Message-----
> From: flashcomm-bounces-1Ss2GqJETD3yZ38Mhd3e/9ZfFG6BLHNm@public.gmane.org
> [mailto:flashcomm-bounces-1Ss2GqJETD3yZ38Mhd3e/9ZfFG6BLHNm@public.gmane.org] On Behalf Of adam
> Sent: Wednesday, June 15, 2005 10:43 AM
> To: FlashComm Mailing List
> Subject: Re: [FlashComm] NetStream.Play.Stop not triggered with
> progressivevideo
>
> Hi Stefan,
>
> sounds like you could be experiencing something simular my problem, can
> you
> trace the ns.time & ns.duration in an onEnterFrame to be sure they equal
> each other at the end of playback? perhaps your ns.time never reaches the
> ns.duration, in which cause you wont get a play.stop or buffer.empty which
> was exactly my problem as i needed those to continue my process.
>
> i did work around this problem in what seems to be a fairly trustworth
> solution.
>
> to access duration if you are unfamiliar, you would create your ns and
> assign the metadata to it like so:
>
> function setMetaData(o)
> {
> this.duration = o.duration;
> }
>
> nc = new NetConnection();
> nc.connect(null);
> ns = new NetStream(nc);
> ns["onMetaData"] = setMetaData;
>
> then in an onEnterFrame or interval u could trace your ns.time &
> ns.duration
> to validate file is ok or not.
>
> if you are interested in how i worked around the intermittant bad flv
> issue,
> let me know and ill post the code.
>
> -adam
>
>
>
>
>
>
>
> ----- Original Message -----
> From: "Stefan Richter" <stefan-fMeCE+ULXElEfu+5ix1nRw@public.gmane.org>
> To: "'FlashComm Mailing List'" <flashcomm-1Ss2GqJETD3yZ38Mhd3e/9ZfFG6BLHNm@public.gmane.org>
> Sent: Wednesday, June 15, 2005 11:01 AM
> Subject: [FlashComm] NetStream.Play.Stop not triggered with progressive
> video
>
>
>
>
>
> =-----------------------------------------------------------
> Supported by Fig Leaf Software - http://www.figleaf.com
> =-----------------------------------------------------------
>
> To change your subscription options or search the archive:
> http://chattyfig.figleaf.com/mailman/listinfo/flashcomm
>
>
> =-----------------------------------------------------------
> Supported by Fig Leaf Software - http://www.figleaf.com
> =-----------------------------------------------------------
>
> To change your subscription options or search the archive:
> http://chattyfig.figleaf.com/mailman/listinfo/flashcomm
>
>




=-----------------------------------------------------------
Supported by Fig Leaf Software - http://www.figleaf.com
=-----------------------------------------------------------

To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcomm

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com