Add sound player

This commit is contained in:
Knut Ahlers 2020-11-23 11:08:57 +01:00
parent fd7327d634
commit 87ba88fc53
Signed by: luzifer
GPG key ID: 0066F03ED215AD7D

View file

@ -27,6 +27,10 @@ const app = new Vue({
created() { created() {
window.setInterval(() => { this.time = new Date() }, 1000) window.setInterval(() => { this.time = new Date() }, 1000)
this.startSocket() this.startSocket()
this.sound = new Audio()
this.sound.addEventListener('load', () => this.sound.play(), true)
this.sound.autoplay = true
}, },
data: { data: {
@ -34,6 +38,7 @@ const app = new Vue({
avail: false, avail: false,
backoff: 100, backoff: 100,
}, },
sound: null,
store: {}, store: {},
socket: null, socket: null,
time: new Date(), time: new Date(),
@ -43,6 +48,10 @@ const app = new Vue({
el: '#app', el: '#app',
methods: { methods: {
playSound(soundUrl) {
this.sound.src = soundUrl
},
showAlert(title, text) { showAlert(title, text) {
this.$bvToast.toast(text, { this.$bvToast.toast(text, {
title, title,
@ -96,6 +105,7 @@ const app = new Vue({
return return
} }
this.showAlert('New Follower', `${to} just followed`) this.showAlert('New Follower', `${to} just followed`)
this.playSound('/public/doorbell.webm')
}, },
version(to, from) { version(to, from) {