Play sound and play stop

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
andyh1234
Posts: 476
Joined: Mon Aug 13, 2007 4:44 pm
Contact:

Play sound and play stop

Post by andyh1234 » Mon Nov 25, 2024 4:32 pm

I'm using the play command to play a sound filled successfully on iOS, works great but issuing play stop does not stop playback.

Is there an easy way to stop playback of an MP3 on iOS?

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10305
Joined: Wed May 06, 2009 2:28 pm

Re: Play sound and play stop

Post by dunbarx » Mon Nov 25, 2024 7:02 pm

Hi.

I have never played anything, but the dictionary does not list a "play stop" command. It does speak about a "stop" command:
stop [playing] {player | videoClip | audioClip}
Craig

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

Re: Play sound and play stop

Post by Klaus » Mon Nov 25, 2024 7:10 pm

Craig,

Code: Select all

play "path/to/file.mp3"
is one possible and official way to PLAY a file on iOS.
And "play stop" is the official way to stop this playback on iOS.
Look in the dictionary under "play". 8)

No idea why it does not work as advertized? Maybe a bug?
What version are you using, Andy?


Best

Klaus

andyh1234
Posts: 476
Joined: Mon Aug 13, 2007 4:44 pm
Contact:

Re: Play sound and play stop

Post by andyh1234 » Mon Nov 25, 2024 7:54 pm

Hi,

Ive founf a solution, simply

play empty

stops the playback.

It would be great if there was a way to know if something is currently playing so I could swap the play button for a stop button and have that automatically flip back to a play button at the end of the playback but it looks like this is not possible yet on mobile devices.

Thanks for the help.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10305
Joined: Wed May 06, 2009 2:28 pm

Re: Play sound and play stop

Post by dunbarx » Mon Nov 25, 2024 7:55 pm

Klaus.

Aha, "under play".

Craig

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

Re: Play sound and play stop

Post by Klaus » Mon Nov 25, 2024 11:19 pm

andyh1234 wrote:
Mon Nov 25, 2024 7:54 pm
Hi,

Ive founf a solution, simply
play empty
stops the playback.

It would be great if there was a way to know if something is currently playing so I could swap the play button for a stop button and have that automatically flip back to a play button at the end of the playback but it looks like this is not possible yet on mobile devices.

Thanks for the help.
This IS in fact possible, but not with the simple PLAY command.
Look up "mobileControlCreate" (player) and "mobilecontrolget()" in the dictionary.

Sophiasm
Posts: 1
Joined: Thu May 15, 2025 4:10 am
Contact:

Re: Play sound and play stop

Post by Sophiasm » Thu May 15, 2025 4:14 am

Klaus wrote:
Mon Nov 25, 2024 11:19 pm

This IS in fact possible, but not with the simple PLAY command.
Look up "mobileControlCreate" (player) and "mobilecontrolget()" in the dictionary.
Can you share a specific example of how to use mobileControlCreate and mobileControlGet() to check the playback status and change the corresponding Play/Stop button on mobile devices?

PaulDaMacMan
Posts: 683
Joined: Wed Apr 24, 2013 4:53 pm
Contact:

Re: Play sound and play stop

Post by PaulDaMacMan » Fri May 16, 2025 12:17 am

I'm not sure about the latest versions as I'm using old version (9.6.3) on an slightly older platform, but ...
I recommend the mobilePlayer control for media play back on mobile, works well on Android as well.

But if you do still want to use 'play' command then try it with its AC/VC audioClip/videoClip form:
play VC tPathToMyMp3File
that worked for me on Android with mp3 (and even with MIDI files on Android)

Do NOT try to use regular play tFile version of the command with an mp3 file on recent macOS, it will probably make a horrible screeching noise with no way to 'play stop' (nor does play "stop" work) with that command on macOS, I assume it did work properly at one time (probably used QuickTime 'under the hood'). I'm not sure if 'Play empty' works as a workaround on macOS. You can see new posix process IDs are created for each playing file and if you 'kill pID' those newly created processes screeching will stop, so thats one way to stop a wild play command.
My GitHub Repos: https://github.com/PaulMcClernan/
Related YouTube Videos: PlayList

Post Reply