diff options
Diffstat (limited to 'src/components/MessagesList/MessagesGroup/Message/MessagePart/AudioPlayer.vue')
-rw-r--r-- | src/components/MessagesList/MessagesGroup/Message/MessagePart/AudioPlayer.vue | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/src/components/MessagesList/MessagesGroup/Message/MessagePart/AudioPlayer.vue b/src/components/MessagesList/MessagesGroup/Message/MessagePart/AudioPlayer.vue new file mode 100644 index 000000000..64540cf1d --- /dev/null +++ b/src/components/MessagesList/MessagesGroup/Message/MessagePart/AudioPlayer.vue @@ -0,0 +1,82 @@ +<!-- + - @copyright Copyright (c) 2021 Marco Ambrosini <marcoambrosini@pm.me> + - + - @author Marco Ambrosini <marcoambrosini@pm.me> + - + - @license GNU AGPL version 3 or any later version + - + - This program is free software: you can redistribute it and/or modify + - it under the terms of the GNU Affero General Public License as + - published by the Free Software Foundation, either version 3 of the + - License, or (at your option) any later version. + - + - This program is distributed in the hope that it will be useful, + - but WITHOUT ANY WARRANTY; without even the implied warranty of + - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + - GNU Affero General Public License for more details. + - + - You should have received a copy of the GNU Affero General Public License + - along with this program. If not, see <http://www.gnu.org/licenses/>. +--> + +<template> + <div class="wrapper"> + <audio + controls + :src="fileURL"> + {{ t('spreed', 'Your browser does not support playing audio files') }} + </audio> + </div> +</template> + +<script> +import { generateRemoteUrl } from '@nextcloud/router' +import { encodePath } from '@nextcloud/paths' + +export default { + name: 'AudioPlayer', + + props: { + /** + * File name + */ + name: { + type: String, + required: true, + }, + link: { + type: String, + required: true, + }, + /** + * File path relative to the user's home storage, + * or link share root, includes the file name. + */ + path: { + type: String, + required: true, + }, + }, + + computed: { + internalAbsolutePath() { + if (this.path.startsWith('/')) { + return this.path + } + return '/' + this.path + }, + + fileURL() { + const userId = this.$store.getters.getUserId() + if (userId === null) { + // guest mode, use public link download URL + return this.link + '/download/' + encodePath(this.name) + } else { + // use direct DAV URL + return generateRemoteUrl(`dav/files/${userId}`) + encodePath(this.internalAbsolutePath) + } + }, + }, + +} +</script> |