Share via


MediaPlayer Constructors

Definition

Overloads

MediaPlayer()

Default constructor.

MediaPlayer(Context)

Default constructor with context.

MediaPlayer(IntPtr, JniHandleOwnership)

A constructor used when creating managed representations of JNI objects; called by the runtime.

MediaPlayer()

Default constructor.

[Android.Runtime.Register(".ctor", "()V", "")]
public MediaPlayer ();
Attributes

Remarks

Default constructor.

Consider using one of the create() methods for synchronously instantiating a MediaPlayer from a Uri or resource.

You must call #release() when you are finished using the instantiated instance. Doing so frees any resources you have previously acquired.

Java documentation for android.media.MediaPlayer.MediaPlayer().

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

MediaPlayer(Context)

Default constructor with context.

[Android.Runtime.Register(".ctor", "(Landroid/content/Context;)V", "", ApiSince=34)]
public MediaPlayer (Android.Content.Context context);
[<Android.Runtime.Register(".ctor", "(Landroid/content/Context;)V", "", ApiSince=34)>]
new Android.Media.MediaPlayer : Android.Content.Context -> Android.Media.MediaPlayer

Parameters

context
Context

non-null context. This context will be used to pull information, such as android.content.AttributionSource and device specific session ids, which will be associated with the MediaPlayer. However, the context itself will not be retained by the MediaPlayer.

Attributes

Remarks

Default constructor with context.

Consider using one of the create() methods for synchronously instantiating a MediaPlayer from a Uri or resource.

Java documentation for android.media.MediaPlayer.MediaPlayer(android.content.Context).

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

MediaPlayer(IntPtr, JniHandleOwnership)

A constructor used when creating managed representations of JNI objects; called by the runtime.

protected MediaPlayer (IntPtr javaReference, Android.Runtime.JniHandleOwnership transfer);
new Android.Media.MediaPlayer : nativeint * Android.Runtime.JniHandleOwnership -> Android.Media.MediaPlayer

Parameters

javaReference
IntPtr

nativeint

A IntPtrcontaining a Java Native Interface (JNI) object reference.

transfer
JniHandleOwnership

A JniHandleOwnershipindicating how to handle javaReference

Remarks

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