Platforms to show: All Mac Windows Linux Cross-Platform
AVAudioPlayerMBS class
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
class | AVFoundation | MBS AVFoundation Plugin | 13.2 | ✅ Yes | ❌ No | ❌ No | ✅ Yes | All |
Apple recommends that you use this class for audio playback unless you are playing audio captured from a network stream or require very low I/O latency. For an overview of audio technologies, see Audio & Video Starting Point and "Using Audio" in Multimedia Programming Guide.
Using an audio player you can:
- Play sounds of any duration
- Play sounds from files or memory buffers
- Loop sounds
- Play multiple sounds simultaneously, one sound per audio player, with precise synchronization
- Control relative playback level, stereo positioning, and playback rate for each sound you are playing
- Seek to a particular point in a sound file, which supports such application features as fast forward and rewind
- Obtain data you can use for playback-level metering
The AVAudioPlayer class lets you play sound in any audio format available in OS X. The plugin provides the events for this audio player in AVFoundationMBS class.
To play, pause, or stop an audio player, call one of its playback control methods, described in "Configuring and Controlling Playback."
To configure an appropriate audio session for playback, refer to AVAudioSession Class Reference and AVAudioSessionDelegate Protocol Reference. To learn how your choice of file formats impacts the simultaneous playback of multiple sounds, refer to "iPhone Hardware and Software Audio Codecs" in Multimedia Programming Guide.
- 17 properties
- property currentDevice as String
- property currentTime as Double
- property data as MemoryBlock
- property deviceCurrentTime as Double
- property duration as Double
- property enableRate as boolean
- property Handle as Integer
- property isPlaying as boolean
- property meteringEnabled as boolean
- property Name as String
- property numberOfChannels as Integer
- property numberOfLoops as Integer
- property pan as Double
- property rate as Double
- property settings as Dictionary
- property URL as string
- property volume as Double
- 14 methods
- method averagePowerForChannel(channel as Integer) as Double
- method Constructor(Data as MemoryBlock, byref error as NSErrorMBS)
- method Constructor(Data as MemoryBlock, fileTypeHintUtiString as string, byref error as NSErrorMBS)
- method Constructor(File as folderitem, byref error as NSErrorMBS)
- method Constructor(File as folderitem, fileTypeHintUtiString as string, byref error as NSErrorMBS)
- method Constructor(URL as string, byref error as NSErrorMBS)
- method Constructor(URL as string, fileTypeHintUtiString as string, byref error as NSErrorMBS)
- method pause
- method peakPowerForChannel(channel as Integer) as Double
- method play as boolean
- method playAtTime(time as Double = 0.0) as boolean
- method prepareToPlay as boolean
- method stop
- method updateMeters
- 9 shared methods
- shared method audioPlayerWithData(Data as MemoryBlock, byref error as NSErrorMBS) as AVAudioPlayerMBS
- shared method audioPlayerWithData(Data as MemoryBlock, fileTypeHintUtiString as string, byref error as NSErrorMBS) as AVAudioPlayerMBS
- shared method audioPlayerWithData(Data as String, byref error as NSErrorMBS) as AVAudioPlayerMBS
- shared method audioPlayerWithData(Data as String, fileTypeHintUtiString as string, byref error as NSErrorMBS) as AVAudioPlayerMBS
- shared method audioPlayerWithFile(File as folderitem, byref error as NSErrorMBS) as AVAudioPlayerMBS
- shared method audioPlayerWithFile(File as folderitem, fileTypeHintUtiString as string, byref error as NSErrorMBS) as AVAudioPlayerMBS
- shared method audioPlayerWithURL(URL as string, byref error as NSErrorMBS) as AVAudioPlayerMBS
- shared method audioPlayerWithURL(URL as string, fileTypeHintUtiString as string, byref error as NSErrorMBS) as AVAudioPlayerMBS
- shared method available as boolean
This class has no sub classes.
Some methods using this class:
- Sound.AVAudioPlayerMBS as AVAudioPlayerMBS
Some events using this class:
- AVFoundationMBS.audioPlayerDecodeErrorDidOccur(player as AVAudioPlayerMBS, error as NSErrorMBS)
- AVFoundationMBS.audioPlayerDidFinishPlaying(player as AVAudioPlayerMBS, successful as boolean)
- AVFoundationMBS.prerollAtRateFinished(player as AVAudioPlayerMBS, rate as Double, finished as boolean, tag as Variant)
Some examples using this class:
Blog Entries
- MBS Xojo Plugins, version 20.0pr5
- MBS Xojo Plugins 18.3
- MBS Xojo Plugins, version 18.3pr6
- MBS Xojo Plugins, version 18.2pr8
- MBS Xojo / Real Studio Plugins, version 14.5pr4
- MBS Xojo / Real Studio Plugins, version 14.2pr4
Xojo Developer Magazine
- 16.5, page 9: News
- 12.2, page 46: Moving to AVFoundation, Leaving QuickTime behind by Christian Schmitz
Release notes
- Version 20.0
- Changed CurrentDevice in AVAudioPlayerMBS to be settable property.
- Version 18.3
- Added Name property for AVAudioPlayerMBS class.
- Version 18.2
- Changed AVAudioPlayerMBS to have real properties visible in debugger.
The items on this page are in the following plugins: MBS AVFoundation Plugin.
AVAudioPCMBufferMBS - AVAudioPlayerNodeMBS