Hunternif
Hunternif

Reputation: 2392

NetStream.info, getting Error #2154

In my application I have a video playing from a NetStream. Every second on timer I update a text label with statistics like stream.info.currentBytesPerSecond. The problem occurs when the NetConnection associated with this NetStream closes: the getter for stream.info throws

Error: Error #2154:The NetStream Object is invalid.

The only solution for this seems to be to listen to NetStatus event and stop the timer when "NetConnection.Connect.Closed" gets caught.
Isn't there a better way to do this?

Upvotes: 2

Views: 2779

Answers (1)

James Tomasino
James Tomasino

Reputation: 3581

You could wrap your test for stream.info in a try..catch, I suppose. Or you could test to see if the object exists first:

if (stream && stream.info) stream.info ...

Really, though, the cleanest way would be to remove the applicable listener and perform cleanup when your connection closes.

Upvotes: 2

Related Questions