iOS Callbacks

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Brittgriscom
Posts: 95
Joined: Wed Mar 30, 2011 10:15 am

iOS Callbacks

Post by Brittgriscom » Wed Apr 06, 2011 12:41 pm

How do I do callbacks in iOS? I need the words to change color as the text is read in my storybook app. Do I need to send in time for each word?

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

Re: iOS Callbacks

Post by Klaus » Wed Apr 06, 2011 1:15 pm

Hi Britt,

as Bernd already explained to you in another thread, "callbacks" are a special PLAYER OBJECT feature
(maybe even QuickTime only?), "player objects" (like in the desktop versions) are NOT supported (yet?)
on iOS, so you, you will need to use "send... in ...".


Best

Klaus

Brittgriscom
Posts: 95
Joined: Wed Mar 30, 2011 10:15 am

Re: iOS Callbacks

Post by Brittgriscom » Wed Apr 06, 2011 1:24 pm

Can I use mpmovieplayercontroller to play audio files?

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

Re: iOS Callbacks

Post by Klaus » Wed Apr 06, 2011 1:38 pm

Hi Britt,

I doubt, since the docs only read "video playback" for this.
Why don't you test this? 8)


Best

Klaus

Brittgriscom
Posts: 95
Joined: Wed Mar 30, 2011 10:15 am

Re: iOS Callbacks

Post by Brittgriscom » Wed Apr 06, 2011 1:55 pm

Apparently you can, and it does play mp3s, but it doesn't have anything like callbacks as far as I can tell.

According to the iOS reference documents, it uses QuickTime so maybe callbacks are possible with it.

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

Re: iOS Callbacks

Post by Klaus » Wed Apr 06, 2011 2:29 pm

Hi Britt,
Brittgriscom wrote:Apparently you can, and it does play mp3s, but it doesn't have anything like callbacks as far as I can tell.
erm, what part of "callbacks on iOS are not supported (yet)" did you not understand? 8)
Brittgriscom wrote:According to the iOS reference documents, it uses QuickTime so maybe callbacks are possible with it.
Well, fine, please tell us when your tests are successful! :mrgreen:


Best

Klaus

Nikovash
Posts: 15
Joined: Thu Mar 24, 2011 7:38 am

Re: iOS Callbacks

Post by Nikovash » Sun Apr 10, 2011 8:25 am

Well I am not entirely sure they could be called callbacks, but there are supposed to be messages that the MPMoviePlayerController is supposed to be sending, but doesn't

IE:
playerPropertyAvailable
playerProgressChanged
playerEnterFullscreen
playerLeaveFullscreen
playerMovieChanged
playerFinished
playerStopped
playerError

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4163
Joined: Sun Jan 07, 2007 9:12 pm

Re: iOS Callbacks

Post by bn » Mon Apr 11, 2011 1:45 pm

Hi Nikovash,

I tried the playerFinished and the playerStopped callback.

The playerFinished callback is sent. The playerStopped callback according to the iOS documentation is sent when "The content finished playing through due to a user exit." I could not trigger that callback.

iphoneControlGet sMovieID, playbackstate

gives you the information about the state of the movie.(Button What is up?")

All handling of the movie is in the card script, the buttons just call a handler in the card script to play, pause, stop etc.

I have set up a small stack that illustrates the various possibilities. It includes a small sample movie, the path in the Standalone Application Settings should work since it the movie is in the same folder, but in case it does not work you would have to reasign the path to the movie in the Standalone Application Settings -> Copy Files

Kind regards

Bernd
Attachments
iOSMovieCallbacks.zip
(68.38 KiB) Downloaded 373 times

Brittgriscom
Posts: 95
Joined: Wed Mar 30, 2011 10:15 am

Re: iOS Callbacks

Post by Brittgriscom » Mon Apr 11, 2011 11:15 pm

I don't see how I would use this to change the color of my words as they were read.

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4163
Joined: Sun Jan 07, 2007 9:12 pm

Re: iOS Callbacks

Post by bn » Mon Apr 11, 2011 11:31 pm

Hi Britt,

it is not meant in itself to give you the callbacks you need. You would still have to roll your own. The only advantage of using the movie player would be that when the user pauses the player you can get the currentTime and know where you are when you resume the callbacks. That was the whole idea of pointing you to this method.
You could do a send in time handler that has a counter (script local variable) to tell you how many times it has been run and triggered a message from a list, one callback per line with the time(ms) as item 2, optionally an item 3 the relative time (ms) to next callback . Then you have the relative times in millseconds and you stopped after the fifth callback at 5000 milliseconds and the user stopped at 5500 milliseconds (the currentTime) then you would resume your sound file and send the next send in time in 500 milliseconds, assuming a regular intervall of 1000 milliseconds between callbacks.

This is a very rough outline of how it could be done. There is enough to take into consideration but if you get it going you would have a pause/resume function in your app.

Kind regards

Bernd

Post Reply