1
0

RadioLive.vue 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. export default {
  21. name: "radio",
  22. data() {
  23. return {
  24. loading: true,
  25. currentShowName: "",
  26. Radio: {},
  27. };
  28. },
  29. props: { f7route: Object, f7router: Object },
  30. async mounted() {
  31. try {
  32. this.Radio = await radiomanifest.get(
  33. decodeURIComponent(this.f7route.params.radioUrl),
  34. );
  35. const currentShow = this.Radio.getShowAtTime();
  36. this.currentShowName =
  37. currentShow == null ? "live" : currentShow.getName();
  38. this.loading = false;
  39. } catch (e) {
  40. console.error("error fetching", e);
  41. }
  42. },
  43. methods: {
  44. async playLive() {
  45. const urls = await this.Radio.getStreaming().pickURLs();
  46. eventBus.$emit("play:now", urls, {
  47. live: true,
  48. title: this.Radio.getName() + " - live",
  49. });
  50. },
  51. },
  52. };
  53. </script>
  54. <style>
  55. #logo {
  56. margin-left: 10px;
  57. max-width: 40px;
  58. }
  59. </style>