RadioLive.vue 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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(decodeURIComponent(this.f7route.params.radioUrl));
  33. const currentShow = this.Radio.getShowAtTime();
  34. this.currentShowName =
  35. currentShow == null ? "live" : currentShow.getName();
  36. this.loading = false;
  37. } catch (e) {
  38. console.error("error fetching", 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>