A Flash Developer Resource Site

Results 1 to 11 of 11

Thread: onPlayStatus()?

  1. #1
    Senior Member
    Join Date
    Apr 2002
    Posts
    2,849

    onPlayStatus()?

    Sometimes I find the AS3 documentation so confusing. How exactly do I use NetStream.onPlayStatus()? I'm assuming I need to write an event listener, but not sure how it should go...

  2. #2
    Member
    Join Date
    Jul 2008
    Posts
    40
    I am also having issues with onPlayStatus event.

    I have it set up the same way as I do with onMetaData (which works), but onPlayStatus has not even fired a simple trace("HI") statement.

    Any help would be very appreciated!
    -Jake

  3. #3
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    Well, I haven't used NetStream, but the docs don't seem that confusing.
    onPlayStaus is actually a property of the NetStream.client object. It isn't an event, but is listed in the Events section because it responds to a data event, either when streaming media using Flash Media Server or during FLV file playback. For more information, see the NetStream class description. You cannot use the addEventListener() method, or any other EventDispatcher methods, to listen for, or process onPlayStatus as an event. Rather, you must define a single callback function and attach it directly to one of the following objects:

    * The object that the client property of a NetStream instance references.
    * An instance of a NetStream subclass. NetStream is a sealed class, which means that properties or methods cannot be added to a NetStream object at runtime. However, you can create a subclass of NetStream and define your event handler in the subclass or make the subclass dynamic and add the event handler function to an instance of the subclass.
    You need to define an onPlayStatus method in whatever you are using as the client.

  4. #4
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    Well, I haven't used NetStream, but the docs don't seem that confusing.
    onPlayStaus is actually a property of the NetStream.client object. It isn't an event, but is listed in the Events section because it responds to a data event, either when streaming media using Flash Media Server or during FLV file playback. For more information, see the NetStream class description. You cannot use the addEventListener() method, or any other EventDispatcher methods, to listen for, or process onPlayStatus as an event. Rather, you must define a single callback function and attach it directly to one of the following objects:

    * The object that the client property of a NetStream instance references.
    * An instance of a NetStream subclass. NetStream is a sealed class, which means that properties or methods cannot be added to a NetStream object at runtime. However, you can create a subclass of NetStream and define your event handler in the subclass or make the subclass dynamic and add the event handler function to an instance of the subclass.
    You need to define an onPlayStatus method in whatever you are using as the client.

  5. #5
    Junior Member
    Join Date
    Jul 2009
    Posts
    5
    Quote Originally Posted by 5TonsOfFlax View Post
    Well, I haven't used NetStream, but the docs don't seem that confusing.


    You need to define an onPlayStatus method in whatever you are using as the client.
    Yes, the documentation is pretty clear. What is confusing is that it just does not work.
    The onPlayStatus handler is never called.

  6. #6
    Senior Member
    Join Date
    Jan 2009
    Posts
    208
    dont use that, listen for NetStream.Play.Stop which is dispatched when video finishes playing

    Actionscript Code:
    netStream.addEventListener(NetStatusEvent.NET_STATUS, doNetStatus);
    private function doNetStatus(e:NetStatusEvent):void {
    switch (e.info.code) {
    case "NetStream.Play.Stop" ://Playback has stopped.
    }
    }

  7. #7
    Junior Member
    Join Date
    Jul 2009
    Posts
    5
    Quote Originally Posted by regbolD View Post
    dont use that, listen for NetStream.Play.Stop which is dispatched when video finishes playing

    Actionscript Code:
    netStream.addEventListener(NetStatusEvent.NET_STATUS, doNetStatus);
    private function doNetStatus(e:NetStatusEvent):void {
    switch (e.info.code) {
    case "NetStream.Play.Stop" ://Playback has stopped.
    }
    }
    Doesn't that get fired whenever the playback is stopped? (as opposed to only when it reaches the end)

  8. #8
    Senior Member
    Join Date
    Jan 2009
    Posts
    208
    no, only when it reaches the end.
    and there is no stop playback, you can either pause/resume it or close the netstream all together.

  9. #9
    Junior Member
    Join Date
    Jul 2009
    Posts
    5
    I understand.
    Thanks a lot.

    I wonder why the documentation mentions an onPlayStatus handler that does not exist.

  10. #10
    Junior Member
    Join Date
    Apr 2009
    Posts
    3
    onPlayStatus does exist - but functions for only streaming video not progressive download. When buffering - you should implement NetStatus.play.stop.

    Here is my info source:

    http://www.actionscript.org/forums/s...=159194&page=3

    Hope this helps

  11. #11
    Junior Member
    Join Date
    Jul 2009
    Posts
    5
    Quote Originally Posted by DJRoberts View Post
    onPlayStatus does exist - but functions for only streaming video not progressive download.

    Hope this helps
    This helps a lot.
    Adobe's documentation really sucks. It doesn't mention that onPlayStatus only works for true streaming, and it definitely should.

    Although indeed, there's no reason why onPlayStatus shouldn't work for progressive download too. Maybe that's a bug. There are so many. Documentation is not the only thing that sucks about Flash.

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