Audio File - Finished?

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Tester2
Posts: 102
Joined: Wed May 18, 2011 7:02 pm

Audio File - Finished?

Post by Tester2 » Mon Aug 06, 2012 5:54 pm

Hey LiveCoders,

I have a card that when the user navigates to it, it plays an audio mp3 (stored within the file). I am using the "mobilePlaySoundOnChannel" command and have buttons that can Pause, Continue or Restart the audio.

I am trying to trap for when the audio file has finished playing so that I can automatically navigate the user to a different card.

I found I could do the following:

put mobileSoundChannelStatus (noise1) into tChannelStatus
if tChannelStatus = "stopped" then
go to card "Main Menu"
end if

But where should I put this piece of code? On OpenCard won't work...it would almost have to check this every few seconds to see if the audio had finished or not :(

Please advise and help!

Thanks so much.

-Tester2

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

Re: Audio File - Finished?

Post by Klaus » Mon Aug 06, 2012 6:02 pm

I found this in the "iOS Release Notes" (cough, cough 8) ):
...
When a sound has finished playing naturally (not stopped/replaced) on a given channel,
a soundFinishedOnChannel message is sent to the object which played the sound:
soundFinishedOnChannel channel, sound
...
This sounds like you could put this into the card script:

Code: Select all

on soundFinishedOnChannel tChannel,tSound
   if tChannel = YourChannelHere AND tSound = "Name of sound here" then
      ## Please ALWAYS use QUOTES around strings like NAMES of objects!
      go cd "some other card"
  end if
end soundFinishedOnChannel
Best

Klaus

Tester2
Posts: 102
Joined: Wed May 18, 2011 7:02 pm

Re: Audio File - Finished?

Post by Tester2 » Mon Aug 06, 2012 8:44 pm

As always Klaus, you rock!! :lol:

Worked lovely.

Thanks again.

-Tester2

Post Reply