Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mobile Safari gets confused if you try to play a sound that's already playing #23

Closed
jagthedrummer opened this issue Nov 2, 2023 · 5 comments

Comments

@jagthedrummer
Copy link

In mobile Safari if you call play on a sound that's already playing the status helpers show the sound as toggling to not playing and it gets stuck that way.

  • play/pause button shows "play"
  • tap "play"
  • sound begins to play & play/pause button shows "pause"
  • somehow call play on that sound again
  • sound continues to play & play/pause button shows "play"
  • tap "play"
  • sound continues to play & play/pause button shows "play"
  • there's now no way to pause the sound

To demonstrate you can stick an "always play" button right next to a normally configured button and the normal one will get stuck (only on mobile Safari as far as I can tell).

      <button {{on 'click' (toggle-play-sound @identifier)}}>
        {{#if (sound-is-playing @identifier)}}
          {{svg-jar 'pause-outline' height=20 width=30 title='Pause'}}
        {{else if (sound-is-loading @identifier)}}
          {{svg-jar 'loading-outline' height=20 width=30 title='Loading' class='animate-spin'}}
        {{else if (sound-is-loaded @identifier)}}
          {{svg-jar 'resume-outline' height=20 width=30 title='Pause'}}
        {{else}}
          {{svg-jar 'play-outline' height=20 width=30 title='Play'}}
        {{/if}}
      </button>

      <button {{on 'click' (play-sound @identifier)}}>
        {{svg-jar 'play-outline' height=20 width=30 title='Play'}}
      </button>

In mobile Safari tapping either button will start the sound. Tapping the first button will pause it. Tapping either button again will start it again. Tapping the second button will cause the first button to show that the sound has been paused even though it continues to play.

I realize this is a super weird edge case, and you obviously wouldn't put an "always play" button on a page. The way that this arose in my app is a little weird and it was easy enough to work around since I'm calling play in JS land, but just thought I'd report it since I ran into it.

My workaround:

if(!sound.isPlaying){
  sound.play();
}

(Fun fact: I ran into this in relation to the wavesurfer integration and trying to keep it and Ember Stereo in sync.)

@jkeen jkeen closed this as completed in dc32ba3 Nov 12, 2023
jkeen pushed a commit that referenced this issue Nov 12, 2023
## [4.2.3](v4.2.2...v4.2.3) (2023-11-12)

### Bug Fixes

* resolve issue when trying to play a sound that is already playing. fixes [#23](#23) ([dc32ba3](dc32ba3))
@jkeen
Copy link
Owner

jkeen commented Nov 12, 2023

🎉 This issue has been resolved in version 4.2.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

@jkeen jkeen added the released label Nov 12, 2023
jkeen pushed a commit that referenced this issue Nov 12, 2023
# [5.0.0-beta.12](v5.0.0-beta.11...v5.0.0-beta.12) (2023-11-12)

### Bug Fixes

* cancel block check if sound is already playing (howler) ([85254b2](85254b2))
* resolve issue when trying to play a sound that is already playing. fixes [#23](#23) ([321bc19](321bc19))
* send pause event when releasing control of shared audio element ([8620ab8](8620ab8))
@jkeen
Copy link
Owner

jkeen commented Nov 12, 2023

🎉 This issue has been resolved in version 5.0.0-beta.12 🎉

The release is available on:

Your semantic-release bot 📦🚀

@jagthedrummer
Copy link
Author

Sorry for the delay getting back to you on this @jkeen. It's not a big deal, but the problem is still reproducible for me on 4.2.3 and 4.3.0 under some circumstances. With the "always play" button it's still happening. But if I remove the workaround that I put in place when I first opened this issue it's not getting confused then. So my primary problem seems to be fixed, but the weird reproduction that nobody would probably do isn't. Or maybe there's something weird about my setup that's causing the problem. Dunno. Just wanted to report back. Thanks for the fix!

jkeen pushed a commit that referenced this issue Mar 18, 2024
# [5.0.0-beta.20](v5.0.0-beta.19...v5.0.0-beta.20) (2024-03-18)

### Bug Fixes

* if crossorigin=anonymous fails on <audio> element, automatically try removing crossorigin. Resolves CORS issue ([3bbda22](3bbda22))
* Implement proper teardown on sound destruction ([f1d6355](f1d6355))
* only show durationWorkaroundTask error if the task wasn't cancelled ([c5f6b08](c5f6b08))
* Resolve issue introduced in last version when multiple sound position sliders on the same page ([a2dc4bd](a2dc4bd))
* resolve issue when trying to play a sound that is already playing. fixes [#23](#23) ([dc32ba3](dc32ba3))
* Resolve issue where sound-position-progress modifier would not work with howler since howler doesn't emit audio-position-changed events ([77408ff](77408ff))
* Resolve some more bugs with sound-position modifiers ([fb496c3](fb496c3))
* send pause event when releasing control of shared audio element ([f7fec45](f7fec45))

### Features

* Allow xhr option to be passed through to connections, so each connection can handle authenticated requests ([82fc6ad](82fc6ad))
* Fail native audio connection if xhr is passed, as native audio does not support that. ([93dea68](93dea68))
* improve firing resolution of audio-position-changed event. refs [#24](#24) ([0777253](0777253))
@jkeen
Copy link
Owner

jkeen commented Mar 18, 2024

🎉 This issue has been resolved in version 5.0.0-beta.20 🎉

The release is available on:

Your semantic-release bot 📦🚀

@jkeen
Copy link
Owner

jkeen commented Mar 18, 2024

🎉 This issue has been resolved in version 5.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants