Skip to main content
tunghoy
Inspiring
February 14, 2009
Question

Is there a real Stop event for FLVPlayback ?

  • February 14, 2009
  • 2 replies
  • 708 views
I struggle with the FLVPlayback component more than anything else. I want one thing to happen when a video finishes playing, but something else to happen when the user clicks the Stop button. But the Complete, Stopped and stoppedStateEntered events will fire if either of these things occur. IOW, ActionScript doesn't distinguish between a video ending normally and the user clicking the Stop button.

Does the Stop button have its own events separate from the player? I can't find anything listed. I suppose I can draw my own button over it, but I'd like to avoid that, if possible.
This topic has been closed for replies.

2 replies

Colin Holgate
Inspiring
February 16, 2009
At the end, the stop event does happen. As the Complete help says:

"The video player also dispatches the stateChange and stoppedStateEntered events."

So, don't use the stoppedStateEntered at all, and if you use the stateChange one, check the playheadTime (which comes with the stateChange event) to see if you're at the end. Other than that, just using the Complete event to tell when it's at the end should work ok.


Colin Holgate
Inspiring
February 15, 2009
The help doesn't think that the stop button triggers a Complete:

(Complete).."Dispatched when playing completes because the player reached the end of the FLV file. The component does not dispatch the event if you call the stop() or pause() methods or click the corresponding controls."


You could either use the complete event to do the different action for the end, or you could use the stateChange event, and decide what to do based on whether the playheadtime is close enough to the duration of the video.


tunghoy
tunghoyAuthor
Inspiring
February 15, 2009
Thanks for your response, but I'm still a little confused. Here's what the Help says about the STOPPED_STATE_ENTERED event:

Dispatched when entering the stopped state. This happens when you call the stop() method or click the stopButton control.....The FLVPlayback instance also dispatches this event when the playhead stops at the end of the FLV file because it has reached the end of the timeline.

The problem I was having was that when a video finished playing, another one had to load into the same player. I have a listener listening for VideoEvent.COMPLETE, which runs a function that calls the Play method to load the next video. But when the first video finishes, AS acts as though the Stop button was clicked.

The workaround I used was to capture the Out and Over states of the player's Stop button. I then cropped them in Photoshop and brought them back into Flash as a simple button, which executes the Stop method when clicked. I then placed this button over the real one. Since it has its own name and functionality separate from the built-in controls, I can now separate the methods and events of the button and player.

But I'm not crazy about the solution because I now have to keep track of another object (esp. when moving or resizing the player), and if I want to re-use the code elsewhere, I have to create another button.