AppleScript sound file not playing...

Hi, I am trying to create an application bundle that plays a sound when opened. I am using a python helper script available from this link: http://files.macscripter.net/joy/files/macsound.py
instead of the main(), however, I have replaced the contents with the following code.


property myname : "Sauterbraten"

on run
	my main()
end run


on main()
	try
		-- searching for the sound files 
		set soundfiles to ""
		
		set soundfile to ("(path to me):Contents:Resources:RickRollD.aiff")
		set soundfile to POSIX path of soundfile
		set soundfiles to soundfiles & space & quoted form of (POSIX path of soundfile)
		
		-- playing the sound files using a Python script utilizing NSSound
		set pyscript to POSIX path of (((path to me) as Unicode text) & "Contents:Resources:macsound.py")
		set command to "python " & quoted form of pyscript & soundfiles
		set command to command as «class utf8»
		do shell script command
		-- catching unexpected errors 
	on error errmsg number errnum
		tell me
			activate
			display dialog "Sorry, an error occured" & return & return & errmsg & " (" & errnum & ")" buttons {"OK"} default button 1 with icon caution with title myname
		end tell
	end try
end main

However, I end up with an error with traceback to the macsound.py files. Can someone please help me?

This line is wrong:


set soundfile to ("(path to me):Contents:Resources:RickRollD.aiff")

Should be:


set soundfile to ((path to me) as text) & "Contents:Resources:RickRollD.aiff"

Thanks, it works perfectly now.
I’m just curious though, is there a way to constantly set the volume to 7 after the sound plays, so the user cannot turn off the sound unless he force-quits it?

Did you know it’s not necessarily to use a python script. You could just do something like this

set soundFile to (choose file with prompt "Choose a file to play")
set soundFile to POSIX path of soundFile
do shell script "afplay " & quoted form of soundFile

Hope it helps,
ief2

Hey, thanks. I hope this version will be at least a little faster than the alternative. By the way, is there a way to constantly set the volume to 7 so the user cannot mute unless he force-quits the application?