0 ? this.item.filename : noSound;
+ return this.file ? this.item.filename : noSound;
},
loopClasses() {
let classes = ['csc-additional'];
@@ -89,6 +102,9 @@
return this.loop ?
this.$t('pbxConfig.dontPlayInLoop') :
this.$t('pbxConfig.playInLoop');
+ },
+ soundFileFormat() {
+ return this.platform.mozilla ? 'ogg' : 'mp3';
}
},
methods: {
@@ -96,7 +112,18 @@
return !!this.item.loopplay;
},
hasFile() {
- return this.item.filename.length > 0;
+ return this.item.filename ? this.item.filename.length > 0 : false;
+ },
+ playSoundFile() {
+ this.$store.dispatch('pbxConfig/playSoundFile', {
+ id: this.item.id,
+ format: this.soundFileFormat
+ });
+ },
+ initSoundFileAudio() {
+ this.playSoundFile();
+ this.$refs.uploadSoundFile.setPlayingTrue();
+ this.$refs.uploadSoundFile.setPausedFalse();
}
},
watch: {
diff --git a/src/store/pbx-config/actions.js b/src/store/pbx-config/actions.js
index b58228e3..c4cb9cdc 100644
--- a/src/store/pbx-config/actions.js
+++ b/src/store/pbx-config/actions.js
@@ -44,7 +44,8 @@ import {
setSoundSetName,
setSoundSetDescription,
setSoundSetContractDefault,
- getSoundSetWithFiles
+ getSoundSetWithFiles,
+ playSoundFile
} from '../../api/pbx-config'
export default {
@@ -648,5 +649,16 @@ export default {
reject(err);
});
});
+ },
+ playSoundFile(context, options) {
+ context.commit('playSoundFileRequesting');
+ playSoundFile(options).then((url) => {
+ context.commit('playSoundFileSucceeded', {
+ id: options.id,
+ url: url
+ });
+ }).catch((err) => {
+ context.commit('playSoundFileFailed', err.message);
+ });
}
}
diff --git a/src/store/pbx-config/getters.js b/src/store/pbx-config/getters.js
index 97e7b0a2..ffe69d72 100644
--- a/src/store/pbx-config/getters.js
+++ b/src/store/pbx-config/getters.js
@@ -335,5 +335,20 @@ export default {
},
isSoundSetsRequesting(state) {
return state.listSoundSetsState === RequestState.requesting;
+ },
+ playSoundFileUrl(state) {
+ return (id) => {
+ return state.soundFileUrls[id];
+ }
+ },
+ playSoundFileLoaded(state) {
+ return (id) => {
+ return state.soundFileUrls[id] ? true : false;
+ }
+ },
+ isLastPlayed(state) {
+ return (id) => {
+ return state.lastPlayed + '' === id + '';
+ }
}
}
diff --git a/src/store/pbx-config/mutations.js b/src/store/pbx-config/mutations.js
index ee7e3f10..2ec27d15 100644
--- a/src/store/pbx-config/mutations.js
+++ b/src/store/pbx-config/mutations.js
@@ -525,5 +525,19 @@ export default {
soundSetReloadingFailed(state, err) {
state.soundSetReloadingState = RequestState.failed;
state.soundSetReloadingError = err;
+ },
+ playSoundFileRequesting(state) {
+ state.playSoundFileState = RequestState.requesting;
+ state.playSoundFileError = null;
+ },
+ playSoundFileSucceeded(state, options) {
+ Vue.set(state.soundFileUrls, options.id, options.url);
+ state.lastPlayed = options.id;
+ state.playSoundFileState = RequestState.succeeded;
+ state.playSoundFileError = null;
+ },
+ playSoundFileFailed(state, err) {
+ state.playSoundFileState = RequestState.failed;
+ state.playSoundFileError = err;
}
}
diff --git a/src/store/pbx-config/state.js b/src/store/pbx-config/state.js
index b0715582..2e7456b6 100644
--- a/src/store/pbx-config/state.js
+++ b/src/store/pbx-config/state.js
@@ -87,5 +87,9 @@ export default {
soundSetFilesErrors: {},
soundSetReloading: null,
soundSetReloadingState: RequestState.initiated,
- soundSetReloadingError: null
+ soundSetReloadingError: null,
+ playSoundFileState: RequestState.initiated,
+ playSoundFileError: null,
+ soundFileUrls: {},
+ lastPlayed: null
}
diff --git a/src/store/voicebox.js b/src/store/voicebox.js
index 923986cd..802bc95d 100644
--- a/src/store/voicebox.js
+++ b/src/store/voicebox.js
@@ -537,7 +537,7 @@ export default {
}).then((url) => {
context.commit('playBusyGreetingSucceeded', url);
}).catch((err) => {
- context.commit('playBusyGreetingFailed', err.mesage);
+ context.commit('playBusyGreetingFailed', err.message);
});
},
playUnavailGreeting(context, format) {
@@ -548,7 +548,7 @@ export default {
}).then((url) => {
context.commit('playUnavailGreetingSucceeded', url);
}).catch((err) => {
- context.commit('playUnavailGreetingFailed', err.mesage);
+ context.commit('playUnavailGreetingFailed', err.message);
});
},
abortUploadBusyGreeting(context) {