0

I am trying to modify the Strobe media playback to seek across a video based on mouse clicks on a button and not on the control bar. Each click should take me ahead by 'n' seconds and the it should clear the buffer and insert the correct fragments automatically.

To do this, I have a function which is triggered based on when the button is clicked, but I'm not able to seek. I get a error: cannot access a property or method of a null object reference

Can someone tell me whats wrong here:

        override protected function onMouseClick(event:MouseEvent):void
    {

        httpStreamSource.seek(9);
//          mediaPlayer.seek(55);

        showRight = !showRight;
        if(showRight)
            setFace(down);
        else
            setFace(up);
    }

Thanks in advance!

jamie
  • 89
  • 4
  • 11
  • You should show the line of the error - null reference means that object is not accessible on which you are invoking method/property. – Lukasz 'Severiaan' Grela Oct 25 '12 at 12:47
  • Thanks for the response, the program compiles ok, this error occurs when I play a video. Is it possible to get a line number through debug? When I am not using the seek lines, there is no error, so I am pretty certain that the reason has to be in this function. – jamie Oct 25 '12 at 12:53
  • so add full error stack so we can see propagation of the error. also httpStreamSource and mediaPlayer must not be null. – Lukasz 'Severiaan' Grela Oct 25 '12 at 14:16
  • Hi, sorry about my ignorance, but do you want to see the flashlog entries? or is it something else that you are asking for. Thanks. – jamie Oct 25 '12 at 14:54
  • When the error is thrown in debug version of flash player it is provided in the error popup and it shows the error details eg.: >>>TypeError: Error #1009: Cannot access a property or method of a null object reference. at Main/run()[C:\test\src\Main.as:181] at Main/libLoadHandler()[C:\test\src\Main.as:375] << – Lukasz 'Severiaan' Grela Oct 26 '12 at 07:38
  • Hi, Im sorry for my late response,here is the errorstack`TypeError: Error #1009: Cannot access a property or method of a null object reference.at org.osmf.player.chrome.widgets::JumpButton/_seekVideo()[I:\OSMF\player\StrobeMediaPlayback\src\org\osmf\player\chrome\widgets\JumpButton.as:49]at org.osmf.player.chrome.widgets::JumpButton/onMouseClick()[I:\OSMF\player\StrobeMediaPlayback\src\org\osmf\player\chrome\widgets\JumpButton.as:37]at org.osmf.player.chrome.widgets::ButtonWidget/onMouseClick_internal()[I:\OSMF\player\StrobeMediaPlayback\src\org\osmf\player\chrome\widgets\ButtonWidget.as:95].` – jamie Oct 29 '12 at 08:36
  • here are the lines: `override protected function onMouseClick(event:MouseEvent):void { var seekTo : Number = ( 5 ); _seekVideo( seekTo ); //line37 showRight = !showRight; if(showRight) setFace(down); else setFace(up); downManager.setBranch(!downManager.getBranch()); } private function _seekVideo( seekTo : Number ):void { if (mediaPlayer.canSeekTo(seekTo*mediaPlayer.duration)) mediaPlayer.seek( seekTo * mediaPlayer.duration );//line49 }` and on line 95 of ButtonWidget I have `onMouseClick(event);`. Please help me out. Thanks in advance. – jamie Oct 29 '12 at 08:37

1 Answers1

0

for seek n-seconds ahead you should take current time add n-seconds and feed this to seek method.

for your null object error you MUST make sure that the object exists:

TypeError: Error #1009: Cannot access a property or method of a null object reference.at org.osmf.player.chrome.widgets::JumpButton/_seekVideo()[I:\OSMF\player\StrobeMed‌​iaPlayback\src\org\osmf\player\chrome\widgets\JumpButton.as:49]

at line 49 you have only one object: mediaPlayer - add test if it exists before using it:

private function _seekVideo( seekTo : Number ):void 
{ 
    if (mediaPlayer && mediaPlayer.canSeekTo(seekTo * mediaPlayer.duration))
    {
        mediaPlayer.seek( seekTo * mediaPlayer.duration );//line49 
    }
}

this will prevent the TypeError you should innvestigate why the mediaPlayer object is not available at the time you click on it.

best regards

Lukasz 'Severiaan' Grela
  • 6,078
  • 7
  • 43
  • 79
  • Hi, Thanks a lot. I managed to zero down to the error and solve it. But now when I try to execute the same routine, it returns a `error: The specified capability is not currently supported`. Doing further digging, I saw that the mediaPlayer.canSeekTo if false for any point in the video. I am not sure why such a thing would occur. I am performing HDS-VOD using strobe. Any ideas would be of great use! Thanks in advance! – jamie Oct 30 '12 at 13:39