RadioLive.vue 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 class="block" large outline @click="playLive"
  12. >Ascolta la diretta</f7-button
  13. >
  14. </f7-block>
  15. </f7-page>
  16. </template>
  17. <script>
  18. import radiomanifest from "../js/radiomanifest";
  19. import eventBus from "../js/eventBus";
  20. import { useRadioStore } from "../js/store";
  21. import { storeToRefs } from "pinia";
  22. export default {
  23. name: "radio",
  24. data() {
  25. return {
  26. radioUrl: null,
  27. isRadioReady: null,
  28. store: useRadioStore(),
  29. radio: () => {
  30. return this.store.radios[this.radioUrl];
  31. },
  32. loading: () => {
  33. return this.isRadioReady === null || !this.isRadioReady(this.radioUrl);
  34. },
  35. currentShowName: () => {
  36. if (this.loading()) {
  37. return "";
  38. }
  39. const radio = this.store.radios[this.radioUrl];
  40. const currentShow = radio.getShowAtTime();
  41. return currentShow == null ? "live" : currentShow.getName();
  42. },
  43. };
  44. },
  45. props: { f7route: Object, f7router: Object },
  46. async mounted() {
  47. this.radioUrl = decodeURIComponent(this.f7route.params.radioUrl);
  48. const { isRadioReady } = storeToRefs(this.store);
  49. this.isRadioReady = isRadioReady;
  50. },
  51. methods: {
  52. async playLive() {
  53. const urls = await this.radio().getStreaming().pickURLs();
  54. eventBus.$emit("play:now", urls, {
  55. live: true,
  56. title: this.radio().getName() + " - live",
  57. });
  58. },
  59. },
  60. };
  61. </script>
  62. <style>
  63. #logo {
  64. margin-left: 10px;
  65. max-width: 40px;
  66. }
  67. </style>