Player.vue 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <template>
  2. <div class="bg-gray-800 rounded-sm">
  3. <div class="flex items-center space-x-3.5 sm:space-x-5 lg:space-x-3.5 xl:space-x-5">
  4. <Button class='text-red-400' ref='button' @play='play' @stop='stop' />
  5. <div class="min-w-0 flex-auto space-y-0.5">
  6. <!-- //- <p class="text-white text-sm sm:text-base lg:text-sm xl:text-base font-semibold uppercase">
  7. //- <abbr title="Episode">Ep.</abbr> 128
  8. //- </p> -->
  9. <h2 class="text-white text-base sm:text-xl lg:text-base xl:text-xl font-semibold truncate" v-text='title'>
  10. </h2>
  11. <!-- //- <p class="text-gray-400 text-base sm:text-lg lg:text-base xl:text-lg font-medium">
  12. //- Full Stack Radio
  13. //- </p> -->
  14. </div>
  15. </div>
  16. </div>
  17. </template>
  18. <script>
  19. import { Howl } from 'howler'
  20. import Button from './Button.vue'
  21. export default {
  22. components: { Button },
  23. data () {
  24. return {
  25. loading: true,
  26. status: 'pause',
  27. volume: 100,
  28. title: 'RadioBlackout > DIRETTA',
  29. subtitle: '',
  30. live: true,
  31. player: null
  32. }
  33. },
  34. // destroyed () {
  35. // this.$nuxt.$off('play:podcast', this.stop)
  36. // },
  37. // mounted () {
  38. // this.$nuxt.$on('play:podcast', this.stop)
  39. // },
  40. methods: {
  41. play () {
  42. const rnd = Math.random()
  43. this.player = new Howl({
  44. autoSuspend: false,
  45. html5: true,
  46. preload: true,
  47. src: ['https://stream.radioblackout.org/blackout.ogg?rnd=' + rnd,
  48. 'https://stream.radioblackout.org/blackout.mp3'],
  49. })
  50. this.player.play()
  51. this.$nuxt.$emit('play:player')
  52. },
  53. stop () {
  54. if (this.player) {
  55. this.player.stop()
  56. }
  57. this.$refs.button.stop()
  58. },
  59. }
  60. }
  61. </script>