Share via


MediaPlayer.Create Method

Definition

Overloads

Create(Context, Uri, ISurfaceHolder, AudioAttributes, Int32)

Same factory method as #create(Context, Uri, SurfaceHolder) but that lets you specify the audio attributes and session ID to be used by the new MediaPlayer instance.

Create(Context, Int32, AudioAttributes, Int32)

Same factory method as #create(Context, int) but that lets you specify the audio attributes and session ID to be used by the new MediaPlayer instance.

Create(Context, Uri)

Convenience method to create a MediaPlayer for a given Uri.

Create(Context, Int32)

Convenience method to create a MediaPlayer for a given resource id.

Create(Context, Uri, ISurfaceHolder)

Convenience method to create a MediaPlayer for a given Uri.

Create(Context, Uri, ISurfaceHolder, AudioAttributes, Int32)

Same factory method as #create(Context, Uri, SurfaceHolder) but that lets you specify the audio attributes and session ID to be used by the new MediaPlayer instance.

[Android.Runtime.Register("create", "(Landroid/content/Context;Landroid/net/Uri;Landroid/view/SurfaceHolder;Landroid/media/AudioAttributes;I)Landroid/media/MediaPlayer;", "")]
public static Android.Media.MediaPlayer? Create (Android.Content.Context? context, Android.Net.Uri? uri, Android.Views.ISurfaceHolder? holder, Android.Media.AudioAttributes? audioAttributes, int audioSessionId);
[<Android.Runtime.Register("create", "(Landroid/content/Context;Landroid/net/Uri;Landroid/view/SurfaceHolder;Landroid/media/AudioAttributes;I)Landroid/media/MediaPlayer;", "")>]
static member Create : Android.Content.Context * Android.Net.Uri * Android.Views.ISurfaceHolder * Android.Media.AudioAttributes * int -> Android.Media.MediaPlayer

Parameters

context
Context

the Context to use

uri
Uri

the Uri from which to get the datasource

holder
ISurfaceHolder

the SurfaceHolder to use for displaying the video, may be null.

audioAttributes
AudioAttributes

the AudioAttributes to be used by the media player.

audioSessionId
Int32

the audio session ID to be used by the media player, see AudioManager#generateAudioSessionId() to obtain a new session.

Returns

a MediaPlayer object, or null if creation failed

Attributes

Remarks

Same factory method as #create(Context, Uri, SurfaceHolder) but that lets you specify the audio attributes and session ID to be used by the new MediaPlayer instance.

Java documentation for android.media.MediaPlayer.create(android.content.Context, android.net.Uri, android.view.SurfaceHolder, android.media.AudioAttributes, 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

Create(Context, Int32, AudioAttributes, Int32)

Same factory method as #create(Context, int) but that lets you specify the audio attributes and session ID to be used by the new MediaPlayer instance.

[Android.Runtime.Register("create", "(Landroid/content/Context;ILandroid/media/AudioAttributes;I)Landroid/media/MediaPlayer;", "")]
public static Android.Media.MediaPlayer? Create (Android.Content.Context? context, int resid, Android.Media.AudioAttributes? audioAttributes, int audioSessionId);
[<Android.Runtime.Register("create", "(Landroid/content/Context;ILandroid/media/AudioAttributes;I)Landroid/media/MediaPlayer;", "")>]
static member Create : Android.Content.Context * int * Android.Media.AudioAttributes * int -> Android.Media.MediaPlayer

Parameters

context
Context

the Context to use

resid
Int32

the raw resource id (<var>R.raw.&lt;something></var>) for the resource to use as the datasource

audioAttributes
AudioAttributes

the AudioAttributes to be used by the media player.

audioSessionId
Int32

the audio session ID to be used by the media player, see AudioManager#generateAudioSessionId() to obtain a new session.

Returns

a MediaPlayer object, or null if creation failed

Attributes

Remarks

Same factory method as #create(Context, int) but that lets you specify the audio attributes and session ID to be used by the new MediaPlayer instance.

Java documentation for android.media.MediaPlayer.create(android.content.Context, int, android.media.AudioAttributes, 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

Create(Context, Uri)

Convenience method to create a MediaPlayer for a given Uri.

[Android.Runtime.Register("create", "(Landroid/content/Context;Landroid/net/Uri;)Landroid/media/MediaPlayer;", "")]
public static Android.Media.MediaPlayer? Create (Android.Content.Context? context, Android.Net.Uri? uri);
[<Android.Runtime.Register("create", "(Landroid/content/Context;Landroid/net/Uri;)Landroid/media/MediaPlayer;", "")>]
static member Create : Android.Content.Context * Android.Net.Uri -> Android.Media.MediaPlayer

Parameters

context
Context

the Context to use

uri
Uri

the Uri from which to get the datasource

Returns

a MediaPlayer object, or null if creation failed

Attributes

Remarks

Convenience method to create a MediaPlayer for a given Uri. On success, #prepare() will already have been called and must not be called again.

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

Note that since #prepare() is called automatically in this method, you cannot change the audio session ID (see #setAudioSessionId(int)) or audio attributes (see #setAudioAttributes(AudioAttributes) of the new MediaPlayer.

Java documentation for android.media.MediaPlayer.create(android.content.Context, android.net.Uri).

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

Create(Context, Int32)

Convenience method to create a MediaPlayer for a given resource id.

[Android.Runtime.Register("create", "(Landroid/content/Context;I)Landroid/media/MediaPlayer;", "")]
public static Android.Media.MediaPlayer? Create (Android.Content.Context? context, int resid);
[<Android.Runtime.Register("create", "(Landroid/content/Context;I)Landroid/media/MediaPlayer;", "")>]
static member Create : Android.Content.Context * int -> Android.Media.MediaPlayer

Parameters

context
Context

the Context to use

resid
Int32

the raw resource id (<var>R.raw.&lt;something></var>) for the resource to use as the datasource

Returns

a MediaPlayer object, or null if creation failed

Attributes

Remarks

Convenience method to create a MediaPlayer for a given resource id. On success, #prepare() will already have been called and must not be called again.

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

Note that since #prepare() is called automatically in this method, you cannot change the audio session ID (see #setAudioSessionId(int)) or audio attributes (see #setAudioAttributes(AudioAttributes) of the new MediaPlayer.

Java documentation for android.media.MediaPlayer.create(android.content.Context, 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

Create(Context, Uri, ISurfaceHolder)

Convenience method to create a MediaPlayer for a given Uri.

[Android.Runtime.Register("create", "(Landroid/content/Context;Landroid/net/Uri;Landroid/view/SurfaceHolder;)Landroid/media/MediaPlayer;", "")]
public static Android.Media.MediaPlayer? Create (Android.Content.Context? context, Android.Net.Uri? uri, Android.Views.ISurfaceHolder? holder);
[<Android.Runtime.Register("create", "(Landroid/content/Context;Landroid/net/Uri;Landroid/view/SurfaceHolder;)Landroid/media/MediaPlayer;", "")>]
static member Create : Android.Content.Context * Android.Net.Uri * Android.Views.ISurfaceHolder -> Android.Media.MediaPlayer

Parameters

context
Context

the Context to use

uri
Uri

the Uri from which to get the datasource

holder
ISurfaceHolder

the SurfaceHolder to use for displaying the video

Returns

a MediaPlayer object, or null if creation failed

Attributes

Remarks

Convenience method to create a MediaPlayer for a given Uri. On success, #prepare() will already have been called and must not be called again.

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

Note that since #prepare() is called automatically in this method, you cannot change the audio session ID (see #setAudioSessionId(int)) or audio attributes (see #setAudioAttributes(AudioAttributes) of the new MediaPlayer.

Java documentation for android.media.MediaPlayer.create(android.content.Context, android.net.Uri, android.view.SurfaceHolder).

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