title: embed src with binary audio data
body: <p>I need to dynamically embed returned audio data so I can play requested mpegs.</p>
  
  <p><code>&lt;embed src=</code> is looking for a file path, but I don't have files locally.</p>
  
  <p>I make a successful request which returns audio/mpeg binary data:</p>
  
  <p><img src="https://i.stack.imgur.com/Xp8wv.png" alt="enter image description here"></p>
  
  <pre><code>    $.get('testPHP.php?translate_tts?ie=utf-8&amp;tl=zh-CN&amp;q=你好',
          function (returned_data) {
              document.getElementById("audio").innerHTML=
                  "&lt;embed src=\""+returned_data+"\" hidden=\"true\" autostart=\"true\" loop=\"false\" /&gt;";
          }
      );
  </code></pre>
  
  <p>How can I create the audio element with that data?</p>
  
  <p><strong>PHP</strong>:</p>
  
  <pre><code>&lt;?php
  header('Content-type: text/plain; charset=utf-8');
  $params = http_build_query(array("ie" =&gt; $_GET['ie'],"tl" =&gt; $_GET["tl"], "q" =&gt; $_GET["q"]));
  $ctx = stream_context_create(array("http"=&gt;array("method"=&gt;"GET","header"=&gt;"Referer: \r\n"))); //create and return stream context
  $soundfile = file_get_contents("https://translate.google.com/translate_tts?".$params, false, $ctx); //reads file into string (string with params[utf-8, tl, q], use include path bool, custom context resource headers)
  
  header("Content-type: audio/mpeg");
  header("Content-Transfer-Encoding: binary");
  header('Pragma: no-cache');
  header('Expires: 0');
  
  echo base64_encode($binary_data);
  </code></pre>
  
  <hr>
  
  <p><strong>Edit</strong>: I'm able to play audio if I pull directly from my server:</p>
  
  <pre><code>    var returned_data = '/recordings/subjects/Wo_I.mp3';
      document.getElementById("audio").innerHTML=
          "&lt;embed src=\""+returned_data+"\" hidden=\"true\" autostart=\"true\" loop=\"false\" /&gt;";
  </code></pre>
  
  <blockquote>
    <p>Resource interpreted as Document but transferred with MIME type audio/mpeg: "<a href="http://melon.localhost/recordings/subjects/Wo_I.mp3" rel="nofollow noreferrer">http://melon.localhost/recordings/subjects/Wo_I.mp3</a>".</p>
  </blockquote>
  
  <p>If I try encoding in base64 in PHP above...</p>
  
  <p><code>'&lt;embed src="data:audio/mpeg;base64,'+returned_data+'" hidden="true" autostart="true" loop="false"/&gt;'</code></p>
  
  <p>It's transferred with MIME to audio/mpeg, but no music plays.</p>
  
  <blockquote>
    <p>Resource interpreted as Document but transferred with MIME type audio/mpeg: "data:audio/mpeg;base64,".</p>
  </blockquote>