Skip to content

Commit

Permalink
fix(mixins): migrate devices mixin
Browse files Browse the repository at this point in the history
Signed-off-by: Maksim Sukharev <antreesy.web@gmail.com>
  • Loading branch information
Antreesy committed Jan 7, 2024
1 parent 0ab5f04 commit 56a7a22
Show file tree
Hide file tree
Showing 5 changed files with 457 additions and 390 deletions.
38 changes: 35 additions & 3 deletions src/components/MediaDevicesPreview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
:audio-preview-available="audioPreviewAvailable"
:audio-enabled="true"
:current-volume="currentVolume"
:volume-threshold="volumeThreshold"
:volume-threshold="currentThreshold"
:size="64" />
</div>
<MediaDevicesSelector kind="videoinput"
Expand Down Expand Up @@ -80,14 +80,16 @@
</template>

<script>
import { ref } from 'vue'
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 { devices } from '../mixins/devices.js'
import { useDevices } from '../composables/useDevices.js'
export default {
Expand All @@ -101,7 +103,37 @@ export default {
VolumeIndicator,
},
mixins: [devices],
setup() {
const video = ref(null)
const {
devices,
currentVolume,
currentThreshold,
audioPreviewAvailable,
videoPreviewAvailable,
audioInputId,
videoInputId,
audioStream,
audioStreamError,
videoStream,
videoStreamError,
} = useDevices(video, true)
return {
video,
devices,
currentVolume,
currentThreshold,
audioPreviewAvailable,
videoPreviewAvailable,
audioInputId,
videoInputId,
audioStream,
audioStreamError,
videoStream,
videoStreamError,
}
},
computed: {
audioStreamErrorMessage() {
Expand Down
39 changes: 33 additions & 6 deletions src/components/MediaSettings/MediaSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
<VolumeIndicator :audio-preview-available="audioPreviewAvailable"
:audio-enabled="audioOn"
:current-volume="currentVolume"
:volume-threshold="volumeThreshold"
:volume-threshold="currentThreshold"
overlay-muted-color="#888888" />
</template>
</NcButton>
Expand Down Expand Up @@ -201,6 +201,8 @@
</template>

<script>
import { ref } from 'vue'
import Bell from 'vue-material-design-icons/Bell.vue'
import BellOff from 'vue-material-design-icons/BellOff.vue'
import Cog from 'vue-material-design-icons/Cog.vue'
Expand All @@ -226,9 +228,9 @@ import MediaDevicesSelector from '../MediaDevicesSelector.vue'
import CallButton from '../TopBar/CallButton.vue'
import VolumeIndicator from '../VolumeIndicator/VolumeIndicator.vue'
import { useDevices } from '../../composables/useDevices.js'
import { useIsInCall } from '../../composables/useIsInCall.js'
import { AVATAR, CALL, PARTICIPANT, VIRTUAL_BACKGROUND } from '../../constants.js'
import { devices } from '../../mixins/devices.js'
import BrowserStorage from '../../services/BrowserStorage.js'
import { useGuestNameStore } from '../../stores/guestName.js'
import { useSettingsStore } from '../../stores/settings.js'
Expand Down Expand Up @@ -265,8 +267,6 @@ export default {
VideoBackgroundEditor,
},
mixins: [devices],
props: {
recordingConsentGiven: {
type: Boolean,
Expand All @@ -277,14 +277,41 @@ export default {
emits: ['update:recording-consent-given'],
setup() {
const video = ref(null)
const isInCall = useIsInCall()
const guestNameStore = useGuestNameStore()
const settingsStore = useSettingsStore()
const {
devices,
currentVolume,
currentThreshold,
audioPreviewAvailable,
videoPreviewAvailable,
audioInputId,
videoInputId,
initializeDevices,
stopDevices,
virtualBackground,
} = useDevices(video, false)
return {
AVATAR,
isInCall,
guestNameStore,
settingsStore,
video,
// useDevices
devices,
currentVolume,
currentThreshold,
audioPreviewAvailable,
videoPreviewAvailable,
audioInputId,
videoInputId,
initializeDevices,
stopDevices,
virtualBackground,
}
},
Expand Down Expand Up @@ -427,9 +454,9 @@ export default {
}
}
this.initializeDevicesMixin()
this.initializeDevices()
} else {
this.stopDevicesMixin()
this.stopDevices()
}
},
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 @@ -28,7 +28,7 @@
<NcAppSettingsSection id="devices"
:name="t('spreed', 'Choose devices')"
class="app-settings-section">
<MediaDevicesPreview initialize-on-mounted />
<MediaDevicesPreview />
</NcAppSettingsSection>
<NcAppSettingsSection v-if="!isGuest"
id="attachments"
Expand Down
Loading

0 comments on commit 56a7a22

Please sign in to comment.