looping video and callbacks

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
kevin11
Posts: 101
Joined: Thu Aug 11, 2011 5:02 pm

looping video and callbacks

Post by kevin11 » Tue Nov 22, 2011 11:56 am

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 ?

Klaus
Posts: 14182
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: looping video and callbacks

Post by Klaus » Tue Nov 22, 2011 12:06 pm

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

kevin11
Posts: 101
Joined: Thu Aug 11, 2011 5:02 pm

Re: looping video and callbacks

Post by kevin11 » Tue Nov 22, 2011 12:51 pm

Thanks Klaus,

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

kevin11
Posts: 101
Joined: Thu Aug 11, 2011 5:02 pm

Re: looping video and callbacks

Post by kevin11 » Tue Nov 22, 2011 12:54 pm

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

Klaus
Posts: 14182
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: looping video and callbacks

Post by Klaus » Tue Nov 22, 2011 12:59 pm

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

kevin11
Posts: 101
Joined: Thu Aug 11, 2011 5:02 pm

Re: looping video and callbacks

Post by kevin11 » Tue Nov 22, 2011 1:06 pm

true, I didn't mention ios.

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

Klaus
Posts: 14182
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: looping video and callbacks

Post by Klaus » Tue Nov 22, 2011 1:24 pm

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

Post Reply