title: Using external library with React to play .ogg files in Safari
body: <p>Good evening. 
  I'm trying to implement playing ogg-opus audio in react app in Safari (it doesn't support .ogg format). I use create-react-app to init the project.</p>
  
  <p>I've found "ogv.js" library, that is actually helps to play audio files in almost all modern browsers. But can't actually get it work (<a href="https://github.com/brion/ogv.js/issues/525" rel="nofollow noreferrer">https://github.com/brion/ogv.js/issues/525</a>). </p>
  
  <p>I'm requring in the top of my <code>PlayerComponent.js</code> file after all the imports</p>
  
  <pre><code>var ogv = require('ogv');
  </code></pre>
  
  <p>After that in my <code>play()</code> function (it's being called from <code>onClick</code> event of a button) I'm trying to play an ogg file, that I'm recieving from API: </p>
  
  <pre><code>play = () =&gt; {
     var player = new OGVPlayer();
     var blob = new Blob([new Uint8Array(this.props.audioData)]);
     player.src = URL.createObjectURL(blob);
     player.play();
  }
  </code></pre>
  
  <p>I'm getting the below error:</p>
  
  <blockquote>
    <p>ogv-demuxer-ogg-wasm.js?version=1.6.0-20190226222001-c4648f0:1
    Uncaught SyntaxError: Unexpected token ogv.js:1586 Uncaught TypeError:
    n[e] is not a function at classWrapper (ogv.js:1586) at ogv.js:4593 at
    ogv.js:1590 at ogv.js:207 at Array.forEach () at
    HTMLScriptElement.done (ogv.js:206)</p>
  </blockquote>
  
  <p>Probably the problem is that some library files and especially 'ogv-demuxer-ogg-wasm.js' can't be loaded properly.</p>
  
  <p>Any help would be helpful, maybe someone has a solution to play .ogg files in Safari in other way. Thanks!</p>
  
  <p><strong>[UPDATED]</strong>
  Solution found, check it down below.</p>