eshaz / icecast-metadata-js

Browser and NodeJS packages for playing and reading Icecast compatible streaming audio with realtime metadata updates.
155 stars 20 forks source link

ogg/flac stream does not work in the icecast-metadata-player #172

Closed solariz9 closed 1 year ago

solariz9 commented 1 year ago

In Liquidsoap: out_icecast(music, '/flac', 'password', %ogg(%flac(channels=2, compression=0, bits_per_sample=24, samplerate=48000))) (The flac encoding format comes in two flavors: %flac is the native flac format, useful for file output but not for streaming purpose %ogg(%flac,...) is the ogg/flac format, which can be used to broadcast data with icecast) URL working in Chrome browser, but in demo html:

<html>
  <head>
  </head>
   <script src="/js/icecast-metadata-player-1.16.0.main.min.js"></script>
   <script>

const player = new IcecastMetadataPlayer("https://endorphin-radio.online/radiohi/", {
  onMetadata: (metadata) => {console.log(metadata)},
  metadataTypes: ["icy", "ogg"]
})

   </script>
   <body>
     <button onclick="player.play();"> Play </button>
     <button onclick="player.stop();"> Stop </button>
     <p> Now Playing: <span id="metadata"></span> </p>
   </body>
</html>

I get an error:

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'then')
    at st.Ci (MediaSourcePlayer.js:166:8)
    at st.fi (MediaSourcePlayer.js:100:28)
    at new st (MediaSourcePlayer.js:25:10)
    at et.le (PlayerFactory.js:349:18)
    at et.readIcecastResponse (PlayerFactory.js:191:51)
eshaz commented 1 year ago

Thanks for letting me know. I found a small typo that caused this in the latest release, and will be publishing a patch release to fix it.