|
@@ -19,6 +19,8 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+import eventBus from '../js/eventBus'
|
|
|
+
|
|
|
import { Howl } from 'howler'
|
|
|
import Button from './Button.vue'
|
|
|
|
|
@@ -35,24 +37,35 @@ export default {
|
|
|
player: null
|
|
|
}
|
|
|
},
|
|
|
- // destroyed () {
|
|
|
- // this.$nuxt.$off('play:podcast', this.stop)
|
|
|
- // },
|
|
|
- // mounted () {
|
|
|
- // this.$nuxt.$on('play:podcast', this.stop)
|
|
|
- // },
|
|
|
+ destroyed () {
|
|
|
+ eventBus.$off('play:now')
|
|
|
+ },
|
|
|
+ mounted () {
|
|
|
+ const t = this
|
|
|
+ eventBus.$on('play:now', function (url) {
|
|
|
+ t.play(url)
|
|
|
+ })
|
|
|
+ },
|
|
|
methods: {
|
|
|
- play () {
|
|
|
- const rnd = Math.random()
|
|
|
+ play (url) {
|
|
|
+ var urls;
|
|
|
+ if (url === undefined) {
|
|
|
+ const rnd = Math.random()
|
|
|
+ urls = [
|
|
|
+ 'https://stream.radioblackout.org/blackout.ogg?rnd=' + rnd,
|
|
|
+ 'https://stream.radioblackout.org/blackout.mp3'
|
|
|
+ ]
|
|
|
+ } else {
|
|
|
+ urls = [url]
|
|
|
+ }
|
|
|
this.player = new Howl({
|
|
|
autoSuspend: false,
|
|
|
html5: true,
|
|
|
preload: true,
|
|
|
- src: ['https://stream.radioblackout.org/blackout.ogg?rnd=' + rnd,
|
|
|
- 'https://stream.radioblackout.org/blackout.mp3'],
|
|
|
- })
|
|
|
+ src: urls,
|
|
|
+ })
|
|
|
+ console.log(this.player)
|
|
|
this.player.play()
|
|
|
- this.$nuxt.$emit('play:player')
|
|
|
},
|
|
|
stop () {
|
|
|
if (this.player) {
|