Class Player
Definition
- Namespace:
- Tizen.Multimedia
- Assembly:
- Tizen.Multimedia.MediaPlayer.dll
- API Level:
- 3
Provides the ability to control media playback.
C#Copypublic class Player : IDisposable
- Inheritance
-
Player
- Implements
-
Tizen.Multimedia.IDisplayable<Tizen.Multimedia.PlayerErrorCode>
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
Declaration
C#Copypublic Player()
API Level: 3
Player(IntPtr, Action<Int32, String>)
Initializes a new instance of the Player class with a native handle. The class takes care of the life cycle of the handle. Thus, it should not be closed/destroyed in another location.
Declaration
C#Copyprotected Player(IntPtr handle, Action<int, string> errorHandler)
Parameters
Type | Name | Description |
---|---|---|
IntPtr | handle | The handle for the media player. |
Action<Int32, String> | errorHandler | The handle for occuring error. |
Remarks
This supports the product infrastructure and is not intended to be used directly from application code.
API Level: 3
Properties
Declaration
C#Copypublic AdaptiveVariants AdaptiveVariants { get; }
Property Value
Type | Description |
---|---|
AdaptiveVariants |
API Level: 5
Declaration
C#Copypublic CodecType AudioCodecType { get; set; }
Property Value
Type | Description |
---|---|
CodecType | A CodecType specifies the type. The default codec type could be different depending on the device capability. |
Remarks
To set, the player must be in the Idle state.
If H/W audio codec type is not supported in some cases, S/W audio codec type could be used instead.
The availability could be changed depending on the codec capability.
If an application wants to use the H/W audio codec type as default,
The following functions should be called after the codec type is set. :
IsAvailable
EnableExportingAudioData(AudioMediaFormat, PlayerAudioExtractOption)
DisableExportingAudioData()
ReplayGain
AudioPitch
AudioPitchEnabled
Exceptions
Type | Condition |
---|---|
CodecNotSupportedException | The selected codec is not supported. |
API Level: 6
Declaration
C#Copypublic AudioEffect AudioEffect { get; }
Property Value
Type | Description |
---|---|
AudioEffect |
API Level: 3
Feature: http://tizen.org/feature/multimedia.custom_audio_effect
Declaration
C#Copypublic 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 |
---|---|
NotAvailableException | If audio offload is enabled by calling IsEnabled. (Since tizen 6.0) |
See Also
API Level: 3
Declaration
C#Copypublic AudioOffload AudioOffload { get; }
Property Value
Type | Description |
---|---|
AudioOffload |
API Level: 6
Declaration
C#Copypublic float AudioPitch { get; set; }
Property Value
Type | Description |
---|---|
Single | The audio stream pitch value. The default is 1. |
Remarks
Enabling pitch control could increase the CPU usage on some devices. This function is used for audio content only. This function could be unavailable depending on the audio codec type.
Exceptions
Type | Condition |
---|---|
NotAvailableException | If audio offload is enabled by calling IsEnabled. (Since tizen 6.0)
-or- |
API Level: 6
AudioPitchEnabled
Enables or disables controlling the pitch of audio. Gets the status of controlling the pitch of audio.
Declaration
C#Copypublic bool AudioPitchEnabled { get; set; }
Property Value
Type | Description |
---|---|
Boolean | The value indicating whether or not AudioPitch is enabled. The default is false. |
Remarks
This function is used for audio content only. To set, the player must be in the Idle state. This function could be unavailable depending on the audio codec type.
Exceptions
Type | Condition |
---|---|
NotAvailableException | If audio offload is enabled by calling IsEnabled. (Since tizen 6.0)
-or- |
API Level: 6
Declaration
C#Copypublic PlayerTrackInfo AudioTrackInfo { get; }
Property Value
Type | Description |
---|---|
PlayerTrackInfo | A PlayerTrackInfo for audio. |
API Level: 3
Declaration
C#Copypublic PlayerBufferingTime BufferingTime { get; set; }
Property Value
Type | Description |
---|---|
PlayerBufferingTime |
Remarks
To set, the player must be in the Idle state.
See Also
API Level: 5
Declaration
C#Copypublic string Cookie { get; set; }
Property Value
Type | Description |
---|---|
String |
Remarks
To set, the player must be in the Idle state.
API Level: 3
Declaration
C#Copypublic 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.
If a user wants to use video and UI sync mode, please use
But DisplaySettings is not supported in UI sync mode.
API Level: 3
Declaration
C#Copypublic PlayerDisplaySettings DisplaySettings { get; }
Property Value
Type | Description |
---|---|
PlayerDisplaySettings | A PlayerDisplaySettings that specifies the display settings. |
API Level: 3
Declaration
C#Copypublic IntPtr Handle { get; }
Property Value
Type | Description |
---|---|
IntPtr | An IntPtr that contains the native handle of the player. |
API Level: 3
HasSource
Determines whether MediaSource has set. This supports the product infrastructure and is not intended to be used directly from application code.
Declaration
C#Copyprotected bool HasSource { get; }
Property Value
Type | Description |
---|---|
Boolean |
Declaration
C#Copypublic bool IsAudioOnly { get; set; }
Property Value
Type | Description |
---|---|
Boolean | true if the playback is audio-only mode; otherwise, false. The default value is false. |
API Level: 5
Declaration
C#Copypublic bool IsLooping { get; set; }
Property Value
Type | Description |
---|---|
Boolean | true if the playback is looping; otherwise, false. The default value is false. |
API Level: 3
Declaration
C#Copypublic bool Muted { get; set; }
Property Value
Type | Description |
---|---|
Boolean | true if the player is muted; otherwise, false. |
API Level: 3
Declaration
C#Copypublic 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. |
Remarks
This function could be unavailable depending on the audio codec type.
Exceptions
Type | Condition |
---|---|
NotAvailableException | If audio offload is enabled by calling IsEnabled. (Since tizen 6.0)
-or- |
API Level: 5
Declaration
C#Copypublic SphericalVideo SphericalVideo { get; }
Property Value
Type | Description |
---|---|
SphericalVideo |
API Level: 5
Declaration
C#Copypublic PlayerState State { get; }
Property Value
Type | Description |
---|---|
PlayerState | The current state of the player. |
API Level: 3
Declaration
C#Copypublic StreamInfo StreamInfo { get; }
Property Value
Type | Description |
---|---|
StreamInfo | A StreamInfo for this player. |
API Level: 3
Declaration
C#Copypublic PlayerTrackInfo SubtitleTrackInfo { get; }
Property Value
Type | Description |
---|---|
PlayerTrackInfo | A PlayerTrackInfo for the subtitle. |
API Level: 3
Declaration
C#Copypublic string UserAgent { get; set; }
Property Value
Type | Description |
---|---|
String |
Remarks
To set, the player must be in the Idle state.
API Level: 3
Declaration
C#Copypublic CodecType VideoCodecType { get; set; }
Property Value
Type | Description |
---|---|
CodecType | A CodecType specifies the type. The default codec type could be different depending on the device capability. |
Remarks
To set, the player must be in the Idle state.
If H/W video codec type is not supported in some cases, S/W video codec type could be used instead.
The availability could be changed depending on the codec capability.
Exceptions
Type | Condition |
---|---|
CodecNotSupportedException | The selected codec is not supported. |
API Level: 11
Declaration
C#Copypublic float Volume { get; set; }
Property Value
Type | Description |
---|---|
Single |
Remarks
Valid volume range is from 0 to 1.0, inclusive.
API Level: 3
Methods
Declaration
C#Copypublic 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.
See Also
API Level: 3
Feature: http://tizen.org/feature/multimedia.player.stream_info
Declaration
C#Copypublic Task<CapturedFrame> CaptureVideoAsync()
Returns
Type | Description |
---|---|
Task<CapturedFrame> | A task that represents the asynchronous capture operation. |
Remarks
API Level: 3
Feature: http://tizen.org/feature/multimedia.raw_video
ClearPreparing()
This supports the product infrastructure and is not intended to be used directly from application code.
Declaration
C#Copyprotected void ClearPreparing()
Declaration
C#Copypublic void ClearSubtitle()
Remarks
The player must be in the Idle state.
API Level: 3
Declaration
C#Copypublic void DisableExportingAudioData()
Remarks
The player must be in the Idle or Ready state. This function could be unavailable depending on the audio codec type.
Exceptions
Type | Condition |
---|---|
NotAvailableException | The function is not available depending on the audio codec type. (Since tizen 6.0) |
API Level: 6
Declaration
C#Copypublic void DisableExportingVideoFrame()
Remarks
See Also
API Level: 6
Feature: http://tizen.org/feature/multimedia.raw_video
Declaration
C#Copypublic void Dispose()
API Level: 3
Declaration
C#Copyprotected virtual void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
Boolean | disposing | true to release both managed and unmanaged resources; false to release only unmanaged resources. |
EnableExportingAudioData(AudioMediaFormat, PlayerAudioExtractOption)
Enable to decode an audio data for exporting PCM from a data.
Declaration
C#Copypublic void EnableExportingAudioData(AudioMediaFormat format, PlayerAudioExtractOption option)
Parameters
Type | Name | Description |
---|---|---|
AudioMediaFormat | format | The media format handle required to audio PCM specification. The format has to include MimeType, Channel and SampleRate. If the format is NULL, the original PCM format or platform default PCM format will be applied. |
PlayerAudioExtractOption | option | The audio extract option. |
Remarks
The player must be in the Idle state.
A AudioDataDecoded event is called in a separate thread(not in the main loop).
The audio PCM data can be retrieved using a AudioDataDecoded event as a media packet and it is available until it's destroyed by Dispose(). The packet has to be destroyed as quickly as possible after rendering the data and all the packets have to be destroyed before Unprepare() is called.
This function could be unavailable depending on the audio codec type.
Exceptions
Type | Condition |
---|---|
NotAvailableException | If audio offload is enabled by calling IsEnabled. (Since tizen 6.0)
-or- |
API Level: 6
Declaration
C#Copypublic void EnableExportingVideoFrame()
Remarks
The player must be in the Idle state, but Display must not be set.
A VideoFrameDecoded event is called in a separate thread, not called in the main loop.
The video frame can be retrieved using a VideoFrameDecoded event with a media packet parameter. If you change the media packet in the VideoFrameDecoded event, it will be displayed on the device. The callback function holds the same buffer that is drawn on the display device. and the MediaPacket is available until it is destroyed by Dispose(). It is recommended to destroy the packet as quickly as possible after the decoded data is rendered on the display. All the packets have to be destroyed before Unprepare() is called.
See Also
API Level: 6
Feature: http://tizen.org/feature/multimedia.raw_video
Declaration
C#Copypublic DownloadProgress GetDownloadProgress()
Returns
Type | Description |
---|---|
DownloadProgress | The DownloadProgress containing current download progress. |
Remarks
API Level: 3
GetException(Int32, String)
This method supports the product infrastructure and is not intended to be used directly from application code.
Declaration
C#Copyprotected static Exception GetException(int errorCode, string message)
Parameters
Type | Name | Description |
---|---|---|
Int32 | errorCode | The error code according to the exception. |
String | message | The error message to show user. |
Returns
Type | Description |
---|---|
Exception |
API Level: 4
GetMediaPacket(IntPtr)
This supports the product infrastructure and is not intended to be used directly from application code.
Declaration
C#Copyprotected MediaPacket GetMediaPacket(IntPtr handle)
Parameters
Type | Name | Description |
---|---|---|
IntPtr | handle |
Returns
Type | Description |
---|---|
MediaPacket |
API Level: 3
Declaration
C#Copypublic int GetPlayPosition()
Returns
Type | Description |
---|---|
Int32 | The current position in milliseconds. |
Remarks
See Also
API Level: 3
Declaration
C#Copypublic long GetPlayPositionNanoseconds()
Returns
Type | Description |
---|---|
Int64 | The current position in nanoseconds. |
Remarks
See Also
API Level: 5
GetVideoRoi()
Get the relative ROI (Region Of Interest) area as a decimal fraction based on the video source.
Declaration
C#Copypublic 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.
API Level: 5
Initialize()
This supports the product infrastructure and is not intended to be used directly from application code.
Declaration
C#Copyprotected void Initialize()
Declaration
C#Copyprotected void OnErrorOccurred(PlayerErrorOccurredEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
PlayerErrorOccurredEventArgs | e | An PlayerErrorOccurredEventArgs that contains the event data. |
Declaration
C#Copyprotected virtual void OnPreparing()
API Level: 3
Declaration
C#Copyprotected virtual void OnUnprepared()
See Also
API Level: 3
Declaration
C#Copypublic 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.
See Also
API Level: 3
Declaration
C#Copypublic 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.
See Also
API Level: 3
PrepareAsync(CancellationToken)
Prepares the cancelable media player for playback, asynchronously.
Declaration
C#Copypublic virtual Task PrepareAsync(CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | cancellationToken | The cancellation token to cancel preparing. |
Returns
Type | Description |
---|---|
Task | The 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. The state must be Preparing to cancel preparing. When preparing is cancelled, a state will be changed to Idle from Preparing.
API Level: 3
Declaration
C#Copypublic 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 |
---|---|
NotAvailableException | If audio offload is enabled by calling IsEnabled. (Since tizen 6.0) |
See Also
API Level: 3
SetPlayPositionAsync(Int32, Boolean)
Sets the seek position for playback, asynchronously.
Declaration
C#Copypublic Task SetPlayPositionAsync(int position, bool accurate)
Parameters
Type | Name | Description |
---|---|---|
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.
See Also
API Level: 3
SetPlayPositionNanosecondsAsync(Int64, Boolean)
Sets the seek position in nanoseconds for playback, asynchronously.
Declaration
C#Copypublic Task SetPlayPositionNanosecondsAsync(long position, bool accurate)
Parameters
Type | Name | Description |
---|---|---|
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.
API Level: 5
SetPreparing()
This supports the product infrastructure and is not intended to be used directly from application code.
Declaration
C#Copyprotected void SetPreparing()
Declaration
C#Copypublic 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.
API Level: 3
Declaration
C#Copypublic void SetSubtitle(string path)
Parameters
Type | Name | Description |
---|---|---|
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.
API Level: 3
Declaration
C#Copypublic void SetSubtitleOffset(int offset)
Parameters
Type | Name | Description |
---|---|---|
Int32 | offset | The value indicating a desired offset in milliseconds. |
Remarks
See Also
API Level: 3
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#Copypublic 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
API Level: 5
Declaration
C#Copypublic 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.
See Also
API Level: 3
Declaration
C#Copypublic 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.
API Level: 3
Declaration
C#Copypublic 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() or PrepareAsync(CancellationToken) 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.
API Level: 3
Events
Declaration
C#Copypublic event EventHandler<AudioDataDecodedEventArgs> AudioDataDecoded
Event Type
Type | Description |
---|---|
EventHandler<AudioDataDecodedEventArgs> |
Remarks
The event handler will be executed on an internal thread.
The Packet in event args should be disposed after use.
See Also
API Level: 6
BufferingProgressChanged
Occurs when there is a change in the buffering status of streaming.
Declaration
C#Copypublic event EventHandler<BufferingProgressChangedEventArgs> BufferingProgressChanged
Event Type
Type | Description |
---|---|
EventHandler<BufferingProgressChangedEventArgs> |
API Level: 3
Declaration
C#Copypublic event EventHandler<PlayerErrorOccurredEventArgs> ErrorOccurred
Event Type
Type | Description |
---|---|
EventHandler<PlayerErrorOccurredEventArgs> |
Remarks
The event handler will be executed on an internal thread.
API Level: 3
Declaration
C#Copypublic event EventHandler<EventArgs> PlaybackCompleted
Event Type
Type | Description |
---|---|
EventHandler<EventArgs> |
API Level: 3
Declaration
C#Copypublic event EventHandler<PlaybackInterruptedEventArgs> PlaybackInterrupted
Event Type
Type | Description |
---|---|
EventHandler<PlaybackInterruptedEventArgs> |
Remarks
If the reason is ResourceConflict, the player state will be one of Idle, Ready, or Paused.
See Also
API Level: 3
Declaration
C#Copypublic event EventHandler<SubtitleUpdatedEventArgs> SubtitleUpdated
Event Type
Type | Description |
---|---|
EventHandler<SubtitleUpdatedEventArgs> |
Remarks
The event handler will be executed on an internal thread.
API Level: 3
Declaration
C#Copypublic event EventHandler<VideoFrameDecodedEventArgs> VideoFrameDecoded
Event Type
Type | Description |
---|---|
EventHandler<VideoFrameDecodedEventArgs> |
Remarks
The event handler will be executed on an internal thread.
The Packet in event args should be disposed after use.
See Also
API Level: 3
Feature: http://tizen.org/feature/multimedia.raw_video
Declaration
C#Copypublic event EventHandler<VideoStreamChangedEventArgs> VideoStreamChanged
Event Type
Type | Description |
---|---|
EventHandler<VideoStreamChangedEventArgs> |
Remarks
The event handler will be executed on an internal thread.