Condividi tramite


MediaActionSound.Play(MediaActionSoundType) Method

Definition

Play one of the predefined platform sounds for media actions.

[Android.Runtime.Register("play", "(I)V", "GetPlay_IHandler")]
public virtual void Play (Android.Media.MediaActionSoundType soundName);
[<Android.Runtime.Register("play", "(I)V", "GetPlay_IHandler")>]
abstract member Play : Android.Media.MediaActionSoundType -> unit
override this.Play : Android.Media.MediaActionSoundType -> unit

Parameters

soundName
MediaActionSoundType

The type of sound to play, selected from SHUTTER_CLICK, FOCUS_COMPLETE, START_VIDEO_RECORDING, or STOP_VIDEO_RECORDING.

Attributes

Remarks

Play one of the predefined platform sounds for media actions.

Use this method to play a platform-specific sound for various media actions. The sound playback is done asynchronously, with the same behavior and content as the sounds played by android.hardware.Camera#takePicture Camera.takePicture, android.media.MediaRecorder#start MediaRecorder.start, and android.media.MediaRecorder#stop MediaRecorder.stop.

With the android.hardware.camera2 camera2 API, this method can be used to play standard camera operation sounds with the appropriate system behavior for such sounds.

With the older android.hardware.Camera API, using this method makes it easy to match the default device sounds when recording or capturing data through the preview callbacks, or when implementing custom camera-like features in your application.

If the sound has not been loaded by #load before calling play, play will load the sound at the cost of some additional latency before sound playback begins.

Java documentation for android.media.MediaActionSound.play(int).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

See also