Page 1 of 1

looping video and callbacks

Posted: Tue Nov 22, 2011 11:56 am
by kevin11
Hi,

I want to play a video in a player, and have it play forwards, then backwards, then forwards...
and before you ask, the video would be a rotation of an object, where I set up just a section of the video to play.
This would give the effect of the object slowly spinning backs and forwards, but not a complete rotation.

I'm trying to do this with callbacks.
First time round, I set up a callback so that when the player gets to x, the callback is invoked, which sets the play speed to the negative of the play speed. I then set up a new call back to be triggered when it gets back to the first frame, which of course sets the play speed back to positive.

This works first time round, the end is reached, the callback invoked, the speed set to negative, and the movie plays backwards. The property inspector shows a new callback is in place to be invoked when the movie gets back to the first frame.

However, the new callback is never invoked.

It seems that once a callback is set up, the player can be given a new callback, which it merely ignores.
Starting and stopping the player makes no difference - subsequent callbacks are ignored.

Any suggestions please ?

Re: looping video and callbacks

Posted: Tue Nov 22, 2011 12:06 pm
by Klaus
Hi Kevin,

yep, I know that there are some problems with callbacks only get triggered once!

In your case I would not rely on callbacks, just "catch" the "playstopped" message
like this, out of my head and untested, but you get the picture :D

Put this into the players script

Code: Select all

on playstopped
  if the currenttime of me = 0
   ## Player reached the FIRST frame after playing backwards!
   set the playrate of me to -1
  else
  ## Otherwise start "normally"
   set the playrate of me to 1
  end if
end playstopped
At least worth a try 8)


Best

Klaus

Re: looping video and callbacks

Posted: Tue Nov 22, 2011 12:51 pm
by kevin11
Thanks Klaus,

Tried that. Playstopped handler doesn't get invoked. I notice also that playstopped isn't supported for ios.

Re: looping video and callbacks

Posted: Tue Nov 22, 2011 12:54 pm
by kevin11
oops, forgot to say, I think playstopped isn't invoked because when it is in a loop as far as the player is concerned it hasn't stopped.

is there some other handler that can be invoked, that could check the current pay direction and frame number, and reverse the pay direction ?

Thanks

Re: looping video and callbacks

Posted: Tue Nov 22, 2011 12:59 pm
by Klaus
Ah, you didn't mention iOS!

After checking the "iOS Release Notes" it looks like you are out of luck.
At least I don't have any more ideas, since I don't develop for iOS.


Best

Klaus

Re: looping video and callbacks

Posted: Tue Nov 22, 2011 1:06 pm
by kevin11
true, I didn't mention ios.

But doesn't work on any other platform, so that keeps it all nice and compatible then ! :wink:

Re: looping video and callbacks

Posted: Tue Nov 22, 2011 1:24 pm
by Klaus
Hi Kevin,

this might work on the desktop Mac/Win, if you do not LOOP the movie. 8)
Will move this thread to the iOS forum now!


Best

Klaus