Platforms to show: All Mac Windows Linux Cross-Platform

Back to AVAudioPlayerMBS class.

AVAudioPlayerMBS.currentDevice as String

Type Topic Plugin Version macOS Windows Linux iOS Targets
property AVFoundation MBS AVFoundation Plugin 18.4 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
The UID of the current audio device (as a string).

Available on MacOS 10.13 or newer.
Settable in v20.0 or newer.
(Read and Write property)

AVAudioPlayerMBS.currentTime as Double

Type Topic Plugin Version macOS Windows Linux iOS Targets
property AVFoundation MBS AVFoundation Plugin 13.2 ✅ Yes ❌ No ❌ No ✅ Yes All
The playback point, in seconds, within the timeline of the sound associated with the audio player.

If the sound is playing, currentTime is the offset of the current playback position, measured in seconds from the start of the sound. If the sound is not playing, currentTime is the offset of where playing starts upon calling the play method, measured in seconds from the start of the sound.

By setting this property you can seek to a specific point in a sound file or implement audio fast-forward and rewind functions.
(Read and Write property)

AVAudioPlayerMBS.data as MemoryBlock

Type Topic Plugin Version macOS Windows Linux iOS Targets
property AVFoundation MBS AVFoundation Plugin 13.2 ✅ Yes ❌ No ❌ No ✅ Yes All
The data object containing the sound associated with the audio player. (read-only)

Returns nil if the audio player has no data (that is, if it was not initialized with an Memoryblock).
(Read only property)

AVAudioPlayerMBS.deviceCurrentTime as Double

Type Topic Plugin Version macOS Windows Linux iOS Targets
property AVFoundation MBS AVFoundation Plugin 13.2 ✅ Yes ❌ No ❌ No ✅ Yes All
The time value, in seconds, of the audio output device. (read-only)

The value of this property increases monotonically while an audio player is playing or paused.

If more than one audio player is connected to the audio output device, device time continues incrementing as long as at least one of the players is playing or paused.

If the audio output device has no connected audio players that are either playing or paused, device time reverts to 0.

Use this property to indicate "now" when calling the playAtTime instance method. By configuring multiple audio players to play at a specified offset from deviceCurrentTime, you can perform precise synchronization—as described in the discussion for that method.
(Read only property)

AVAudioPlayerMBS.duration as Double

Type Topic Plugin Version macOS Windows Linux iOS Targets
property AVFoundation MBS AVFoundation Plugin 13.2 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns the total duration, in seconds, of the sound associated with the audio player. (read-only)
Example
dim f as FolderItem = SpecialFolder.Desktop.Child("test.mp3")
dim e as NSErrorMBS
dim u as new AVAudioPlayerMBS(f,e)
if e<>nil then
MsgBox e.localizedDescription
else
MsgBox str(u.duration)+" seconds"
end if

(Read only property)

AVAudioPlayerMBS.enableRate as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
property AVFoundation MBS AVFoundation Plugin 14.0 ✅ Yes ❌ No ❌ No ✅ Yes All
A Boolean value that specifies whether playback rate adjustment is enabled for an audio player.

To enable adjustable playback rate for an audio player, set this property to YES after you initialize the player and before you call the prepareToPlay instance method for the player.
Available in OS X v10.8 and later.
(Read and Write property)

Some examples using this property:

AVAudioPlayerMBS.Handle as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
property AVFoundation MBS AVFoundation Plugin 13.2 ✅ Yes ❌ No ❌ No ✅ Yes All
The internal object reference.

(Read and Write property)

AVAudioPlayerMBS.isPlaying as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
property AVFoundation MBS AVFoundation Plugin 13.2 ✅ Yes ❌ No ❌ No ✅ Yes All
A Boolean value that indicates whether the audio player is playing (true) or not (false). (read-only)

To find out when playback has stopped, use the AVFoundationMBS.audioPlayerDidFinishPlaying event.

Important: Do not poll this property (that is, do not use it inside of a loop) in an attempt to discover when playback has stopped.
(Read only property)

AVAudioPlayerMBS.meteringEnabled as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
property AVFoundation MBS AVFoundation Plugin 13.2 ✅ Yes ❌ No ❌ No ✅ Yes All
A Boolean value that specifies the audio-level metering on/off state for the audio player.

The default value for the meteringEnabled property is off (Boolean false). Before using metering for an audio player, you need to enable it by setting this property to true.
(Read and Write property)

AVAudioPlayerMBS.Name as String

Type Topic Plugin Version macOS Windows Linux iOS Targets
property AVFoundation MBS AVFoundation Plugin 18.3 ✅ Yes ❌ No ❌ No ✅ Yes All
The name of the audio file.

This uses the URL to pull the display name if possible, so you can show it to user or identify the player when debugging.
(Read only property)

AVAudioPlayerMBS.numberOfChannels as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
property AVFoundation MBS AVFoundation Plugin 13.2 ✅ Yes ❌ No ❌ No ✅ Yes All
The number of audio channels in the sound associated with the audio player. (read-only)

(Read only property)

AVAudioPlayerMBS.numberOfLoops as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
property AVFoundation MBS AVFoundation Plugin 13.2 ✅ Yes ❌ No ❌ No ✅ Yes All
The number of times a sound will return to the beginning, upon reaching the end, to repeat playback.

A value of 0, which is the default, means to play the sound once. Set a positive integer value to specify the number of times to return to the start and play again. For example, specifying a value of 1 results in a total of two plays of the sound. Set any negative integer value to loop the sound indefinitely until you call the stop method.
(Read and Write property)

AVAudioPlayerMBS.pan as Double

Type Topic Plugin Version macOS Windows Linux iOS Targets
property AVFoundation MBS AVFoundation Plugin 13.2 ✅ Yes ❌ No ❌ No ✅ Yes All
The audio player's stereo pan position.

By setting this property you can position a sound in the stereo field. A value of –1.0 is full left, 0.0 is center, and 1.0 is full right.
(Read and Write property)

AVAudioPlayerMBS.rate as Double

Type Topic Plugin Version macOS Windows Linux iOS Targets
property AVFoundation MBS AVFoundation Plugin 14.0 ✅ Yes ❌ No ❌ No ✅ Yes All
The audio player's playback rate.
Example
dim s as sound // your sound
dim a as AVAudioPlayerMBS = s.AVAudioPlayerMBS
a.rate = 0.5

This property's default value of 1.0 provides normal playback rate. The available range is from 0.5 for half-speed playback through 2.0 for double-speed playback.

To set an audio player's playback rate, you must first enable rate adjustment as described in the enableRate property description.
Available in OS X v10.8 and later.
(Read and Write property)

AVAudioPlayerMBS.settings as Dictionary

Type Topic Plugin Version macOS Windows Linux iOS Targets
property AVFoundation MBS AVFoundation Plugin 13.2 ✅ Yes ❌ No ❌ No ✅ Yes All
The audio player's settings dictionary, containing information about the sound associated with the player. (read-only)

An audio player's settings dictionary contains keys for the following information about the player's associated sound:

Channel layout (AVChannelLayoutKey)
Encoder bit rate (AVEncoderBitRateKey)
Audio data format (AVFormatIDKey)
Channel count (AVNumberOfChannelsKey)
Sample rate (AVSampleRateKey)

The settings keys are described in AV Foundation Audio Settings Constants.
(Read only property)

AVAudioPlayerMBS.URL as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
property AVFoundation MBS AVFoundation Plugin 13.2 ✅ Yes ❌ No ❌ No ✅ Yes All
The URL for the sound associated with the audio player. (read-only)
Example
dim f as FolderItem = SpecialFolder.Desktop.Child("test.mp3")
dim e as NSErrorMBS
dim u as new AVAudioPlayerMBS(f,e)
if e<>nil then
MsgBox e.localizedDescription
else
MsgBox u.URL
end if

Returns "" if the audio player was not initialized with a URL.
(Read only property)

AVAudioPlayerMBS.volume as Double

Type Topic Plugin Version macOS Windows Linux iOS Targets
property AVFoundation MBS AVFoundation Plugin 13.2 ✅ Yes ❌ No ❌ No ✅ Yes All
The playback gain for the audio player, ranging from 0.0 through 1.0.

(Read and Write property)

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


The biggest plugin in space...