Thanks Brian On Dec 4, 2007, at 4:32 PM, Brian Stevens wrote: > > On Dec 4, 2007, at 1:21 PM, Steve wrote: > >> What is the best way to play the System Alert sounds and resource >> files with snd in FBtoC? > Steve, > > There is a least one FBtoC bug (#249) with the FB Sound statement, > so my own code uses the QuickTime movie calls to play a sound. It > works perfectly. I'm using the following fn to play AIFF alert > sounds (as found in System/Library/Sounds). If you are using an > FSSpec, just change the argument in the function header and remove > the call to FSGetCatalogInfo since its only purpose is to retrieve a > spec for the ref. Also, notice the way the file is opened in > OpenMovieFile as read only. This fn assumes only playing a sound and > not modifying the file. It would require modifications if more than > playing the sound is needed. > > > local fn PlaySound( inRef as ^FSRef ) > dim as OSErr @ err > dim as Movie @ theSound > dim as short @ fileRefNum > dim as FSSpec @ outSpec > > // Convert the FSRef back into an FSSpec > err = fn FSGetCatalogInfo( #inRef, _kFSCatInfoNone,#_nil, #_nil, > outSpec, #_nil ) > // Initialize QuickTime > err = fn entermovies > long if (_noErr == err) > // Open new QT movie file from incoming FSSpec > err = fn OpenMovieFile( #outSpec, fileRefNum, _fsRdPerm ) > long if (_noErr == err) > // Convert file to Sound > err = fn NewMovieFromFile( theSound, fileRefNum,#_nil, "", > _newMovieActive, #_nil ) > long if (_noErr == err) > err = Fn CloseMovieFile( fileRefNum ) > long if (_noErr == err) > // Set play point to beginning of sound > GoToBeginningOfMovie( theSound ) > long if (_noErr == err) > // Start playing sound > StartMovie( theSound ) > long if (_noErr == err) > // Check to see if sound is playing > while fn IsMovieDone( theSound ) > //gPlaying = _true > // Play the sound > MoviesTask( theSound, 0 ) > // When done, close sound > DisposeMovie( theSound ) > wend > end if > end if > end if > end if > end if > end if > end fn = err >