Xojo Conferences

Platforms to show: All Mac Windows Linux Cross-Platform

AVAudioPlayerMBS class

Type Topic Plugin Version macOS Windows Linux Console & Web iOS
class AVFoundation MBS AVFoundation Plugin 13.2 Yes No No Yes, macOS only No
Function: An instance of the AVAudioPlayer class, called an audio player, provides playback of audio data from a file or memory.
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
MsgBox str(u.duration)+" seconds"
end if
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.

Feedback, Comments & Corrections

This class has no sub classes.

Some methods using this class:

Some events for this class:

Some examples which use this class:

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

AVAudioPCMBufferMBS   -   AVAudioPlayerNodeMBS

MBS Xojo Chart Plugins