Class Player

Definition

Namespace:
Tizen.Multimedia
Assembly:
Tizen.Multimedia.MediaPlayer.dll
API Level:
3

Provides the ability to control media playback.

C#
Copy
public class Player : IDisposable
Inheritance
Player
Implements
System.IDisposable
Remarks

The player provides functions to play a media content. It also provides functions to adjust the configurations of the player such as playback rate, volume, looping etc. Note that only one video player can be played at one time.

Constructors

View Source

Player()

Initializes a new instance of the Player class.

Declaration
C#
Copy
public Player()
API Level: 3

Properties

View Source

AdaptiveVariants

Gets the adaptive variants settings.

Declaration
C#
Copy
public AdaptiveVariants AdaptiveVariants { get; }
Property Value
Type Description
AdaptiveVariants
API Level: 5
View Source

AudioEffect

Gets the audio effect.

Declaration
C#
Copy
public AudioEffect AudioEffect { get; }
Property Value
Type Description
AudioEffect
Exceptions
Type Condition
System.NotSupportedException

The required feature is not supported.

API Level: 3
Feature: http://tizen.org/feature/multimedia.custom_audio_effect
View Source

AudioLatencyMode

Gets or sets the audio latency mode.

Declaration
C#
Copy
public AudioLatencyMode AudioLatencyMode { get; set; }
Property Value
Type Description
AudioLatencyMode

A AudioLatencyMode that specifies the mode. The default is Mid.

Remarks

If the mode is High, audio output interval can be increased, so it can keep more audio data to play. But, state transition like pause or resume can be more slower than default(Mid).

Exceptions
Type Condition
ObjectDisposedException

The player has already been disposed of.

System.ArgumentException

The value is not valid.

API Level: 3
View Source

AudioTrackInfo

Gets the track info for the audio.

Declaration
C#
Copy
public PlayerTrackInfo AudioTrackInfo { get; }
Property Value
Type Description
PlayerTrackInfo

A PlayerTrackInfo for audio.

API Level: 3
View Source

BufferingTime

Gets or sets the streaming buffering time.

Declaration
C#
Copy
public PlayerBufferingTime BufferingTime { get; set; }
Property Value
Type Description
PlayerBufferingTime
Remarks

To set, the player must be in the Idle state.

Exceptions
Type Condition
InvalidOperationException

The player is not in the valid state.

ObjectDisposedException

The player has already been disposed of.

ArgumentOutOfRangeException

is less than 0.
-or-
is less than 0.

API Level: 5
View Source

Gets or sets the cookie for streaming playback.

Declaration
C#
Copy
public string Cookie { get; set; }
Property Value
Type Description
System.String

To set, the player must be in the Idle state.

Exceptions
Type Condition
InvalidOperationException

The player is not in the valid state.

ObjectDisposedException

The player has already been disposed of.

ArgumentNullException

The value to set is null.

API Level: 3
View Source

Display

Gets or sets the display.

Declaration
C#
Copy
public Display Display { get; set; }
Property Value
Type Description
Display

A Display that specifies the display.

Remarks

The player must be in the Idle state.
The raw video feature(http://tizen.org/feature/multimedia.raw_video) is required if the display is created with MediaView.

Exceptions
Type Condition
ObjectDisposedException

The player has already been disposed of.

System.ArgumentException

The value has already been assigned to another player.

InvalidOperationException

The player is not in the valid state.

System.NotSupportedException

The required feature is not supported.

API Level: 3
View Source

DisplaySettings

Gets the display settings.

Declaration
C#
Copy
public PlayerDisplaySettings DisplaySettings { get; }
Property Value
Type Description
PlayerDisplaySettings

A PlayerDisplaySettings that specifies the display settings.

API Level: 3
View Source

Handle

Gets the native handle of the player.

Declaration
C#
Copy
public IntPtr Handle { get; }
Property Value
Type Description
System.IntPtr

An IntPtr that contains the native handle of the player.

Exceptions
Type Condition
ObjectDisposedException

The player has already been disposed of.

API Level: 3
View Source

IsAudioOnly

Gets or sets the audio-only state.

Declaration
C#
Copy
public bool IsAudioOnly { get; set; }
Property Value
Type Description
Boolean

true if the playback is audio-only mode; otherwise, false. The default value is false.

Exceptions
Type Condition
InvalidOperationException

The player is not in the valid state.

ObjectDisposedException

The player has already been disposed of.

API Level: 5
View Source

IsLooping

Gets or sets the looping state.

Declaration
C#
Copy
public bool IsLooping { get; set; }
Property Value
Type Description
Boolean

true if the playback is looping; otherwise, false. The default value is false.

Exceptions
Type Condition
ObjectDisposedException

The player has already been disposed of.

API Level: 3
View Source

Muted

Gets or sets the mute state.

Declaration
C#
Copy
public bool Muted { get; set; }
Property Value
Type Description
Boolean

true if the player is muted; otherwise, false.

Exceptions
Type Condition
ObjectDisposedException

The player has already been disposed of.

API Level: 3
View Source

ReplayGain

Gets or sets the player's replaygain state.

Declaration
C#
Copy
public bool ReplayGain { get; set; }
Property Value
Type Description
Boolean

If the replaygain status is true, replaygain is applied (if contents has a replaygain tag); otherwise, the replaygain is not affected by tag and properties.

Exceptions
Type Condition
ObjectDisposedException

The player has already been disposed of.

InvalidOperationException

The player is not in the valid state.

API Level: 5
View Source

SphericalVideo

Gets the spherical video settings.

Declaration
C#
Copy
public SphericalVideo SphericalVideo { get; }
Property Value
Type Description
SphericalVideo
API Level: 5
View Source

State

Gets the state of the player.

Declaration
C#
Copy
public PlayerState State { get; }
Property Value
Type Description
PlayerState

The current state of the player.

Exceptions
Type Condition
ObjectDisposedException

The player has already been disposed of.

API Level: 3
View Source

StreamInfo

Gets the stream information.

Declaration
C#
Copy
public StreamInfo StreamInfo { get; }
Property Value
Type Description
StreamInfo

A StreamInfo for this player.

API Level: 3
View Source

SubtitleTrackInfo

Gets the track info for the subtitle.

Declaration
C#
Copy
public PlayerTrackInfo SubtitleTrackInfo { get; }
Property Value
Type Description
PlayerTrackInfo

A PlayerTrackInfo for the subtitle.

API Level: 3
View Source

UserAgent

Gets or sets the user agent for streaming playback.

Declaration
C#
Copy
public string UserAgent { get; set; }
Property Value
Type Description
System.String
Remarks

To set, the player must be in the Idle state.

Exceptions
Type Condition
InvalidOperationException

The player is not in the valid state.

ObjectDisposedException

The player has already been disposed of.

ArgumentNullException

The value to set is null.

API Level: 3
View Source

Volume

Gets or sets the current volume.

Declaration
C#
Copy
public float Volume { get; set; }
Property Value
Type Description
Single
Remarks

Valid volume range is from 0 to 1.0, inclusive.

Exceptions
Type Condition
ObjectDisposedException

The player has already been disposed of.

ArgumentOutOfRangeException

value is less than zero.
-or-
value is greater than 1.0.

API Level: 3

Methods

View Source

ApplyAudioStreamPolicy(AudioStreamPolicy)

Applies the audio stream policy.

Declaration
C#
Copy
public void ApplyAudioStreamPolicy(AudioStreamPolicy policy)
Parameters
Type Name Description
AudioStreamPolicy policy

The AudioStreamPolicy to apply.

Remarks

The player must be in the Idle state.

Player does not support all AudioStreamType.
Supported types are Media, System, Alarm, Notification, Emergency, VoiceInformation, RingtoneVoip and MediaExternalOnly.

Exceptions
Type Condition
ObjectDisposedException

The player has already been disposed of.
-or-
policy has already been disposed of.

InvalidOperationException

The player is not in the valid state.

ArgumentNullException

policy is null.

System.NotSupportedException

The required feature is not supported.
-or-
AudioStreamType of policy is not supported on the current platform.

API Level: 3
Feature: http://tizen.org/feature/multimedia.player.stream_info
View Source

CaptureVideoAsync()

Captures a video frame, asynchronously.

Declaration
C#
Copy
public Task<CapturedFrame> CaptureVideoAsync()
Returns
Type Description
System.Threading.Tasks.Task<CapturedFrame>

A task that represents the asynchronous capture operation.

Remarks

The player must be in the Playing or Paused state.

Exceptions
Type Condition
ObjectDisposedException

The player has already been disposed of.

InvalidOperationException

The player is not in the valid state.

System.NotSupportedException

The required feature is not supported.

API Level: 3
Feature: http://tizen.org/feature/multimedia.raw_video
View Source

ClearSubtitle()

Removes the subtitle path.

Declaration
C#
Copy
public void ClearSubtitle()
Remarks

The player must be in the Idle state.

Exceptions
Type Condition
ObjectDisposedException

The player has already been disposed of.

InvalidOperationException

The player is not in the valid state.

API Level: 3
View Source

Dispose()

Releases all resources used by the current instance.

Declaration
C#
Copy
public void Dispose()
API Level: 3
View Source

GetDownloadProgress()

Gets the streaming download progress.

Declaration
C#
Copy
public DownloadProgress GetDownloadProgress()
Returns
Type Description
DownloadProgress

The DownloadProgress containing current download progress.

Remarks

The player must be in the Playing or Paused state.

Exceptions
Type Condition
InvalidOperationException

The player is not streaming.
-or-
The player is not in the valid state.

ObjectDisposedException

The player has already been disposed of.

API Level: 3
View Source

GetPlayPosition()

Gets the play position in milliseconds.

Declaration
C#
Copy
public int GetPlayPosition()
Returns
Type Description
System.Int32

The current position in milliseconds.

Remarks

The player must be in the Ready, Playing, or Paused state.

Exceptions
Type Condition
ObjectDisposedException

The player has already been disposed of.

InvalidOperationException

The player is not in the valid state.

API Level: 3
View Source

GetPlayPositionNanoseconds()

Gets the play position in nanoseconds.

Declaration
C#
Copy
public long GetPlayPositionNanoseconds()
Returns
Type Description
System.Int64

The current position in nanoseconds.

Remarks

The player must be in the Ready, Playing, or Paused state.

Exceptions
Type Condition
ObjectDisposedException

The player has already been disposed of.

InvalidOperationException

The player is not in the valid state.

API Level: 5
View Source

GetVideoRoi()

Get the relative ROI (Region Of Interest) area as a decimal fraction based on the video source.

Declaration
C#
Copy
public ScaleRectangle GetVideoRoi()
Returns
Type Description
ScaleRectangle

The ScaleRectangle containing the ROI area information.

Remarks

The specified ROI area is valid only in Tizen.Multimedia.PlayerDisplayType.Overlay.

Exceptions
Type Condition
ObjectDisposedException

The player has already been disposed of.

InvalidOperationException

Operation failed; internal error.

API Level: 5
View Source

OnPreparing()

Called when the Tizen.Multimedia.Player.Prepare is invoked.

Declaration
C#
Copy
protected virtual void OnPreparing()
API Level: 3
View Source

OnUnprepared()

Called after the Player is unprepared.

Declaration
C#
Copy
protected virtual void OnUnprepared()
See Also
API Level: 3
View Source

Pause()

Pauses the player.

Declaration
C#
Copy
public virtual void Pause()
Remarks

The player must be in the Playing state. It has no effect if the player is already in the Paused state.

Exceptions
Type Condition
ObjectDisposedException

The player has already been disposed of.

InvalidOperationException

The player is not in the valid state.

See Also
API Level: 3
View Source

PrepareAsync()

Prepares the media player for playback, asynchronously.

Declaration
C#
Copy
public virtual Task PrepareAsync()
Returns
Type Description
Task

A task that represents the asynchronous prepare operation.

Remarks

To prepare the player, the player must be in the Idle state, and a source must be set.

Exceptions
Type Condition
InvalidOperationException

No source is set.

ObjectDisposedException

The player has already been disposed of.

InvalidOperationException

The player is not in the valid state.

API Level: 3
View Source

SetPlaybackRate(Single)

Sets the playback rate.

Declaration
C#
Copy
public void SetPlaybackRate(float rate)
Parameters
Type Name Description
Single rate

The value for the playback rate. Valid range is -5.0 to 5.0, inclusive.

Remarks

The player must be in the Ready, Playing, or Paused state.

The sound will be muted, when the playback rate is under 0.0 or over 2.0.

Exceptions
Type Condition
ObjectDisposedException

The player has already been disposed of.

InvalidOperationException

The player is not in the valid state.
-or-
Streaming playback.

ArgumentOutOfRangeException

rate is less than -5.0.
-or-
rate is greater than 5.0.
-or-
rate is zero.

API Level: 3
View Source

SetPlayPositionAsync(Int32, Boolean)

Sets the seek position for playback, asynchronously.

Declaration
C#
Copy
public Task SetPlayPositionAsync(int position, bool accurate)
Parameters
Type Name Description
System.Int32 position

The value indicating a desired position in milliseconds.

Boolean accurate

The value indicating whether the operation performs with accuracy.

Returns
Type Description
Task

A task that represents the asynchronous operation.

Remarks

The player must be in the Ready, Playing, or Paused state.

If the accurate is true, the play position will be adjusted as the specified position value, but this might be considerably slow. If false, the play position will be a nearest keyframe position.

Exceptions
Type Condition
ObjectDisposedException

The player has already been disposed of.

InvalidOperationException

The player is not in the valid state.
-or-
In case of non-seekable content, the player will return error and keep playing without changing the play position.

ArgumentOutOfRangeException

The specified position is not valid.

API Level: 3
View Source

SetPlayPositionNanosecondsAsync(Int64, Boolean)

Sets the seek position in nanoseconds for playback, asynchronously.

Declaration
C#
Copy
public Task SetPlayPositionNanosecondsAsync(long position, bool accurate)
Parameters
Type Name Description
System.Int64 position

The value indicating a desired position in nanoseconds.

Boolean accurate

The value indicating whether the operation performs with accuracy.

Returns
Type Description
Task

A task that represents the asynchronous operation.

Remarks

The player must be in the Ready, Playing, or Paused state.

If the accurate is true, the play position will be adjusted as the specified position value, but this might be considerably slow. If false, the play position will be a nearest keyframe position.

Exceptions
Type Condition
ObjectDisposedException

The player has already been disposed of.

InvalidOperationException

The player is not in the valid state.
-or-
In case of non-seekable content, the player will return error and keep playing without changing the play position.

ArgumentOutOfRangeException

The specified position is not valid.

API Level: 5
View Source

SetSource(MediaSource)

Sets a media source for the player.

Declaration
C#
Copy
public void SetSource(MediaSource source)
Parameters
Type Name Description
MediaSource source

A MediaSource that specifies the source for playback.

Remarks

The player must be in the Idle state.

Exceptions
Type Condition
ObjectDisposedException

The player has already been disposed of.

InvalidOperationException

The player is not in the valid state.
-or-
It is not able to assign the source to the player.

See Also
API Level: 3
View Source

SetSubtitle(String)

Sets the subtitle path for playback.

Declaration
C#
Copy
public void SetSubtitle(string path)
Parameters
Type Name Description
System.String path

The absolute path of the subtitle file, it can be NULL in the Idle state.

Remarks

Only MicroDVD/SubViewer(.sub), SAMI(.smi), and SubRip(*.srt) subtitle formats are supported.

The mediastorage privilege(http://tizen.org/privilege/mediastorage) must be added if any files are used to play located in the internal storage. The externalstorage privilege(http://tizen.org/privilege/externalstorage) must be added if any files are used to play located in the external storage.

Exceptions
Type Condition
ObjectDisposedException

The player has already been disposed of.

System.ArgumentException

path is an empty string.

System.IO.FileNotFoundException

The specified path does not exist.

ArgumentNullException

path is null.

API Level: 3
View Source

SetSubtitleOffset(Int32)

Sets the offset for the subtitle.

Declaration
C#
Copy
public void SetSubtitleOffset(int offset)
Parameters
Type Name Description
System.Int32 offset

The value indicating a desired offset in milliseconds.

Remarks

The player must be in the Playing or Paused state.

Exceptions
Type Condition
ObjectDisposedException

The player has already been disposed of.

InvalidOperationException

The player is not in the valid state.
-or-
No subtitle is set.

API Level: 3
View Source

SetVideoRoi(ScaleRectangle)

Set the relative ROI (Region Of Interest) area as a decimal fraction based on the video source. It can be regarded as zooming operation because the specified video area will be rendered to fit to the display.

Declaration
C#
Copy
public void SetVideoRoi(ScaleRectangle scaleRectangle)
Parameters
Type Name Description
ScaleRectangle scaleRectangle

The containing the ROI area information.

Remarks

This function requires the ratio of the each coordinate and size to the video resolution size to guarantee of showing the same area for the dynamic resolution video content. This function have to be called after setting Display

Exceptions
Type Condition
ObjectDisposedException

The player has already been disposed of.

InvalidOperationException

Operation failed; internal error. -or-
The Tizen.Multimedia.PlayerDisplayType is not set to Tizen.Multimedia.PlayerDisplayType.Overlay.

ArgumentOutOfRangeException

scaleRectangle.ScaleX.ScaleX is less than 0.0 or greater than 1.0.
-or-
scaleRectangle.ScaleY.ScaleY is less than 0.0 or greater than 1.0.
-or-
scaleRectangle.ScaleWidth.ScaleWidth is less than or equal to 0.0 or greater than 1.0.
-or-
scaleRectangle.ScaleHeight.ScaleHeight is less than or equal to 0.0 or greater than 1.0.

API Level: 5
View Source

Start()

Starts or resumes playback.

Declaration
C#
Copy
public virtual void Start()
Remarks

Sound can be mixed with other sounds if you don't control the stream focus using ApplyAudioStreamPolicy(AudioStreamPolicy).

Before Tizen 5.0, The player must be in the Ready or Paused state. It has no effect if the player is already in the Playing state.

Since Tizen 5.0, The player must be in the Ready, Playing, or Paused state.
In case of HTTP streaming playback, the player could be internally paused for buffering. If the application calls this function during the buffering, the playback will be resumed by force and the buffering message posting by BufferingProgressChanged will be stopped.
In other cases, the player will keep playing without returning error.

Exceptions
Type Condition
ObjectDisposedException

The player has already been disposed of.

InvalidOperationException

The player is not in the valid state.

API Level: 3
View Source

Stop()

Stops playing the media content.

Declaration
C#
Copy
public virtual void Stop()
Remarks

The player must be in the Playing or Paused state. It has no effect if the player is already in the Ready state.

Exceptions
Type Condition
ObjectDisposedException

The player has already been disposed of.

InvalidOperationException

The player is not in the valid state.

See Also
API Level: 3
View Source

Unprepare()

Unprepares the player.

Declaration
C#
Copy
public virtual void Unprepare()
Remarks

The most recently used source is reset and is no longer associated with the player. Playback is no longer possible. If you want to use the player again, you have to set a source and call PrepareAsync() again.

The player must be in the Ready, Playing, or Paused state. It has no effect if the player is already in the Idle state.

Exceptions
Type Condition
ObjectDisposedException

The player has already been disposed of.

InvalidOperationException

The player is not in the valid state.

API Level: 3

Events

View Source

BufferingProgressChanged

Occurs when there is a change in the buffering status of streaming.

Declaration
C#
Copy
public event EventHandler<BufferingProgressChangedEventArgs> BufferingProgressChanged
Event Type
Type Description
System.EventHandler<BufferingProgressChangedEventArgs>
API Level: 3
View Source

ErrorOccurred

Occurs when any error occurs.

Declaration
C#
Copy
public event EventHandler<PlayerErrorOccurredEventArgs> ErrorOccurred
Event Type
Type Description
System.EventHandler<PlayerErrorOccurredEventArgs>
Remarks

The event handler will be executed on an internal thread.

API Level: 3
View Source

PlaybackCompleted

Occurs when the playback of a media is finished.

Declaration
C#
Copy
public event EventHandler<EventArgs> PlaybackCompleted
Event Type
Type Description
System.EventHandler<EventArgs>
API Level: 3
View Source

PlaybackInterrupted

Occurs when the playback of a media is interrupted.

Declaration
C#
Copy
public event EventHandler<PlaybackInterruptedEventArgs> PlaybackInterrupted
Event Type
Type Description
System.EventHandler<PlaybackInterruptedEventArgs>
Remarks

If the reason is ResourceConflict, the player state will be one of Idle, Ready, or Paused.

See Also
API Level: 3
View Source

SubtitleUpdated

Occurs when the subtitle is updated.

Declaration
C#
Copy
public event EventHandler<SubtitleUpdatedEventArgs> SubtitleUpdated
Event Type
Type Description
System.EventHandler<SubtitleUpdatedEventArgs>
Remarks

The event handler will be executed on an internal thread.

API Level: 3
View Source

VideoFrameDecoded

Occurs when a video frame is decoded.

Declaration
C#
Copy
public event EventHandler<VideoFrameDecodedEventArgs> VideoFrameDecoded
Event Type
Type Description
System.EventHandler<VideoFrameDecodedEventArgs>
Remarks

The event handler will be executed on an internal thread.

The Packet in event args should be disposed after use.

Exceptions
Type Condition
System.NotSupportedException

The required feature is not supported.

See Also
API Level: 3
Feature: http://tizen.org/feature/multimedia.raw_video
View Source

VideoStreamChanged

Occurs when the video stream is changed.

Declaration
C#
Copy
public event EventHandler<VideoStreamChangedEventArgs> VideoStreamChanged
Event Type
Type Description
System.EventHandler<VideoStreamChangedEventArgs>
Remarks

The event handler will be executed on an internal thread.

API Level: 3

Implements

System.IDisposable