[Multimedia] Modified a constructor of the Display class not to check the raw video...
[platform/core/csapi/tizenfx.git] / src / Tizen.Multimedia.MediaPlayer / Player / Player.cs
index 7dd4035..c1670ac 100644 (file)
@@ -20,6 +20,7 @@ using System.Diagnostics;
 using System.IO;
 using System.Threading;
 using static Interop;
+using System.ComponentModel;
 
 namespace Tizen.Multimedia
 {
@@ -43,6 +44,7 @@ namespace Tizen.Multimedia
         /// <summary>
         /// Initializes a new instance of the <see cref="Player"/> class.
         /// </summary>
+        /// <since_tizen> 3 </since_tizen>
         public Player()
         {
             NativePlayer.Create(out _handle).ThrowIfFailed("Failed to create player");
@@ -51,12 +53,12 @@ namespace Tizen.Multimedia
 
             RetrieveProperties();
 
-            if (Features.IsSupported(Features.AudioEffect))
+            if (Features.IsSupported(PlayerFeatures.AudioEffect))
             {
                 _audioEffect = new AudioEffect(this);
             }
 
-            if (Features.IsSupported(Features.RawVideo))
+            if (Features.IsSupported(PlayerFeatures.RawVideo))
             {
                 RegisterVideoFrameDecodedCallback();
             }
@@ -86,6 +88,7 @@ namespace Tizen.Multimedia
         /// <summary>
         /// Releases all resources used by the current instance.
         /// </summary>
+        /// <since_tizen> 3 </since_tizen>
         public void Dispose()
         {
             Dispose(true);
@@ -138,11 +141,12 @@ namespace Tizen.Multimedia
         /// <returns>The <see cref="DownloadProgress"/> containing current download progress.</returns>
         /// <remarks>The player must be in the <see cref="PlayerState.Playing"/> or <see cref="PlayerState.Paused"/> state.</remarks>
         /// <exception cref="InvalidOperationException">
-        ///     The player is not streaming.\n
-        ///     -or-\n
+        ///     The player is not streaming.<br/>
+        ///     -or-<br/>
         ///     The player is not in the valid state.
         ///     </exception>
         /// <exception cref="ObjectDisposedException">The player has already been disposed of.</exception>
+        /// <since_tizen> 3 </since_tizen>
         public DownloadProgress GetDownloadProgress()
         {
             ValidatePlayerState(PlayerState.Playing, PlayerState.Paused);
@@ -167,7 +171,8 @@ namespace Tizen.Multimedia
         /// <exception cref="ObjectDisposedException">The player has already been disposed of.</exception>
         /// <exception cref="ArgumentException"><paramref name="path"/> is an empty string.</exception>
         /// <exception cref="FileNotFoundException">The specified path does not exist.</exception>
-        /// <exception cref="ArgumentNullException">The path is null.</exception>
+        /// <exception cref="ArgumentNullException"><paramref name="path"/> is null.</exception>
+        /// <since_tizen> 3 </since_tizen>
         public void SetSubtitle(string path)
         {
             ValidateNotDisposed();
@@ -197,6 +202,7 @@ namespace Tizen.Multimedia
         /// <remarks>The player must be in the <see cref="PlayerState.Idle"/> state.</remarks>
         /// <exception cref="ObjectDisposedException">The player has already been disposed of.</exception>
         /// <exception cref="InvalidOperationException">The player is not in the valid state.</exception>
+        /// <since_tizen> 3 </since_tizen>
         public void ClearSubtitle()
         {
             ValidatePlayerState(PlayerState.Idle);
@@ -212,11 +218,12 @@ namespace Tizen.Multimedia
         /// <remarks>The player must be in the <see cref="PlayerState.Playing"/> or <see cref="PlayerState.Paused"/> state.</remarks>
         /// <exception cref="ObjectDisposedException">The player has already been disposed of.</exception>
         /// <exception cref="InvalidOperationException">
-        ///     The player is not in the valid state.\n
-        ///     -or-\n
+        ///     The player is not in the valid state.<br/>
+        ///     -or-<br/>
         ///     No subtitle is set.
         /// </exception>
         /// <seealso cref="SetSubtitle(string)"/>
+        /// <since_tizen> 3 </since_tizen>
         public void SetSubtitleOffset(int offset)
         {
             ValidatePlayerState(PlayerState.Playing, PlayerState.Paused);
@@ -239,6 +246,7 @@ namespace Tizen.Multimedia
         /// <summary>
         /// Called when the <see cref="Prepare"/> is invoked.
         /// </summary>
+        /// <since_tizen> 3 </since_tizen>
         protected virtual void OnPreparing()
         {
             RegisterEvents();
@@ -253,6 +261,7 @@ namespace Tizen.Multimedia
         /// <exception cref="InvalidOperationException">No source is set.</exception>
         /// <exception cref="ObjectDisposedException">The player has already been disposed of.</exception>
         /// <exception cref="InvalidOperationException">The player is not in the valid state.</exception>
+        /// <since_tizen> 3 </since_tizen>
         public virtual Task PrepareAsync()
         {
             if (_source == null)
@@ -262,6 +271,8 @@ namespace Tizen.Multimedia
 
             ValidatePlayerState(PlayerState.Idle);
 
+            SetDisplay(_display).ThrowIfFailed("Failed to configure display of the player");
+
             OnPreparing();
 
             var completionSource = new TaskCompletionSource<bool>();
@@ -299,6 +310,7 @@ namespace Tizen.Multimedia
         /// </remarks>
         /// <exception cref="ObjectDisposedException">The player has already been disposed of.</exception>
         /// <exception cref="InvalidOperationException">The player is not in the valid state.</exception>
+        /// <since_tizen> 3 </since_tizen>
         public virtual void Unprepare()
         {
             if (State == PlayerState.Idle)
@@ -317,6 +329,7 @@ namespace Tizen.Multimedia
         /// Called after the <see cref="Player"/> is unprepared.
         /// </summary>
         /// <seealso cref="Unprepare"/>
+        /// <since_tizen> 3 </since_tizen>
         protected virtual void OnUnprepared()
         {
             _source?.DetachFrom(this);
@@ -328,8 +341,8 @@ namespace Tizen.Multimedia
         /// </summary>
         /// <remarks>
         /// The player must be in the <see cref="PlayerState.Ready"/> or <see cref="PlayerState.Paused"/> state.
-        /// It has no effect if the player is already in the <see cref="PlayerState.Playing"/> state.\n
-        /// \n
+        /// It has no effect if the player is already in the <see cref="PlayerState.Playing"/> state.<br/>
+        /// <br/>
         /// Sound can be mixed with other sounds if you don't control the stream focus using <see cref="ApplyAudioStreamPolicy"/>.
         /// </remarks>
         /// <exception cref="ObjectDisposedException">The player has already been disposed of.</exception>
@@ -339,6 +352,7 @@ namespace Tizen.Multimedia
         /// <seealso cref="Pause"/>
         /// <seealso cref="PlaybackCompleted"/>
         /// <seealso cref="ApplyAudioStreamPolicy"/>
+        /// <since_tizen> 3 </since_tizen>
         public virtual void Start()
         {
             if (State == PlayerState.Playing)
@@ -362,6 +376,7 @@ namespace Tizen.Multimedia
         /// <exception cref="InvalidOperationException">The player is not in the valid state.</exception>
         /// <seealso cref="Start"/>
         /// <seealso cref="Pause"/>
+        /// <since_tizen> 3 </since_tizen>
         public virtual void Stop()
         {
             if (State == PlayerState.Ready)
@@ -384,6 +399,7 @@ namespace Tizen.Multimedia
         /// <exception cref="ObjectDisposedException">The player has already been disposed of.</exception>
         /// <exception cref="InvalidOperationException">The player is not in the valid state.</exception>
         /// <seealso cref="Start"/>
+        /// <since_tizen> 3 </since_tizen>
         public virtual void Pause()
         {
             if (State == PlayerState.Paused)
@@ -406,11 +422,12 @@ namespace Tizen.Multimedia
         /// <remarks>The player must be in the <see cref="PlayerState.Idle"/> state.</remarks>
         /// <exception cref="ObjectDisposedException">The player has already been disposed of.</exception>
         /// <exception cref="InvalidOperationException">
-        ///     The player is not in the valid state.\n
-        ///     -or-\n
+        ///     The player is not in the valid state.<br/>
+        ///     -or-<br/>
         ///     It is not able to assign the source to the player.
         ///     </exception>
         /// <seealso cref="PrepareAsync"/>
+        /// <since_tizen> 3 </since_tizen>
         public void SetSource(MediaSource source)
         {
             ValidatePlayerState(PlayerState.Idle);
@@ -437,9 +454,10 @@ namespace Tizen.Multimedia
         /// <exception cref="ObjectDisposedException">The player has already been disposed of.</exception>
         /// <exception cref="InvalidOperationException">The player is not in the valid state.</exception>
         /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
+        /// <since_tizen> 3 </since_tizen>
         public async Task<CapturedFrame> CaptureVideoAsync()
         {
-            ValidationUtil.ValidateFeatureSupported(Features.RawVideo);
+            ValidationUtil.ValidateFeatureSupported(PlayerFeatures.RawVideo);
 
             ValidatePlayerState(PlayerState.Playing, PlayerState.Paused);
 
@@ -472,6 +490,7 @@ namespace Tizen.Multimedia
         /// <exception cref="ObjectDisposedException">The player has already been disposed of.</exception>
         /// <exception cref="InvalidOperationException">The player is not in the valid state.</exception>
         /// <seealso cref="SetPlayPositionAsync(int, bool)"/>
+        /// <since_tizen> 3 </since_tizen>
         public int GetPlayPosition()
         {
             ValidatePlayerState(PlayerState.Ready, PlayerState.Paused, PlayerState.Playing);
@@ -519,11 +538,12 @@ namespace Tizen.Multimedia
         /// <exception cref="InvalidOperationException">The player is not in the valid state.</exception>
         /// <exception cref="ArgumentOutOfRangeException">The specified position is not valid.</exception>
         /// <seealso cref="GetPlayPosition"/>
+        /// <since_tizen> 3 </since_tizen>
         public async Task SetPlayPositionAsync(int position, bool accurate)
         {
             ValidatePlayerState(PlayerState.Ready, PlayerState.Playing, PlayerState.Paused);
 
-            var taskCompletionSource = new TaskCompletionSource<bool>();
+            var taskCompletionSource = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
 
             bool immediateResult = _source is MediaStreamSource;
 
@@ -552,17 +572,18 @@ namespace Tizen.Multimedia
         /// </remarks>
         /// <exception cref="ObjectDisposedException">The player has already been disposed of.</exception>
         /// <exception cref="InvalidOperationException">
-        ///     The player is not in the valid state.\n
-        ///     -or-\n
+        ///     The player is not in the valid state.<br/>
+        ///     -or-<br/>
         ///     Streaming playback.
         /// </exception>
         /// <exception cref="ArgumentOutOfRangeException">
-        ///     <paramref name="rate"/> is less than 5.0.\n
-        ///     -or-\n
-        ///     <paramref name="rate"/> is greater than 5.0.\n
-        ///     -or-\n
+        ///     <paramref name="rate"/> is less than 5.0.<br/>
+        ///     -or-<br/>
+        ///     <paramref name="rate"/> is greater than 5.0.<br/>
+        ///     -or-<br/>
         ///     <paramref name="rate"/> is zero.
         /// </exception>
+        /// <since_tizen> 3 </since_tizen>
         public void SetPlaybackRate(float rate)
         {
             if (rate < -5.0F || 5.0F < rate || rate == 0.0F)
@@ -580,17 +601,17 @@ namespace Tizen.Multimedia
         /// </summary>
         /// <param name="policy">The <see cref="AudioStreamPolicy"/> to apply.</param>
         /// <remarks>
-        /// The player must be in the <see cref="PlayerState.Idle"/> state.\n
-        /// \n
-        /// <see cref="Player"/> does not support all <see cref="AudioStreamType"/>.\n
+        /// The player must be in the <see cref="PlayerState.Idle"/> state.<br/>
+        /// <br/>
+        /// <see cref="Player"/> does not support all <see cref="AudioStreamType"/>.<br/>
         /// Supported types are <see cref="AudioStreamType.Media"/>, <see cref="AudioStreamType.System"/>,
         /// <see cref="AudioStreamType.Alarm"/>, <see cref="AudioStreamType.Notification"/>,
         /// <see cref="AudioStreamType.Emergency"/>, <see cref="AudioStreamType.VoiceInformation"/>,
         /// <see cref="AudioStreamType.RingtoneVoip"/> and <see cref="AudioStreamType.MediaExternalOnly"/>.
         /// </remarks>
         /// <exception cref="ObjectDisposedException">
-        ///     The player has already been disposed of.\n
-        ///     -or-\n
+        ///     The player has already been disposed of.<br/>
+        ///     -or-<br/>
         ///     <paramref name="policy"/> has already been disposed of.
         /// </exception>
         /// <exception cref="InvalidOperationException">The player is not in the valid state.</exception>
@@ -599,6 +620,7 @@ namespace Tizen.Multimedia
         ///     <see cref="AudioStreamType"/> of <paramref name="policy"/> is not supported by <see cref="Player"/>.
         /// </exception>
         /// <seealso cref="AudioStreamPolicy"/>
+        /// <since_tizen> 3 </since_tizen>
         public void ApplyAudioStreamPolicy(AudioStreamPolicy policy)
         {
             if (policy == null)
@@ -637,6 +659,8 @@ namespace Tizen.Multimedia
         /// <summary>
         /// This method supports the product infrastructure and is not intended to be used directly from application code.
         /// </summary>
+        /// <since_tizen> 4 </since_tizen>
+        [EditorBrowsable(EditorBrowsableState.Never)]
         protected static Exception GetException(int errorCode, string message) =>
             ((PlayerErrorCode)errorCode).GetException(message);
     }