A game framework written with osu! in mind.

Handle by clamping `PlaybackPosition` rather than early returning

Changed files
+8 -20
osu.Framework
Graphics
osu.Framework.Tests
Visual
+4 -12
osu.Framework.Tests/Visual/Sprites/TestSceneVideo.cs
··· 95 95 AddUntilStep("decoding ran", () => didDecode); 96 96 } 97 97 98 - [Test] 99 - public void TestDecodingContinuesBeforeStartTimeIfLooping() 98 + [TestCase(false)] 99 + [TestCase(true)] 100 + public void TestDecodingStopsBeforeStartTime(bool looping) 100 101 { 101 - AddStep("Set looping", () => video.Loop = true); 102 - 103 - AddStep("Jump back to before start time", () => clock.CurrentTime = -30000); 104 - 105 - AddStep("reset decode state", () => didDecode = false); 106 - AddUntilStep("decoding ran", () => didDecode); 107 - } 102 + AddStep("Set looping", () => video.Loop = looping); 108 103 109 - [Test] 110 - public void TestDecodingStopsBeforeStartTime() 111 - { 112 104 AddStep("Jump back to before start time", () => clock.CurrentTime = -30000); 113 105 114 106 AddUntilStep("decoding stopped", () => video.State == VideoDecoder.DecoderState.Ready);
+4 -3
osu.Framework/Graphics/Animations/AnimationClockComposite.cs
··· 83 83 { 84 84 get 85 85 { 86 - if (Loop) 87 - return manualClock.CurrentTime % Duration; 86 + double current = manualClock.CurrentTime; 87 + 88 + if (Loop) current %= Duration; 88 89 89 - return Math.Min(manualClock.CurrentTime, Duration); 90 + return Math.Clamp(current, 0, Duration); 90 91 } 91 92 set 92 93 {
-5
osu.Framework/Graphics/Video/Video.cs
··· 127 127 } 128 128 } 129 129 130 - // if not looping and not yet having reached the start of the video, don't attempt to consume frames yet. 131 - // if we begin consuming frames the decoder will be performing unnecessary work. 132 - if (!Loop && PlaybackPosition < 0) 133 - return; 134 - 135 130 var peekFrame = availableFrames.Count > 0 ? availableFrames.Peek() : null; 136 131 bool outOfSync = false; 137 132