Jasonette / JASONETTE-iOS

📡 Native App over HTTP, on iOS
https://www.jasonette.com
MIT License
5.27k stars 352 forks source link

$audio.play *toggle* not working properly (reproducible test case included) #329

Closed darenr closed 6 years ago

darenr commented 6 years ago

The example in the docs (below) is sufficient to demonstrate the problem, when the button is clicked rather than toggle the audio playback as the docs says, the audio starts repeatedly.


{
  "$jason": {
    "head": {
      "title": "Play audio"
    }, 
    "body": {
      "sections": [{
        "items": [{
          "type": "label",
          "text": "Yo",
          "action": {
            "type": "$audio.play",
            "options": {
              "title": "Busdriver - Worlds to Run",
              "author": "Song Exploder",
              "image": "http://discover.pocketcasts.com/discover/images/400/fff9ba50-53e1-0131-8293-723c91aeae46.jpg",
              "url": "http://www.podtrac.com/pts/redirect.mp3/traffic.libsyn.com/songexploder/SongExploder73-Busdriver.mp3"
            }
          }
        }]
      }]
    }
  }
}```
darenr commented 6 years ago

Attempts to work around the problem didn't work either. I tried first calling pause

          "action": {
                "type": "$audio.stop",
                "success": {
                  "type": "$audio.play",
                  "options": {
                       ...

and then stop

          "action": {
                "type": "$audio.stop",
                "success": {
                  "type": "$audio.play",
                  "options": {
                       ...

But neither have any effect, when the button is tapped the audio starts a different copy playing, all overlapping. I also tried specifying the specific url of the audio in the pause/stop section with no effect.

darenr commented 6 years ago

@gliechtenstein - Do you think you'll have a chance to take a loot at this bug soon please?

gliechtenstein commented 6 years ago

should be fixed now with https://github.com/Jasonette/JASONETTE-iOS/commit/b4009acf408778ef0092ea707c38614678f1c14a

darenr commented 6 years ago

thank you. will pull and try now.