Platforms to show: All Mac Windows Linux Cross-Platform

Back to NSSoundMBS class.

NSSoundMBS.availableSounds as string()

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa MBS MacBase Plugin 9.5 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Returns an array of the available sounds.
Example
dim sounds(-1) as string = NSSoundMBs.availableSounds

// play first sound
dim n as NSSoundMBS = NSSoundMBS.soundNamed(sounds(0))

call n.play

// show list of sounds
MsgBox Join(sounds,EndOfLine)

You can use the names in this array for the soundNamed function.

NSSoundMBS.canInitWithPasteboard as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa MBS MacBase Plugin 9.4 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Indicates whether the receiver can create an instance of itself from the data in a pasteboard.

true when the receiver can handle the data represented by pasteboard; false otherwise.

The soundUnfilteredPasteboardTypes method is used to find out whether the class can handle the data in pasteboard.

NSSoundMBS.NSSoundPboardType as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa MBS MacBase Plugin 14.3 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
The NSSound class defines this common pasteboard data type.

NSSoundMBS.soundNamed(name as string) as NSSoundMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa MBS MacBase Plugin 9.4 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Returns the NSSound instance associated with a given name.
Example
dim s as NSSoundMBS

s=NSSoundMBS.soundNamed("Submarine")

call s.play

NSSound instance initialized with the sound data identified by soundName.

The returned object can be one of the following:

One that's been assigned a name with setName.

One of the named system sounds provided by the Application Kit framework If there's no known NSSound object with soundName, this method tries to create one by searching for sound files in the application's main bundle (see NSBundle for a description of how the bundle's contents are searched). If no sound file can be located in the application main bundle, the following directories are searched in order: ~/Library/Sounds, /Library/Sounds, /Network/Library/Sounds or /System/Library/Sounds.

If no data can be found for soundName, no object is created, and nil is returned.

The preferred way to locate a sound is to pass a name without the file extension. See the class description for a list of the supported sound file extensions.

NSSoundMBS.soundUnfilteredFileTypes as string()

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa MBS MacBase Plugin 14.3 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Provides the list of file types the NSSound class understands.

Returns array of strings representing the file types the NSSound class understands.
The returned array may be passed directly to the runModalForTypes method of the NSOpenPanel class.
Available in OS X v10.0 and later. Deprecated in OS X v10.5.

NSSoundMBS.soundUnfilteredPasteboardTypes as string()

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa MBS MacBase Plugin 14.3 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Provides a list of the pasteboard types that the NSSound class can accept.

Array of pasteboard types that the NSSound class can accept.
Available in OS X v10.0 and later. Deprecated in OS X v10.5.

NSSoundMBS.soundUnfilteredTypes as string()

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa MBS MacBase Plugin 14.3 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Provides the file types the NSSound class understands.

Returns array of UTIs identifying the file types the NSSound class understands.

Available in OS X v10.5 and later.

NSSoundMBS.soundWithContentsOfFile(file as folderitem, ByReference as boolean) as NSSoundMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa MBS MacBase Plugin 9.4 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Initializes a NSSound object with the the audio data located at a given file.
Example
dim s as NSSoundMBS
dim f as FolderItem

f=SpecialFolder.Desktop.Child("test.mp3")

s=NSSoundMBS.soundWithContentsOfFile(f,true)

call s.play

// sound continues to play even after NSSoundMBS object is destroyed.

file: Path to the sound file.
ByReference: When true only the name of the sound is stored with the NSSound instance when archived using encodeWithCoder:; otherwise the audio data is archived along with the instance. (not used in Xojo)

NSSoundMBS.soundWithContentsOfURL(url as string, ByReference as boolean) as NSSoundMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa MBS MacBase Plugin 9.4 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Initializes a NSSoundMBS object with the audio data located at a given URL.

url: URL to the sound file with which the receiver is to be initialized.
ByReference: When true only the name of the sound is stored with the NSSound instance when archived using encodeWithCoder:; otherwise the audio data is archived along with the instance. (not used in Xojo)

NSSoundMBS.soundWithData(data as MemoryBlock) as NSSoundMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa MBS MacBase Plugin 9.4 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Initializes a NSSoundMBS object with a given audio data.

data: Audio data with which the receiver is to be initialized. The data must have a proper magic number, sound header, and data for the formats the NSSound class supports.

NSSoundMBS.soundWithPasteboard as NSSoundMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa MBS MacBase Plugin 9.4 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Initializes a NSSoundMBS object with data from a pasteboard.

NSSound expects the data to have a proper magic number, sound header, and data for the formats it supports.

The items on this page are in the following plugins: MBS MacBase Plugin.


The biggest plugin in space...