Still stuck on playing a sound with a player
livfoss at mac.com
Wed Dec 18 17:42:50 EST 2013
Thanks Jacque, it's amazing how patient you are giving answers on this issue!
Actually I do think I am addressing the sound files correctly. I ask for my mp3 files to be included in the 'copy files' section of the standalone settings. They then end up in the MacOS part of the plist of the application at the same level as the executable program itself (this is shockingly under-explained in the User Guide, BTW). So a script like this when the mainstack starts up, or anyway before the players get used:
set the itemDel to slash
put the effective filename of this stack into tPath
put "Recording.mp3" into last item of tPath
if (there is a file tPath) then
lock messages -- so as not to fire the 'playstopped' message
set the filename of player "myPlayer" of stack "sounds" to tPath
answer error "Could not find Recording. Path was:" && tPath
should work both in the IDE and the standalone, or give an error. Sadly in my case neither applies. And no 'playstopped' message is sent later, after I try to activate the player properly. Works in the IDE.
I have now been able to prove that the file paths exist in the standalone, and that the actual players can play the sounds, if I expose their little stack with the controllers on it and simply click on one of the controllers. So all that I am unable to do is to
start player "myPlayer" of cd 1 of stack "sounds"
from within another stack.
When I execute this, there is nothing in the result, but it's as if that line of code hadn't been executed. In fact this really seems to be the case, because the player doesn't even receive a 'playstarted' message. Both 'playStarted' and 'playStopped' are received when the thing is run from the IDE without script changes.
Still working on it, for example by putting a button in the sound stack which starts the player, then sending 'mouseUp' to the button. The button gets the message, but same non-result. If I can see the "sounds" stack and click the button, it works.
I suppose it will be obvious in the end.
Thanks for all your suggestions.
On 18 Dec 2013, at 19:43, J. Landman Gay wrote:
> On 12/18/13 12:27 PM, Graham Samuel wrote:
>> Finally I don't understand what setting the currentTime does in your
>> script. When I play the sound in the IDE without setting the
>> currentTime, it always plays, but not (so far) in the standalone. I
>> have no idea why.
> The currentTime sets the start position of the playback. Zero is the beginning. When you load a new filename into a player, the postion is set to zero by default, so adding that line is theoretically unnecessary but doesn't hurt.
> The file paths in a standalone are not necessarily the same as the filepaths in the IDE, which could cause the problem. What is the filepath you've assigned to the player? You may need to calculate a path in your script so that it works in both the IDE and the standalone.
> Jacqueline Landman Gay | jacque at hyperactivesw.com
> HyperActive Software | http://www.hyperactivesw.com
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
More information about the Use-livecode