Copy link to clipboard
Copied
I have a flvplayback video player which uses a VideoEvent.PLAYHEAD_UPDATE event listener to drive a custom tape timer display. I am trying to use the event listener to also trigger a stop command to the video when the playheadTime reaches a certain value. Putting the .stop() method inside the event listener triggers a 1009 Error when it tries to execute. Using the .pause() method does work but it's not exactly what I'm looking for. Is there another way to trigger the stop?
Since Display is the only object being targeted in that line, and it is targeted in a line just before it without error, I suspect that line is not the first line in the trail of errors. I think the error is erupting from within the FLVPlayback component at some line relevant to a function within it named closeNS().
It is possible there is something being processed in that function which gets nulled but then with another call to the function maybe it is failing from there on.
What you might try
...Copy link to clipboard
Copied
Show the code that is not working for you.
Copy link to clipboard
Copied
function playVideo(videoTitle:String, seekTime:String, stoptime:String):void | |||||
{ | |||||
stopTime = (int(stoptime)); | |||||
TimerLabel.text = "00:00:00 \\ 00:00:00"; | |||||
Display.source = serverURL + videoTitle; | |||||
Display.seek(int(seekTime)); | |||||
Display.addEventListener(VideoEvent.PLAYHEAD_UPDATE, updateTapeTimer); | |||||
Display.addEventListener(VideoEvent.STATE_CHANGE, playerStateHandler); | |||||
StatusLabel.text = Display.state; | |||||
} | |||||
function updateTapeTimer(event:VideoEvent):void | |||||
{ | |||||
tapeTime = Display.playheadTime; | |||||
if(tapeTime > stopTime) | |||||
{ | |||||
Display.stop(); | |||||
} | |||||
var playHeadSecs:int = Math.round(Display.playheadTime); | |||||
var totalTimeSecs:int = Math.round(Display.totalTime); |
... formatting code for tape timer display
Copy link to clipboard
Copied
Go into your Flash Publish Settings and select the option to Permit Debugging. Run the file and see what line of code is being identified as the source of the problem in the 1009 error. The line number should follow directly after the first frame number identified.
Copy link to clipboard
Copied
Yes, debugginig is set and it shows the Display.stop() on line 371 as the culprit.
Copy link to clipboard
Copied
Here's the beginning of the error output. It repeats for a good 10 seconds before it clears.
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at fl.video::VideoPlayer/http://www.adobe.com/2007/flash/flvplayback/internal::closeNS()
at fl.video::VideoPlayer/stop()
at fl.video::FLVPlayback/stop()
at Function/Main/$construct/updateTapeTimer()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at fl.video::FLVPlayback/http://www.adobe.com/2007/flash/flvplayback/internal::handleVideoEvent()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at fl.video::VideoPlayer/http://www.adobe.com/2007/flash/flvplayback/internal::doUpdateTime()
at fl.video::VideoPlayer/http://www.adobe.com/2007/flash/flvplayback/internal::closeNS()
at fl.video::VideoPlayer/stop()
at fl.video::FLVPlayback/stop()
at Function/Main/$construct/updateTapeTimer()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at fl.video::FLVPlayback/http://www.adobe.com/2007/flash/flvplayback/internal::handleVideoEvent()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at fl.video::VideoPlayer/http://www.adobe.com/2007/flash/flvplayback/internal::doUpdateTime()
Copy link to clipboard
Copied
Since Display is the only object being targeted in that line, and it is targeted in a line just before it without error, I suspect that line is not the first line in the trail of errors. I think the error is erupting from within the FLVPlayback component at some line relevant to a function within it named closeNS().
It is possible there is something being processed in that function which gets nulled but then with another call to the function maybe it is failing from there on.
What you might try doing is removing the event listener inside the conditional so that it only executes the event handler until the event occurs and not afterwards.
if(tapeTime > stopTime){
Display.removeEventListener(VideoEvent.PLAYHEAD_UPDATE, updateTapeTimer);
Display.stop();
}
Copy link to clipboard
Copied
Thank you for your help Ned. I'm running out of time here so I will try your suggestion tomorrow and see how it goes.
Copy link to clipboard
Copied
That works Ned. Thanks again for your help.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now