mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 14:57:52 +08:00
Don't stop non-looping samples immediately when pausing
This commit is contained in:
parent
e41085dbb5
commit
758088672c
@ -109,9 +109,9 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
||||
}
|
||||
}
|
||||
|
||||
public override void StopAllSamples()
|
||||
public override void StopLoopingSamples()
|
||||
{
|
||||
base.StopAllSamples();
|
||||
base.StopLoopingSamples();
|
||||
slidingSample?.Stop();
|
||||
}
|
||||
|
||||
|
@ -124,9 +124,9 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
||||
}
|
||||
}
|
||||
|
||||
public override void StopAllSamples()
|
||||
public override void StopLoopingSamples()
|
||||
{
|
||||
base.StopAllSamples();
|
||||
base.StopLoopingSamples();
|
||||
spinningSample?.Stop();
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,7 @@ using osu.Game.Rulesets.Objects.Types;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Skinning;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Screens.Play;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Rulesets.Objects.Drawables
|
||||
@ -387,7 +388,10 @@ namespace osu.Game.Rulesets.Objects.Drawables
|
||||
/// <summary>
|
||||
/// Stops playback of all samples. Automatically called when <see cref="DrawableHitObject{TObject}"/>'s lifetime has been exceeded.
|
||||
/// </summary>
|
||||
public virtual void StopAllSamples() => Samples?.Stop();
|
||||
public virtual void StopLoopingSamples()
|
||||
{
|
||||
if (Samples?.Looping == true)
|
||||
Samples.Stop();
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
@ -457,7 +461,9 @@ namespace osu.Game.Rulesets.Objects.Drawables
|
||||
foreach (var nested in NestedHitObjects)
|
||||
nested.OnKilled();
|
||||
|
||||
StopAllSamples();
|
||||
// failsafe to ensure looping samples don't get stuck in a playing state.
|
||||
// this could occur in a non-frame-stable context where DrawableHitObjects get killed before a SkinnableSound has the chance to be stopped.
|
||||
StopLoopingSamples();
|
||||
|
||||
UpdateResult(false);
|
||||
}
|
||||
|
@ -34,21 +34,21 @@ namespace osu.Game.Skinning
|
||||
samplePlaybackDisabled.BindTo(samplePlaybackDisabler.SamplePlaybackDisabled);
|
||||
samplePlaybackDisabled.BindValueChanged(disabled =>
|
||||
{
|
||||
if (RequestedPlaying)
|
||||
if (!RequestedPlaying) return;
|
||||
|
||||
// let non-looping samples that have already been started play out to completion (sounds better than abruptly cutting off).
|
||||
if (!Looping) return;
|
||||
|
||||
if (disabled.NewValue)
|
||||
base.Stop();
|
||||
else
|
||||
{
|
||||
if (disabled.NewValue)
|
||||
base.Stop();
|
||||
// it's not easy to know if a sample has finished playing (to end).
|
||||
// to keep things simple only resume playing looping samples.
|
||||
else if (Looping)
|
||||
// schedule so we don't start playing a sample which is no longer alive.
|
||||
Schedule(() =>
|
||||
{
|
||||
// schedule so we don't start playing a sample which is no longer alive.
|
||||
Schedule(() =>
|
||||
{
|
||||
if (RequestedPlaying)
|
||||
base.Play();
|
||||
});
|
||||
}
|
||||
if (RequestedPlaying)
|
||||
base.Play();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user