Skip to content

Commit

Permalink
Merge pull request #11624 from nextcloud/feat/1181/add-audio-test
Browse files Browse the repository at this point in the history
Feat(MediaSettings): Add audio test
  • Loading branch information
Antreesy authored Mar 5, 2024
2 parents 9efd7e0 + c699ada commit aba2df7
Show file tree
Hide file tree
Showing 6 changed files with 145 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!--
- @copyright Copyright (c) 2020, Daniel Calviño Sánchez (danxuliu@gmail.com)
- @copyright Copyright (c) 2020 Daniel Calviño Sánchez (danxuliu@gmail.com)
-
- @license GNU AGPL version 3 or any later version
- @license AGPL-3.0-or-later
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as
Expand Down
131 changes: 131 additions & 0 deletions src/components/MediaSettings/MediaDevicesSpeakerTest.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
<!--
- @copyright Copyright (c) 2024 Maksim Sukharev <antreesy.web@gmail.com>
-
- @author Maksim Sukharev <antreesy.web@gmail.com>
-
- @license AGPL-3.0-or-later
-
- 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="media-devices-checker">
<div class="media-devices-checker__icon">
<VolumeHighIcon :size="16" />
</div>
<NcButton type="secondary" @click="playTestSound">
{{ buttonLabel }}
</NcButton>
<div v-if="isPlayingTestSound" class="equalizer">
<div v-for="bar in equalizerBars"
:key="bar.key"
class="equalizer__bar"
:style="bar.style" />
</div>
</div>
</template>

<script>
import VolumeHighIcon from 'vue-material-design-icons/VolumeHigh.vue'
import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
export default {
name: 'MediaDevicesSpeakerTest',
components: {
NcButton,
VolumeHighIcon,
},
data() {
return {
isPlayingTestSound: false,
}
},
computed: {
buttonLabel() {
return this.isPlayingTestSound
// TRANSLATORS Playing the test sound to check speakers
? t('spreed', 'Playing …')
: t('spreed', 'Test speakers')
},
equalizerBars() {
return Array.from(Array(4).keys()).map(item => ({
key: item,
style: {
height: Math.random() * 100 + '%',
animationDelay: Math.random() * -2 + 's',
},
}))
}
},
methods: {
playTestSound() {
if (this.isPlayingTestSound) {
this.$store.dispatch('pauseWaitAudio')
return
}
this.isPlayingTestSound = true
this.$store.dispatch('playWaitAudio').then((response) => {
response.addEventListener('ended', () => {
this.isPlayingTestSound = false
})
})
},
},
}
</script>

<style lang="scss" scoped>
.media-devices-checker {
display: flex;
margin: 16px 0;
&__icon {
display: flex;
justify-content: flex-start;
align-items: center;
width: 36px;
}
.equalizer {
margin-left: 8px;
height: var(--default-clickable-area);
display: flex;
align-items: center;
&__bar {
width: 8px;
height: 100%;
background: var(--color-primary-element);
border-radius: 4px;
margin: 0 2px;
will-change: height;
animation: equalizer 2s steps(15, end) infinite;
}
}
}
@keyframes equalizer {
@for $i from 0 through 15 {
#{4*$i}% { height: random(70) + 20%; }
}
}
</style>
5 changes: 4 additions & 1 deletion src/components/MediaSettings/MediaSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
:devices="devices"
:device-id="videoInputId"
@update:deviceId="videoInputId = $event" />
<MediaDevicesSpeakerTest />
</div>

<!-- Background selection -->
Expand Down Expand Up @@ -221,10 +222,11 @@ import NcModal from '@nextcloud/vue/dist/Components/NcModal.js'
import NcNoteCard from '@nextcloud/vue/dist/Components/NcNoteCard.js'
import Tooltip from '@nextcloud/vue/dist/Directives/Tooltip.js'
import MediaDevicesSelector from './MediaDevicesSelector.vue'
import MediaDevicesSpeakerTest from './MediaDevicesSpeakerTest.vue'
import VideoBackgroundEditor from './VideoBackgroundEditor.vue'
import AvatarWrapper from '../AvatarWrapper/AvatarWrapper.vue'
import VideoBackground from '../CallView/shared/VideoBackground.vue'
import MediaDevicesSelector from '../MediaDevicesSelector.vue'
import CallButton from '../TopBar/CallButton.vue'
import VolumeIndicator from '../VolumeIndicator/VolumeIndicator.vue'
Expand Down Expand Up @@ -260,6 +262,7 @@ export default {
NcModal,
NcNoteCard,
MediaDevicesSelector,
MediaDevicesSpeakerTest,
VideoBackground,
VideoIcon,
VideoOff,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!--
- @copyright Copyright (c) 2020, Daniel Calviño Sánchez (danxuliu@gmail.com)
- @copyright Copyright (c) 2020 Daniel Calviño Sánchez (danxuliu@gmail.com)
-
- @license GNU AGPL version 3 or any later version
- @license AGPL-3.0-or-later
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as
Expand Down Expand Up @@ -86,10 +86,10 @@ import AlertCircle from 'vue-material-design-icons/AlertCircle.vue'
import MicrophoneOff from 'vue-material-design-icons/MicrophoneOff.vue'
import VideoOff from 'vue-material-design-icons/VideoOff.vue'
import MediaDevicesSelector from './MediaDevicesSelector.vue'
import VolumeIndicator from './VolumeIndicator/VolumeIndicator.vue'
import MediaDevicesSelector from '../MediaSettings/MediaDevicesSelector.vue'
import VolumeIndicator from '../VolumeIndicator/VolumeIndicator.vue'
import { useDevices } from '../composables/useDevices.js'
import { useDevices } from '../../composables/useDevices.js'
export default {
Expand Down
2 changes: 1 addition & 1 deletion src/components/SettingsDialog/SettingsDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ import NcAppSettingsSection from '@nextcloud/vue/dist/Components/NcAppSettingsSe
import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
import NcCheckboxRadioSwitch from '@nextcloud/vue/dist/Components/NcCheckboxRadioSwitch.js'
import MediaDevicesPreview from '../MediaDevicesPreview.vue'
import MediaDevicesPreview from './MediaDevicesPreview.vue'
import { PRIVACY } from '../../constants.js'
import BrowserStorage from '../../services/BrowserStorage.js'
Expand Down
2 changes: 2 additions & 0 deletions src/store/soundsStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@ const actions = {
audio.load()
audio.volume = 0.5
audio.play()

return audio
},

/**
Expand Down

0 comments on commit aba2df7

Please sign in to comment.