Skip to content
Snippets Groups Projects
Commit b766979b authored by Ron Lucke's avatar Ron Lucke
Browse files

BIEST #374

parent 5a07f042
No related branches found
No related tags found
No related merge requests found
...@@ -141,8 +141,8 @@ ...@@ -141,8 +141,8 @@
<label v-show="currentSource === 'studip_folder'"> <label v-show="currentSource === 'studip_folder'">
<translate>Audio Aufnahmen zulassen</translate> <translate>Audio Aufnahmen zulassen</translate>
<select v-model="currentRecorderEnabled"> <select v-model="currentRecorderEnabled">
<option value="true"><translate>Ja</translate></option> <option :value="true"><translate>Ja</translate></option>
<option value="false"><translate>Nein</translate></option> <option :value="false"><translate>Nein</translate></option>
</select> </select>
</label> </label>
</form> </form>
...@@ -231,6 +231,7 @@ export default { ...@@ -231,6 +231,7 @@ export default {
{ type: 0, file_id: id, file_name: attributes.name }, { type: 0, file_id: id, file_name: attributes.name },
true true
), ),
mime_type: attributes['mime-type']
}; };
}); });
}, },
...@@ -259,7 +260,7 @@ export default { ...@@ -259,7 +260,7 @@ export default {
return this.block?.attributes?.payload?.recorder_enabled; return this.block?.attributes?.payload?.recorder_enabled;
}, },
showRecorder() { showRecorder() {
return this.currentRecorderEnabled === 'true'; return this.currentRecorderEnabled;
}, },
hasPlaylist() { hasPlaylist() {
return this.files.length > 0 && this.currentSource === 'studip_folder'; return this.files.length > 0 && this.currentSource === 'studip_folder';
...@@ -324,6 +325,7 @@ export default { ...@@ -324,6 +325,7 @@ export default {
updateBlock: 'updateBlockInContainer', updateBlock: 'updateBlockInContainer',
companionWarning: 'companionWarning', companionWarning: 'companionWarning',
companionSuccess: 'companionSuccess', companionSuccess: 'companionSuccess',
companionError: 'companionError',
createFile: 'createFile', createFile: 'createFile',
}), }),
initCurrentData() { initCurrentData() {
...@@ -383,8 +385,25 @@ export default { ...@@ -383,8 +385,25 @@ export default {
this.durationSeconds = this.$refs.audio.duration; this.durationSeconds = this.$refs.audio.duration;
}, },
playAudio() { playAudio() {
this.$refs.audio.play(); const audio = this.$refs.audio;
this.playing = true; let isSupported = 'unknown';
if (this.currentSource === 'studip_file') {
isSupported = audio.canPlayType(this.currentFile.mime_type);
}
if (this.currentSource === 'studip_folder') {
isSupported = audio.canPlayType(this.files[this.currentPlaylistItem].mime_type);
}
if (isSupported !== '') {
audio.play();
this.playing = true;
} else {
this.companionError({
info: this.$gettext('Ihr Browser unterstützt dieses Audioformat leider nicht.')
});
if(this.hasPlaylist) {
this.nextAudio();
}
}
}, },
pauseAudio() { pauseAudio() {
this.$refs.audio.pause(); this.$refs.audio.pause();
...@@ -474,6 +493,7 @@ export default { ...@@ -474,6 +493,7 @@ export default {
{ type: 0, file_id: fileRef.id, file_name: fileRef.attributes.name }, { type: 0, file_id: fileRef.id, file_name: fileRef.attributes.name },
true true
), ),
mime_type: fileRef.attributes['mime-type']
}); });
} }
}, },
...@@ -481,13 +501,13 @@ export default { ...@@ -481,13 +501,13 @@ export default {
let view = this; let view = this;
navigator.mediaDevices.getUserMedia({audio: true}).then(_stream => { navigator.mediaDevices.getUserMedia({audio: true}).then(_stream => {
let stream = _stream; let stream = _stream;
view.recorder = new MediaRecorder(stream); view.recorder = new MediaRecorder(stream, {mimeType: 'audio/ogg; codecs=opus'});
view.userRecorderEnabled = true; view.userRecorderEnabled = true;
view.recorder.ondataavailable = e => { view.recorder.ondataavailable = e => {
view.chunks.push(e.data); view.chunks.push(e.data);
if(view.recorder.state == 'inactive') { if(view.recorder.state == 'inactive') {
this.blob = new Blob(view.chunks, {type: 'audio/mpeg' }); this.blob = new Blob(view.chunks, {type: 'audio/ogg; codecs=opus' });
} }
}; };
view.recorder.start(); view.recorder.start();
...@@ -527,7 +547,7 @@ export default { ...@@ -527,7 +547,7 @@ export default {
let user = this.usersById({id: this.userId}); let user = this.usersById({id: this.userId});
let file = {}; let file = {};
file.attributes = {}; file.attributes = {};
file.attributes.name = (user.attributes["formatted-name"]).replace(/\s+/g, '_') + '.mp3'; file.attributes.name = (user.attributes["formatted-name"]).replace(/\s+/g, '_') + '.ogg';
let fileObj = false; let fileObj = false;
try { try {
fileObj = await this.createFile({ fileObj = await this.createFile({
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment