Playing MP3 & AIFF files with Quicktime Player

I am developing an application that, among other things, will play MP3 & AIFF files that the user will choose from a list. I use “choose file” to get a file reference but when I tell Quicktime Player to “play” that reference, nothing happens. What am I doing wrong? Thanks.

Try this:

choose file without invisibles
get ("file://" & POSIX path of result)
tell application "QuickTime Player"
	open location result
	play (item 1 of result)
end tell

Model: Mac mini
AppleScript: 1.10
Browser: Safari 412
Operating System: Mac OS X (10.4)

Thanks, I’ll try it this evening. However, is it possible to play an audio file without opening windows on QTP? I would prefer that the only application the user sees be the one I am writing. Can QTP open as a faceless app in this case?

To you and all those who help others in this forum: Thank you, especially for the understanding you all show for beginners like me. RalphC

I don’t think so. However, you could use Play Sound.

Thanks again. I looked at Play Sound, but one of the features that my sound file player needs to have is to be able to play between arbitary points in a sound file, a feature which Play Sound does not offer. In effect, I need to be able to play just a selection from the file. QTP looks like it can do this, if I can avoid displaying all its windows. Play Sound uses QTP to play its sound files and it doesn’t show QTP windows. Maybe it can only be done through the C++ or C interfaces. RalphC

Not quite. Play Sound uses QuickTime. ( QuickTime Player also uses QuickTime.)

See, I told you I was a beginner. David Blache, the developer of Play Sound at Microcosm Software, has indicated to me that he will try to include the feature to play a selection in the next release, once he has solved the dock problem with OS 10.4.x. So, this is the perfect answer to my problem. Thanks for pointing me in that direction again.