Skip to main content
Known Participant
September 1, 2011
Answered

Intercepting play calls

  • September 1, 2011
  • 2 replies
  • 830 views

I'm trying to limit a client's video playback to 10 seconds.  After that, the client should be disconnected.  I have to allow time for connection and buffering, so I can't just disconnect them after 10 seconds.  I was hoping to override the play command, so I can force the length parameter to 10, but I can't figure out how.  Is this possible?

Thanks,

Sean

    This topic has been closed for replies.
    Correct answer

    On the server side you mean? You can't with server side actionscript...you'd need to write an access plugin in C++ for that, and even with that, I don't know of a useful way to use the data once you catch it in the plugin.

    2 replies

    September 1, 2011

    The netstream.play method will accept parameters for startTime and length. The length flag defines how long to play the stream. For example:

    ns.play("foo", 0, 10, true)

    will play a recorded file named foo.flv from the top of the file for 10 seconds.

    If you want to disconnect after playback is done, listen for the NetStatusEvent on the netstream. Youll want to inspect the event.info.code property, and close the netconnection in respose to a value of NetStream.Play.Stop

    calmchessplayer
    Inspiring
    September 1, 2011

    or you can do it that way.....I display the count down thats where i got my method from. If you don't need to display it then Jay's method is more efficient.

    calmchessplayer
    Inspiring
    September 1, 2011

    I'd just use Timer and a counter variable couVar++;  and close the netStream after  a count of 10 if(couVar==10){ NS0.close()};. I might also remove child the video playback object so they don't see a frozen image. The counter I describe above isn't completely accurate but I think i will do for you purposes. I do have a highly accurte time keeper that I use to charge my customers for the time they spend on my site. You want it? PS if NS0.close() doesn't work for you try NS0.play(null) or NS0.play(flase) I can't remember which one works exactly its been awhile since i did this. When in doubt look in the AS3.0 liveDocs or SSAS docs