Compartir a través de


AsyncPlayer.Play Method

Definition

Overloads

Play(Context, Uri, Boolean, AudioAttributes)

Start playing the sound.

Play(Context, Uri, Boolean, Stream)

Start playing the sound.

Play(Context, Uri, Boolean, AudioAttributes)

Start playing the sound.

[Android.Runtime.Register("play", "(Landroid/content/Context;Landroid/net/Uri;ZLandroid/media/AudioAttributes;)V", "GetPlay_Landroid_content_Context_Landroid_net_Uri_ZLandroid_media_AudioAttributes_Handler", ApiSince=23)]
public virtual void Play (Android.Content.Context context, Android.Net.Uri uri, bool looping, Android.Media.AudioAttributes attributes);
[<Android.Runtime.Register("play", "(Landroid/content/Context;Landroid/net/Uri;ZLandroid/media/AudioAttributes;)V", "GetPlay_Landroid_content_Context_Landroid_net_Uri_ZLandroid_media_AudioAttributes_Handler", ApiSince=23)>]
abstract member Play : Android.Content.Context * Android.Net.Uri * bool * Android.Media.AudioAttributes -> unit
override this.Play : Android.Content.Context * Android.Net.Uri * bool * Android.Media.AudioAttributes -> unit

Parameters

context
Context

the non-null application's context.

uri
Uri

the non-null URI to play. (see MediaPlayer#setDataSource(Context, Uri))

looping
Boolean

whether the audio should loop forever. (see MediaPlayer#setLooping(boolean))

attributes
AudioAttributes

the non-null AudioAttributes to use. (see MediaPlayer#setAudioAttributes(AudioAttributes))

Attributes

Remarks

Start playing the sound. It will actually start playing at some point in the future. There are no guarantees about latency here. Calling this before another audio file is done playing will stop that one and start the new one.

Java documentation for android.media.AsyncPlayer.play(android.content.Context, android.net.Uri, boolean, android.media.AudioAttributes).

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

Play(Context, Uri, Boolean, Stream)

Start playing the sound.

[Android.Runtime.Register("play", "(Landroid/content/Context;Landroid/net/Uri;ZI)V", "GetPlay_Landroid_content_Context_Landroid_net_Uri_ZIHandler")]
public virtual void Play (Android.Content.Context? context, Android.Net.Uri? uri, bool looping, Android.Media.Stream stream);
[<Android.Runtime.Register("play", "(Landroid/content/Context;Landroid/net/Uri;ZI)V", "GetPlay_Landroid_content_Context_Landroid_net_Uri_ZIHandler")>]
abstract member Play : Android.Content.Context * Android.Net.Uri * bool * Android.Media.Stream -> unit
override this.Play : Android.Content.Context * Android.Net.Uri * bool * Android.Media.Stream -> unit

Parameters

context
Context

Your application's context.

uri
Uri

The URI to play. (see MediaPlayer#setDataSource(Context, Uri))

looping
Boolean

Whether the audio should loop forever.
(see MediaPlayer#setLooping(boolean))

stream
Stream

the AudioStream to use. (see MediaPlayer#setAudioStreamType(int))

Attributes

Remarks

Start playing the sound. It will actually start playing at some point in the future. There are no guarantees about latency here. Calling this before another audio file is done playing will stop that one and start the new one.

This member is deprecated. use #play(Context, Uri, boolean, AudioAttributes) instead

Java documentation for android.media.AsyncPlayer.play(android.content.Context, android.net.Uri, boolean, 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