Fixed Unresponsive Playback Slider Issue 65/314265/2
authorMobaswirul Islam/NC eXperience Group /SRBD/Engineer/Samsung Electronics <mobaswirul.i@samsung.com>
Tue, 9 Jul 2024 08:44:54 +0000 (14:44 +0600)
committerMobaswirul Islam/NC eXperience Group /SRBD/Engineer/Samsung Electronics <mobaswirul.i@samsung.com>
Thu, 11 Jul 2024 05:09:52 +0000 (11:09 +0600)
[Problem] [TNINE-3739] Progress Bar interaction did not change in Music Player

[Cause & Measure]
 Cause : MediaInfo/AudioInfo doesn't have tracklength information.
 Measure : Used player.StreamInfo.GetDuration() to geth tracklength.

Change-Id: Ieebe0e539577adf70df42d4d10f0e36f5cd1814b
Signed-off-by: Mobaswirul Islam/NC eXperience Group /SRBD/Engineer/Samsung Electronics <mobaswirul.i@samsung.com>
music-player/Core/MusicPlayer.cs
music-player/Core/PlayerController.cs
music-player/ViewModels/PlayerViewModel.cs
packaging/org.tizen.MusicPlayer-1.0.0.tpk

index 0237cb32346dee6a8d8f8908a160db2c7b5daa34..7d4c5a43e1f4a85f7765bb8e49fa8bf1ea524cdc 100755 (executable)
@@ -106,6 +106,18 @@ namespace MusicPlayer.Core
             }
         }
 
+        public int GetTrackDuration()
+        {
+            if (player != null)
+            {
+                if (player.StreamInfo != null)
+                {
+                    return player.StreamInfo.GetDuration();
+                }
+            }
+            return 0;
+        }
+
         public void Stop()
         {
             if(ValidatePlayerState(PlayerValidationState.Stop))
index 4cd4a80b9f5247ec68c873d290d51a2652b721b3..7cec9ad84543aa30793b4d25aa35dd745ee0c76d 100755 (executable)
@@ -69,6 +69,15 @@ namespace MusicPlayer.Core
             musicPlayer.Pause();
         }
 
+        public int GetTrackDuration()
+        {
+            if (musicPlayer == null)
+            {
+                return 0;
+            }
+            return musicPlayer.GetTrackDuration();
+        }
+
         public void Resume()
         {
             if (musicPlayer.State == PlayerState.Paused)
index dbc44c8a9d41215838f2f58eaa1c9c80c3b74737..6ad737ccf8912da7106e36aece5c907c948ee24d 100755 (executable)
@@ -254,7 +254,7 @@ namespace MusicPlayer.ViewModels
 
         public void SetElapsedTime(float value)
         {
-            int currentPosition = (int)(playerModel.CurrentTrack.DurationInMS * value);
+            int currentPosition = (int)(GetTrackDuration() * value);
             playerModel.PlayingTime = TimeSpan.FromMilliseconds(currentPosition).ToString(AppConstants.TimeFormat);
         }
 
@@ -402,8 +402,14 @@ namespace MusicPlayer.ViewModels
         private void UpdatePlayingTime()
         {
             int position = PlayerController.Instance.GetPosition();
-            playerModel.ElapsedTime = position / (float)playerModel.CurrentTrack.DurationInMS;
+            int duration = GetTrackDuration();
+
+            if (duration <= 0) return;
+
+            float elapsedTime = 1.0f * position / duration;
+            playerModel.ElapsedTime = Math.Min(1.0f, Math.Max(0.0f, elapsedTime));
             playerModel.PlayingTime = TimeSpan.FromMilliseconds(position).ToString(AppConstants.TimeFormat);
+            playerModel.TrackLength = TimeSpan.FromMilliseconds(duration).ToString(AppConstants.TimeFormat);
         }
 
         private void StartPlayback()
@@ -428,6 +434,19 @@ namespace MusicPlayer.ViewModels
         {
             PlayerController.Instance.Pause();
         }
+
+        private int GetTrackDuration()
+        {
+            int duration = playerModel.CurrentTrack.DurationInMS;
+            if (playerModel.CurrentTrack.DurationInMS <= 0)
+            {
+                duration = PlayerController.Instance.GetTrackDuration();
+                playerModel.CurrentTrack.DurationInMS = duration;
+                playerModel.CurrentTrack.Duration = TimeSpan.FromMilliseconds(duration).ToString(AppConstants.TimeFormat);
+            }
+            return duration;
+        }
+
         private void Resume()
         {
             PlayerController.Instance.Resume();
index b7047f66207dfd5eb5866cd59eb61c9ee99912ef..7a89623ee1acfd9796b0db3dec8361f3767955c0 100755 (executable)
Binary files a/packaging/org.tizen.MusicPlayer-1.0.0.tpk and b/packaging/org.tizen.MusicPlayer-1.0.0.tpk differ