[MediaPlayer] Modified the PrepareAsync method as a LongRunning task and not to use... 84/165484/3
authorcoderhyme <jhyo.kim@samsung.com>
Fri, 29 Dec 2017 08:13:45 +0000 (17:13 +0900)
committerJungHo Kim <jhyo.kim@samsung.com>
Tue, 2 Jan 2018 22:48:29 +0000 (22:48 +0000)
Change-Id: I5fbc5099c39bfc4c77a9de5632475bad6e142dd3
Signed-off-by: coderhyme <jhyo.kim@samsung.com>
src/Tizen.Multimedia.MediaPlayer/Player/Player.Events.cs
src/Tizen.Multimedia.MediaPlayer/Player/Player.cs

index e3ec8fd..913081c 100644 (file)
@@ -217,8 +217,6 @@ namespace Tizen.Multimedia
 
         private void RegisterVideoStreamChangedCallback()
         {
-            ValidatePlayerState(PlayerState.Idle);
-
             _videoStreamChangedCallback = (width, height, fps, bitrate, _) =>
             {
                 Log.Debug(PlayerLog.Tag, "height : " + height + ", width : " + width
index c1670ac..7ddc811 100644 (file)
@@ -273,28 +273,23 @@ namespace Tizen.Multimedia
 
             SetDisplay(_display).ThrowIfFailed("Failed to configure display of the player");
 
-            OnPreparing();
-
-            var completionSource = new TaskCompletionSource<bool>();
-
             SetPreparing();
 
-            Task.Run(() =>
+            OnPreparing();
+
+            return Task.Factory.StartNew(() =>
             {
                 try
                 {
                     Prepare();
-                    ClearPreparing();
-                    completionSource.SetResult(true);
                 }
-                catch (Exception e)
+                finally
                 {
                     ClearPreparing();
-                    completionSource.TrySetException(e);
                 }
-            });
-
-            return completionSource.Task;
+            }, CancellationToken.None,
+                TaskCreationOptions.DenyChildAttach | TaskCreationOptions.LongRunning,
+                TaskScheduler.Default);
         }
 
         /// <summary>