|Type||Topic||Plugin||Version||macOS||Windows||Linux||Console & Web||iOS|
|class||Cocoa||MBS MacCocoa Plugin||9.4||Yes||No||No||Yes, macOS only||No|
This class supports the same audio encodings and file formats that are supported by Core Audio and QuickTime.
To use this class, initialize a new instance with the desired file or audio data. You can configure assorted aspects of the audio playback, including the volume and whether the sound loops before you play it. Depending on the type of the audio data, this class may use either Core Audio or QuickTime to handle the actual playback. (Typically, it uses Core Audio to play files in the AIFF, WAVE, NeXT, SD2, AU, and MP3 formats and may use it for other formats in the future as well.) Playback occurs asynchronously so that your application can continue doing work.
You should retain NSSound objects before initiating playback or make sure you have a strong reference to them in a garbage-collected environment. Upon deallocation, a sound object stops playback of the sound (as needed) so that it can free up the corresponding audio resources. If you want to deallocate a sound object immediately after playback, assign a delegate and use the sound:didFinishPlaying: method to deallocate it.
If you want to play the system beep sound, use the NSBeep function.
- 5 properties
- 16 methods
- method channelMapping as Integer()
- method Constructor
- method Constructor(data as MemoryBlock)
- method Constructor(file as folderitem, ByReference as boolean)
- method Constructor(url as string, ByReference as boolean)
- method duration as Double
- method isPlaying as boolean
- method name as string
- method pause as boolean
- method play as boolean
- method resume as boolean
- method setChannelMapping(mapping() as Integer)
- method setDelegate(delegate as NSSoundDelegateMBS)
- method setName(name as string) as boolean
- method stop as boolean
- method writeToPasteboard
- 11 shared methods
- shared method availableSounds as string()
- shared method canInitWithPasteboard as boolean
- shared method NSSoundPboardType as string
- shared method soundNamed(name as string) as NSSoundMBS
- shared method soundUnfilteredFileTypes as string()
- shared method soundUnfilteredPasteboardTypes as string()
- shared method soundUnfilteredTypes as string()
- shared method soundWithContentsOfFile(file as folderitem, ByReference as boolean) as NSSoundMBS
- shared method soundWithContentsOfURL(url as string, ByReference as boolean) as NSSoundMBS
- shared method soundWithData(data as MemoryBlock) as NSSoundMBS
- shared method soundWithPasteboard as NSSoundMBS
This class has no sub classes.
Some events for this class:
- NSSoundDelegateMBS.SoundFinished(s as NSSoundMBS, didFinishPlaying as boolean)
The items on this page are in the following plugins: MBS MacCocoa Plugin.
MBS Xojo blog