예제 #1
0
 private void load(ISamplePlaybackDisabler samplePlaybackDisabler)
 {
     // if in a gameplay context, pause sample playback when gameplay is paused.
     if (samplePlaybackDisabler != null)
     {
         samplePlaybackDisabled.BindTo(samplePlaybackDisabler.SamplePlaybackDisabled);
         samplePlaybackDisabled.BindValueChanged(disabled =>
         {
             if (RequestedPlaying)
             {
                 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(() =>
                     {
                         if (RequestedPlaying)
                         {
                             base.Play();
                         }
                     });
                 }
             }
         });
     }
 }
예제 #2
0
 private void load(GameplayClock clock, ISamplePlaybackDisabler sampleDisabler)
 {
     if (clock != null)
     {
         parentGameplayClock = frameStableClock.ParentGameplayClock = clock;
         frameStableClock.IsPaused.BindTo(clock.IsPaused);
     }
 }
예제 #3
0
 private void load(ISamplePlaybackDisabler samplePlaybackDisabler)
 {
     // if in a gameplay context, pause sample playback when gameplay is paused.
     if (samplePlaybackDisabler != null)
     {
         samplePlaybackDisabled.BindTo(samplePlaybackDisabler.SamplePlaybackDisabled);
         samplePlaybackDisabled.BindValueChanged(SamplePlaybackDisabledChanged);
     }
 }
예제 #4
0
        private void load(GameplayClock clock, ISamplePlaybackDisabler sampleDisabler)
        {
            if (clock != null)
            {
                parentGameplayClock = stabilityGameplayClock.ParentGameplayClock = clock;
                GameplayClock.IsPaused.BindTo(clock.IsPaused);
            }

            // this is a bit temporary. should really be done inside of GameplayClock (but requires large structural changes).
            stabilityGameplayClock.ParentSampleDisabler = sampleDisabler;
        }
        public void TestAllSamplesStopDuringSeek()
        {
            DrawableSlider slider = null;

            PoolableSkinnableSample[] samples        = null;
            ISamplePlaybackDisabler   sampleDisabler = null;

            AddUntilStep("get variables", () =>
            {
                sampleDisabler = Player;
                slider         = Player.ChildrenOfType <DrawableSlider>().MinBy(s => s.HitObject.StartTime);
                samples        = slider?.ChildrenOfType <PoolableSkinnableSample>().ToArray();

                return(slider != null);
            });

            AddUntilStep("wait for slider sliding then seek", () =>
            {
                if (!slider.Tracking.Value)
                {
                    return(false);
                }

                if (!samples.Any(s => s.Playing))
                {
                    return(false);
                }

                Player.ChildrenOfType <GameplayClockContainer>().First().Seek(40000);
                return(true);
            });

            AddAssert("sample playback disabled", () => sampleDisabler.SamplePlaybackDisabled.Value);

            // because we are in frame stable context, it's quite likely that not all samples are "played" at this point.
            // the important thing is that at least one started, and that sample has since stopped.
            AddAssert("all looping samples stopped immediately", () => allStopped(allLoopingSounds));
            AddUntilStep("all samples stopped eventually", () => allStopped(allSounds));

            AddAssert("sample playback still disabled", () => sampleDisabler.SamplePlaybackDisabled.Value);

            AddUntilStep("seek finished, sample playback enabled", () => !sampleDisabler.SamplePlaybackDisabled.Value);
            AddUntilStep("any sample is playing", () => Player.ChildrenOfType <PausableSkinnableSound>().Any(s => s.IsPlaying));
        }
예제 #6
0
        private void load(ISamplePlaybackDisabler samplePlaybackDisabler)
        {
            // if in a gameplay context, pause sample playback when gameplay is paused.
            if (samplePlaybackDisabler != null)
            {
                samplePlaybackDisabled.BindTo(samplePlaybackDisabler.SamplePlaybackDisabled);
                samplePlaybackDisabled.BindValueChanged(disabled =>
                {
                    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;
                    }

                    cancelPendingStart();

                    if (disabled.NewValue)
                    {
                        base.Stop();
                    }
                    else
                    {
                        // schedule so we don't start playing a sample which is no longer alive.
                        scheduledStart = Schedule(() =>
                        {
                            if (RequestedPlaying)
                            {
                                base.Play();
                            }
                        });
                    }
                });
            }
        }