RadioLive.vue 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <template>
  2. <f7-page name="RadioLive">
  3. <img :src='Radio.logo' id='logo'/>
  4. <f7-block-title>{{Radio.name}}</f7-block-title>
  5. <f7-block-header>{{Radio.description}}</f7-block-header>
  6. <div v-if='loading' strong class="text-align-center">
  7. <f7-preloader />
  8. </div>
  9. <f7-block v-else>
  10. {{currentShowName}}
  11. <f7-button type="button" @click="playLive">Ascolta la diretta</f7-button>
  12. </f7-block>
  13. </f7-page>
  14. </template>
  15. <script>
  16. import radiomanifest from '../js/radiomanifest'
  17. import eventBus from '../js/eventBus'
  18. export default {
  19. name: 'radio',
  20. data () {
  21. return {
  22. loading: true,
  23. radioId: null,
  24. radio: { name: '' },
  25. currentShowName: '',
  26. Radio: { }
  27. }
  28. },
  29. props: { f7route: Object, f7router: Object },
  30. async mounted () {
  31. this.radioId = this.f7route.params.radioName
  32. try {
  33. this.Radio = await radiomanifest.get(this.f7route.params.radioName)
  34. const currentShow = this.Radio.getShowAtTime();
  35. this.currentShowName = currentShow == null ? "live" : currentShow.getName();
  36. this.loading = false
  37. } catch (e) {
  38. console.error('le cose non vanno mai sempre bene!', e)
  39. }
  40. },
  41. methods: {
  42. async playLive() {
  43. const urls = await this.Radio.getStreaming().pickURLs();
  44. eventBus.$emit('play:now', urls, {
  45. live: true,
  46. title: this.Radio.getName() + " - live"
  47. })
  48. }
  49. }
  50. }
  51. </script>
  52. <style>
  53. #logo {
  54. margin-left: 10px;
  55. max-width: 40px;
  56. }
  57. </style>