Skip to main content
Participating Frequently
February 12, 2013
Answered

FLVPlayBack.stop()

  • February 12, 2013
  • 1 reply
  • 982 views

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?

This topic has been closed for replies.
Correct answer Ned Murphy

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()


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();

}



1 reply

Ned Murphy
Legend
February 12, 2013

Show the code that is not working for you.

irallenAuthor
Participating Frequently
February 12, 2013
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

irallenAuthor
Participating Frequently
February 12, 2013

Yes, debugginig is set and it shows the Display.stop() on line 371 as the culprit.


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()