title: How to play audio tracks continuously from a web app on IOS when phone locked?
body: <p>Visit Soundcloud and play any song using an iPhone (I have an iPhone 5s which I'm using it to test my web app.). If you lock the phone and the song finishes, the next track will start playing. This is something I'm trying to implement for my app.</p>
  
  <p>based on the research I have done, apple doesn't allow HTML5 audios to start programmatically. It needs some sort of user interaction but the question is, how does Soundcloud do it?</p>
  
  <p>My app at the moment uses the "onended()" HTML5 method to check if the current track is finished playing and then starts the next one. This works on android and desktop but not on ios. </p>
  
  <p>here is the part of the code that plays the next track for my app:</p>
  
  <pre><code>this.audio.onended = () =&gt; {
       this.index++;
       this.audio.currentTime = 0;
       axios.patch('/api/track/'+this.track.id,{album_id: this.track.album_id});
  
     if(this.index &lt;= (this.tracks.length - 1)){
        this.track = this.tracks[this.index];
        this.audio.src = this.tracks[this.index].url;
        this.audio.play();
        Event.$emit('setCurrentPlayingTrack', this.tracks[this.index]);
        this.$store.commit('setPlayingTrack', this.tracks[this.index]);
     }else{
       console.log('playlist ended');
     }
  
  }
  </code></pre>
  
  <p>btw I'm using VueJs to build my app.</p>