Edit

Share via


SystemSound Class

Definition

Provides methods for producing simple sounds.

public class SystemSound : IDisposable, ObjCRuntime.INativeObject
type SystemSound = class
    interface INativeObject
    interface IDisposable
Inheritance
SystemSound
Implements

Remarks

This API is intended to be used to play sound effects or to make the device vibrate. You use PlaySystemSoundAsync() to play short sounds and PlayAlertSoundAsync() to play either the sound or vibrate (depending on the device settings).

Unlike the AVAudioPlayer which works with the audio session and is able to dim your audio, play in the background and interact with the system based on a set of rules, the SystemSound does not support this. So you should in general avoid using it for anything but sound effects and device vibration.

As of iOS 8, SystemSound has the following restrictions:

  • Audio Format: PCM or IMA4 (IMA/ADPCM). :
  • Audio Container: .caf, .aif or .wav containers. :
  • At most 30 seconds of duration. :
  • There is no volume control, this uses the system volume. :
  • Sound plays immediately. :
  • Only one sound can be played at a time, there is no way to play more than one sound at a time. :

To play a sound, you first create an instance of the SystemSound object, either via the constructor, or one of the FromFile(String) methods. Once this object has been created, you call one of the playback methods PlaySystemSoundAsync() to play short sounds and PlayAlertSoundAsync().

Constructors

SystemSound(NSUrl)

Create a system sound from a local file.

SystemSound(UInt32)

Fields

Vibrate

A special system sound that can be used to make the device vibrate.

Properties

CompletePlaybackIfAppDies

Controls whether the sound will complete playing, even if the application dies.

Handle

Handle (pointer) to the unmanaged object representation.

IsUISound

Gets or sets whether to override user preferences when calling PlaySystemSound().

Methods

AddSystemSoundCompletion(Action, CFRunLoop)

Method to invoke when this sound completes playing.

Close()

Closes this system sound.

Dispose()

Releases the resources used by the SystemSound object.

Dispose(Boolean)

Releases the resources used by the SystemSound object.

Finalize()

Finalizer for the SystemSound object

FromFile(NSUrl)

Creates a system sound from a file.

FromFile(String)

An array of packet descriptions that describe the contents of the buffer.

PlayAlertSound()

Plays a sound or alert.

PlayAlertSound(Action)

Plays a sound or alert and then calls the handler.

PlayAlertSoundAsync()

Asynchronously plays a sound or alert, returning a T:System.Threading.Task that completes after the sound ends.

PlaySystemSound()

Plays the system sound.

PlaySystemSound(Action)

Plays the system sound and calls afterwards.

PlaySystemSoundAsync()

Asynchronously plays a system sound and returns a T:System.Threading.Tasks.Task that is completed when the sound ends.

RemoveSystemSoundCompletion()

Removes the previously registered completion method.

Applies to