mobileControlSet Player. How does it works for consecutive sounds?

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
trevix
Posts: 960
Joined: Sat Feb 24, 2007 11:25 pm
Location: Italy
Contact:

mobileControlSet Player. How does it works for consecutive sounds?

Post by trevix » Sat Sep 28, 2019 11:46 pm

I am trying to understand how to play, on iOS, different parts of the same sound file, one after the other in a row.
But I may have been missing something, since the results are mixed. The second sound starts at the wrong position...
May be this is not the correct way to do it?

The "v_zeroventiita.aiff" sound file is a recording of voice growing numbers, from 0 to 20. One for each second of the recording.
This is the script I am using:

Code: Select all

on MouseUp
put gPrefTF["AllPath"]["Sounds"] & "Voices/v_zeroventiita.aiff" into tSoundPath
          mobileControlCreate "player", "playerControl"
          put the result into playerID 
          mobileControlSet  playerID, "useApplicationAudioSession", "true" 
          mobileControlSet playerID, "filename", tSoundPath
          mobileControlSet playerID, "visible", false
          put 2000 into tStartTime
          put 3000 into tEndTime    
          mobileControlSet playerID, "startTime", tStartTime
          mobileControlSet playerID, "endTime", tEndTime
          mobileControlDo playerID, "play"
          wait 2 seconds with messages
          mobileControlDo playerID, "stop"
--now play another part of the file
          put 5000 into tStartTime
          put 6000 into tEndTime
          mobileControlSet playerID, "startTime", tStartTime
          mobileControlSet playerID, "endTime", tEndTime
          mobileControlDo playerID, "play"
          wait 2 seconds with messages
          mobileControlDelete playerID
end Mouseup
Somebody is willing to help?
Thanks
Trevix
OSX 14.3.1 xCode 15 LC 10 DP7 iOS 15> Android 7>

SteveB
Posts: 40
Joined: Mon Sep 30, 2019 4:49 pm

Re: mobileControlSet Player. How does it works for consecutive sounds?

Post by SteveB » Mon Sep 30, 2019 6:35 pm

The startTime is in intervals not milliseconds. Take a look at the timeScale property.

From the dictionary:

Reports the number of intervals per second of a movie or sound.

Use the timeScale property to convert internal movie or sound times into seconds.

The timeScale is the number of intervals per second of a movie or sound. These intervals are used for the player's startTime, endTime, duration, and currentTime properties, and you can use the timeScale property to convert from the time scale used by the movie or sound to seconds.

HTH

trevix
Posts: 960
Joined: Sat Feb 24, 2007 11:25 pm
Location: Italy
Contact:

Re: mobileControlSet Player. How does it works for consecutive sounds?

Post by trevix » Mon Sep 30, 2019 7:31 pm

May be I am missing something:
The "timeScale" property is unique to Mac,Windows and linux. It refers to a "player control" dragged from the tools.
Here, I am talking about iOS and a mobileControlCreate "player", where, from the dictionary:
"startTime" (iOS Only): The position at which playback should start, measured in milliseconds (maps to the native initialPlaybackTime property). This is an integer value.
"endTime" (iOS Only): The position at which playback should end, measured in milliseconds (maps to the native endPlaybackTime property). This is an integer value. Set to -1 to make the video to play to the end.
Am I wrong?
Thanks
Trevix
OSX 14.3.1 xCode 15 LC 10 DP7 iOS 15> Android 7>

trevix
Posts: 960
Joined: Sat Feb 24, 2007 11:25 pm
Location: Italy
Contact:

Re: mobileControlSet Player. How does it works for consecutive sounds?

Post by trevix » Mon Sep 30, 2019 9:00 pm

Anyway, I ended up doing it with two players and it works. Seems redundant though.

Code: Select all

on mouseUp pMouseButton
     put gPrefTF["AllPath"]["Sounds"] & "Voices/v_zeroventiita.aiff" into tSoundPath
     --player 1
     mobileControlCreate "player", "playerControl" 
     put the result into playerID 
     mobileControlSet playerID, "filename", tSoundPath
     mobileControlSet  playerID, "useApplicationAudioSession", "true" 
     mobileControlSet playerID, "visible", false
     put 2000 into tStartTime1
     put 3000 into tEndTime1
     mobileControlSet playerID, "startTime", tStartTime1
     mobileControlSet playerID, "endTime", tEndTime1
     mobileControlDo playerID, "play"
     wait 1 seconds with messages
     mobileControlDelete playerID
     
     --player 2
     mobileControlCreate "player", "playerControl2" 
     put the result into playerID2 
     mobileControlSet playerID2, "filename", tSoundPath
     mobileControlSet  playerID2, "useApplicationAudioSession", "true" 
     mobileControlSet playerID2, "visible", false
     put 12000 into tStartTime2
     put 13000 into tEndTime2
     mobileControlSet playerID2, "startTime", tStartTime2
     mobileControlSet playerID2, "endTime", tEndTime2
     mobileControlDo playerID2, "play"
     wait 1 seconds with messages
     mobileControlDelete playerID2
end mouseUp
Trevix
OSX 14.3.1 xCode 15 LC 10 DP7 iOS 15> Android 7>

Post Reply

Return to “iOS Deployment”