ui.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. // const radiomanifest = require('radiomanifest.js')
  2. async function fai () {
  3. const radio = await radiomanifest.get('https://radiomanifest.degenerazione.xyz/v0.2/examples/full-ondarossa')
  4. console.log('radio?', radio)
  5. const s = radio.getStreaming()
  6. console.log(s.sources)
  7. console.log(s.getOptions())
  8. console.log(s.getSource(s.getOptions()[0]))
  9. console.log(s.getSource())
  10. var audioEl = document.querySelector('#player audio')
  11. var urls = await s.pickURLs()
  12. console.log('audios', urls)
  13. urls.forEach( function(url) {
  14. var srcEl = document.createElement("source")
  15. srcEl.setAttribute('src', url)
  16. console.log('src', srcEl, url)
  17. audioEl.appendChild(srcEl)
  18. })
  19. const showList = document.querySelector('#shows > ul')
  20. for (const show of radio.getShows()) {
  21. const item = document.createElement('li')
  22. const link = document.createElement('a')
  23. link.dataset['show'] = show.getName()
  24. link.textContent = show.getName()
  25. link.setAttribute('href', show.getWebsite())
  26. item.appendChild(link)
  27. showList.appendChild(item)
  28. }
  29. showList.addEventListener('mouseenter', function (evt) {
  30. if (evt.target.dataset['show'] === undefined)
  31. return;
  32. const info = document.querySelector('#show-info')
  33. info.textContent = radio.getShowByName(evt.target.dataset['show']).getFeed()
  34. }, true)
  35. }
  36. fai()