4 Replies Latest reply on Oct 22, 2009 12:17 PM by braddini

    VideoEvent.COMPLETE handler not executing...

      Hi Everyone,

      I have a Video Display control that has an addEventListener assigned to it upon clicking the play button to play an flv file. To try and explain as clear as I can I'll go through the process in order. Upon clicking the play button, a function executes ( playFLV() ), and first assigns an addEventListener to listen for the end of the flv - " videoDisplay.addEventListener(VideoEvent.COMPLETE, videoCompleteHandler); ". Directly after that in the same function, i assign the source of the videoDisplay control and then execute the videoDisplay play() function so the flv starts playing.

      Once that flv has finished playing, the videoCompleteHandler() function executes like it should. Now what I want happen is for the next flv in the array collection to play. In the videoCompleteHandler() i remove the addEventListener I added in the playFLV() function and then execute another function which is supposed to play the next video. The function which executes the next video assigns another addEventListener to the video display control, assigns the new source to the videoDisplay control and then executes the play() function to start playing the flv ( videoDisplay.play() ). Everything up until this point works like it should. The problem comes in next - when the second video has finished playing the addEventListener handler doesn't execute even though I have assigned one to the videoDisplay control. So what I have is the following in the function which executes the next video - " videoDisplay.addEventListener(VideoEvent.COMPLETE, nextVidCompleteHandler); ". The nextVidCompleteHandler() function doesn't execute once the flv has finished playing.

      I'm not sure what I'm doing wrong, any idea why the handler of the second addEventListener assignment doesn't execute? I thought perhaps I've over complicated things with the adding and removing of addEventListeners so what I did was assigned an addEventListener to the videoDisplay control once the application has finished loading up (creationComplete). So when the flv ends, it executes the same handler each time which is supposed to play the next video. The resut is still the same.

      Any idea why the addEventListener I've assigned to the video display control somehow stops functioning after the first 2 videos have played?

      Any ideas would be grand :).

      Thanks for your time,

      - Tony


      Further testing has revealed something else that will probably help with the arrival of an explanation that explains why this is happening... What I've done is I've assigned addEventListeners to almost every single video event type, so for example I have listeners for when the video has stopped, for seeking, ready, playhead_update etc.. While coding this in Flex Builder I left the video player I've built run in debug mode in my browser and wierdly enough when the second video has played and doesn't go onto the third - after letting it hang like that for a while (more or less 10 minutes), the third video started playing. I'm not sure how that happened, this is what inspired me to listen for almost every video event. The event type PLAYHEAD_UPDATE is what has shed some light - when the first video has played the playHeadTime matches the totalTime of that video, when the second video has played the playHeadTime doesn't match the totalTime of that video - this is probably why the handler which is supposed to execute once the video has completed doesn't execute. It appears to just hang just before the end of the video. It hangs at playHeadTime: 26.827, where the totalTime is: 26.86.

      Why does it hang just before the end of the video? I thought perhaps its just corrupt, but it also hangs with the third video.

      Thanks again for your time,

      - Tony