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