Triggering Events At Specific Player Times?

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
jpatten
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 45
Joined: Tue May 06, 2008 11:24 pm

Triggering Events At Specific Player Times?

Post by jpatten » Sun Nov 24, 2013 10:58 pm

Hi All...

Is it possible to trigger events at specific times during the playback of a movie or an audio file in iOS? I had looked at an older CallBacks tutorial but callbacks are not iOS compatible.

I also noticed there is a mobileControlGet (player_id, currentTime) but I was not sure how I could report out that currentTime while a media played along. My original plan was checking the currentTime while the media played and then acting on the reported time when it was at specific times.

Is there an example stack of using currentTime in this manner? Or is reporting the currentTime, while a piece of media plays not possible?

Thank you!

Jellicle
Posts: 453
Joined: Thu Feb 24, 2011 11:07 am

Re: Triggering Events At Specific Player Times?

Post by Jellicle » Sun Nov 24, 2013 11:21 pm

Try something like this:

Code: Select all

on playmovie
  mobileControlDo "myPlayerControl", "play"
  send "trackCurrentTime" to this card in 1 second
end playmovie

on trackCurrentTime
  put mobileControlGet ("myPlayerControl", "currenttime") into currentMovieTime
  switch
    case currentMovieTime = 5
      show image "5 seconds"
      break
    case currentMovieTime = 10
      show image "10 seconds"
      break
  end switch
  send "trackCurrentTime" to this card in 1 second
end trackCurrentTime
Gerry
14" MacBook Pro
Former LiveCode developer.
Now recovering.

Jellicle
Posts: 453
Joined: Thu Feb 24, 2011 11:07 am

Re: Triggering Events At Specific Player Times?

Post by Jellicle » Sun Nov 24, 2013 11:41 pm

Oh and put that code in the card script.

Gerry
14" MacBook Pro
Former LiveCode developer.
Now recovering.

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Triggering Events At Specific Player Times?

Post by Simon » Sun Nov 24, 2013 11:53 pm

I wonder if the case should be padded?
case min(5.05,max(currentMovieTime,4.95))
because of currentMovieTime is in millisecs.

Simon
Edit: Nah that isn't it.
Just a plain old
case currentMovieTime >=4.95 and currentMovieTime <=5.05
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Jellicle
Posts: 453
Joined: Thu Feb 24, 2011 11:07 am

Re: Triggering Events At Specific Player Times?

Post by Jellicle » Mon Nov 25, 2013 1:32 am

Simon

Shhhhhh. Leave her/him something to work out on her/his own :)

Gerry
14" MacBook Pro
Former LiveCode developer.
Now recovering.

jpatten
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 45
Joined: Tue May 06, 2008 11:24 pm

Re: Triggering Events At Specific Player Times?

Post by jpatten » Mon Nov 25, 2013 6:54 am

Thanks Gerry and Simon!

I just took the easy way out and rounded :)

put the round of (mobileControlGet ("iosControl", "currenttime")/1000) & " seconds" into cd fld "videoTime"

Cheers!

Post Reply