Stinkstudios / sono

A simple yet powerful JavaScript library for working with Web Audio
http://stinkstudios.github.io/sono/
MIT License
170 stars 15 forks source link

Setting currentTime resets to 0 #19

Closed ameliemaia closed 7 years ago

ameliemaia commented 7 years ago

Hi, I've just began testing sono in https://github.com/Stinkstudios/boilerplate-component-test/blob/feature/sono/tests/functional/sono/_suite.js#L120.

When trying to set the currentTime or seek() I've noticed:

  1. It resets to 0
  2. It begins playback even if play() hasn't been called.

What should happen:

  1. currentTime should remain to the value set
  2. Playing shouldn't begin unless it's already playing
ianmcgregor commented 7 years ago

Hey @amelierosser I can't access that link. Can you add me or post a public link?

ameliemaia commented 7 years ago

Hi Ian, here's the code snippet!

 'audio seeks': function() {
        return (
          this.remote
            .get(require.toUrl(`${utils.getBaseUrl()}/sono/seek.html`))
            // Wait for the page to load
            .sleep(1000)
            // Play the audio
            .execute(function() {
              document.defaultView.testCase.player.play();
            })
            // Wait for the audio to play a little
            .sleep(2000)
            // Pause the audio and set the current time
            .execute(function() {
              document.defaultView.testCase.player.pause();
              document.defaultView.testCase.player.currentTime = 10;
            })
            // Wait a little more to make sure the audio currentTime doesn't change
            .sleep(1000)
            // Return the final currentTime
            .execute(function() {
              return document.defaultView.testCase.player.currentTime;
            })
            // Test whether the currentTime is equal to the seeked time
            .then(currentTime => {
              assert.equal(currentTime, 10);
            })
        );
ianmcgregor commented 7 years ago

Thanks Amelie, I'll take a look.

ameliemaia commented 7 years ago

Thank you Ian, it passed the test perfectly!