protected override void Update()
        {
            base.Update();

            // TODO: this logic will need to be consolidated with other game samples like hit sounds.
            if (Time.Current < sampleInfo.StartTime)
            {
                // We've rewound before the start time of the sample
                channel?.Stop();

                // In the case that the user fast-forwards to a point far beyond the start time of the sample,
                // we want to be able to fall into the if-conditional below (therefore we must not have a life time end)
                LifetimeStart = sampleInfo.StartTime;
                LifetimeEnd   = double.MaxValue;
            }
            else if (Time.Current - Time.Elapsed < sampleInfo.StartTime)
            {
                // We've passed the start time of the sample. We only play the sample if we're within an allowable range
                // from the sample's start, to reduce layering if we've been fast-forwarded far into the future
                if (Time.Current - sampleInfo.StartTime < allowable_late_start)
                {
                    channel?.Play();
                }

                // In the case that the user rewinds to a point far behind the start time of the sample,
                // we want to be able to fall into the if-conditional above (therefore we must not have a life time start)
                LifetimeStart = double.MinValue;
                LifetimeEnd   = sampleInfo.StartTime;
            }
        }
Exemplo n.º 2
0
        public void TestPlayingUpdatedAfterInlineStop()
        {
            channel = sample.Play();
            bass.Update();

            bass.RunOnAudioThread(() => channel.Stop());
            Assert.That(channel.Playing, Is.False);
        }
        public void TestTogglePlaying()
        {
            SampleChannel channel = null;

            AddStep("play sample", () => channel = sample.Play());
            AddStep("stop channel", () => channel.Stop());
            AddStep("start channel", () => channel.Play());
            AddAssert("still playing", () => channel.Playing);
        }
Exemplo n.º 4
0
        public void TestStopBeforeLoadFinished()
        {
            channel = sample.Play();
            channel.Stop();

            bass.Update();

            Assert.IsFalse(channel.Playing);
        }
        public void TestStop()
        {
            channel = sample.Play();
            updateSample();

            channel.Stop();
            updateSample();

            Assert.IsFalse(channel.Playing);
        }
        protected override void LoadComplete()
        {
            base.LoadComplete();

            AddStep("start sample", () =>
            {
                channel         = sample.Play();
                channel.Looping = true;
            });

            AddStep("stop sample", () => channel.Stop());
        }
Exemplo n.º 7
0
        public void TestStopWhileLooping()
        {
            AddStep("create sample", createSample);

            AddStep("enable looping", () => sampleChannel.Looping = true);
            AddStep("play sample", () => sampleChannel.Play());

            AddWaitStep("wait", 1);
            AddAssert("is playing", () => sampleChannel.Playing);

            AddStep("stop playing", () => sampleChannel.Stop());
            AddAssert("not playing", () => !sampleChannel.Playing);
        }
        public void TestPlayLoopingSample()
        {
            SampleChannel channel = null;

            AddStep("play sample", () =>
            {
                channel         = sample.GetChannel();
                channel.Looping = true;
                channel.Play();
            });

            AddWaitStep("wait for loop", 20);
            AddAssert("still playing", () => channel.Playing);
            AddStep("stop playing", () => channel.Stop());
        }
Exemplo n.º 9
0
 /// <summary>
 /// Stops the sample.
 /// </summary>
 public void Stop()
 {
     activeChannel?.Stop();
     activeChannel = null;
 }
Exemplo n.º 10
0
 public void Stop() => channel.Stop();
Exemplo n.º 11
0
 private void stopAndCheckSample()
 {
     AddStep("stop playing", () => sampleChannel.Stop());
     AddUntilStep("stopped", () => !sampleChannel.Playing);
 }
Exemplo n.º 12
0
 private void stopAndCheckSample()
 {
     AddStep("stop playing", () => channel?.Stop());
     AddUntilStep("stopped", () => channel?.Playing != true);
 }