2 Replies - 1862 Views - Last Post: 14 October 2011 - 11:39 AM

#1 DilutedImage  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 15
  • View blog
  • Posts: 646
  • Joined: 20-November 06

VideoEvent.COMPLETE workaround - AS3

Posted 09 June 2007 - 10:43 PM

Description: Simply place an FLVPlayback component on the stage, and give it an instance name of "theVideo". Then put the filepath of your video into the "source" property. This snippet will detect when the video has reached a "stopped" state. The "playbackBegun" boolean is used as a way to ignore the first "stopped" state, which occurs before the video begins it's "playing" state.In need of a FLVPlayback component "COMPLETE" detection that worked despite improper meta data embedded by the Flash Video Encoder, I devised this snippet. NOTE: THIS ONLY WORKS WITHOUT A VIDEO CONTROLLER, AS IT LISTENS FOR THE "stopped" VIDEO STATE.
// Class that handles video events
import fl.video.VideoEvent;

// A variable to track if the video has begun playback
var playbackBegun:Boolean = false; 

// A function to handle the video events sent by the listener
function videoHandler(evt:VideoEvent) {
     // Detect state of theVideo
     switch(evt.state) {
          case "playing":
               playbackBegun = true;
               break;
          case "stopped":
               // Only process if playback occurred
               if(playbackBegun == true) {
                    // Reset the tracking variable
                    playbackBegun = false;
                    // *** THE VIDEO HAS COMPLETED ***
                    // *** DO SOMETHING HERE ***
               }
               break;
          default:
               // Optional handler for other playback states
     }     
}

// Listen for "STATE_CHANGE" video events generated by theVideo
// and call the videoHandler function when they occur.
theVideo.addEventListener(VideoEvent.STATE_CHANGE, videoHandler);


Is This A Good Question/Topic? 0
  • +

Replies To: VideoEvent.COMPLETE workaround - AS3

#2 mikoop  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 0
  • Joined: 07-December 10

Re: VideoEvent.COMPLETE workaround - AS3

Posted 07 December 2010 - 08:14 PM

Great work, just what I was looking for!!!! thanks.
Was This Post Helpful? 0
  • +
  • -

#3 fermp  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 0
  • Joined: 14-October 11

Re: VideoEvent.COMPLETE workaround - AS3

Posted 14 October 2011 - 11:39 AM

You sir, rock! Thanks :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1