title: Weird behavior when playing audio from Data with AVAudioPlayer
body: <p>I'm trying to reproduce an audio that's being sent from my server in a <strong>[UInt8]</strong> buffer. And I've only managed to reproduce it correctly in the following way:</p>
  
  <pre><code>let datax = Data(bytes: data, count: data.count)
  do
  {
  
      let pl:AVAudioPlayer = try AVAudioPlayer(data: datax, fileTypeHint: "m4a")
      pl.volume = 1
      pl.play()
  
      //Here is the weird part, which I randomly added to make it work. Keep reading to understand.
      DispatchQueue.main.asyncAfter(deadline: .now() + 100) {
          if(false){
              pl.play()
          }
      }
  
  } catch {
      print("ERROR")
  }
  </code></pre>
  
  <p><strong>What is weird here?</strong></p>
  
  <p>Pay attention to this part of the code, which it never executes because of the <strong><code>if(false){ pl.play() }</code></strong></p>
  
  <p>If I comment this part of the code, the audio doesn't reproduce. Weird huh?</p>
  
  <pre><code>DispatchQueue.main.asyncAfter(deadline: .now() + 100) {
      if(false){
          pl.play()
      }
  }
  </code></pre>
  
  <p>If I change the <strong><code>DispatchQueue.main.asyncAfter(deadline: .now() + 100)</code></strong> to <strong><code>DispatchQueue.main.asyncAfter(deadline: .now() + 1)</code></strong> (Changing the 100 to 1): The audio only reproduces for 1 second, and it stops playing.</p>
  
  <p>If I comment <strong><code>if(false){ pl.play() }</code></strong>: The audio never reproduces</p>
  
  <p><strong>Weird!</strong></p>
  
  <p>I found this by error, I don't know if it's a bug or what's going on. For now I'm leaving that weird part of code at <strong>100 seconds</strong>, only because I know my audios won't be larger than <strong>100 seconds</strong>.</p>
  
  <p><strong>What could be happening?</strong></p>
  
  <p>This is weird, I don't want to put lame code. Is it a bug of the compiler? Do you recommend another way of doing this? Do you have any idea what could be causing this weird behavior?</p>