diff --git a/app/components/windows/settings/VirtualWebcamSettings.tsx b/app/components/windows/settings/VirtualWebcamSettings.tsx index 326b9555ac21..7b0751ebee4f 100644 --- a/app/components/windows/settings/VirtualWebcamSettings.tsx +++ b/app/components/windows/settings/VirtualWebcamSettings.tsx @@ -10,6 +10,8 @@ import { getOS, OS } from 'util/operating-systems'; import { Services } from 'components-react/service-provider'; import { Multiselect } from 'vue-multiselect'; import { VCamOutputType } from 'obs-studio-node'; +import { ObjectChangeSet } from 'realm'; +import { DefaultObject } from 'realm/dist/public-types/schema'; @Component({ components: { @@ -34,23 +36,26 @@ export default class VirtualCamSettings extends Vue { scenesService = Services.ScenesService; sourcesService = Services.SourcesService; + isVCamRunning: boolean = false; + created() { this.checkInstalled(); - // TODO: reimplement with settings in RealmDB - /* - const outputType: VCamOutputType = this.settingsService.findSettingValue(this.settingsService.views.virtualWebcamSettings, 'OutputType', 'OutputType'); - const outputTypeIndex = this.outputTypeOptions.findIndex(val => val.id === outputType); + const outputTypeIndex = this.outputTypeOptions.findIndex(val => val.id === this.virtualWebcamService.outputType); if (outputTypeIndex !== -1) { this.outputTypeValue = this.outputTypeOptions[outputTypeIndex]; } else { this.outputTypeValue = this.outputTypeOptions[0]; - this.settingsService.setSettingValue('Virtual Webcam', 'OutputType', VCamOutputType.ProgramView); } this.onOutputTypeChange(this.outputTypeValue); - */ + + // TODO: after migrating this component to React, the listener should be removed and useRealmObject used instead + const listener = (_o: DefaultObject, changes: ObjectChangeSet) => { + this.isVCamRunning = this.virtualWebcamService.isRunning; + }; + this.virtualWebcamService.ephemeralState.realmModel.addListener(listener); } install() { @@ -79,7 +84,7 @@ export default class VirtualCamSettings extends Vue { } get running() { - return this.virtualWebcamService.state.running; + return this.isVCamRunning; } needsInstallSection(isUpdate: boolean) { @@ -114,8 +119,8 @@ export default class VirtualCamSettings extends Vue { } isInstalledSection() { - const buttonText = this.running ? $t('Stop Virtual Webcam') : $t('Start Virtual Webcam'); - const statusText = this.running + const buttonText = this.isVCamRunning ? $t('Stop Virtual Webcam') : $t('Start Virtual Webcam'); + const statusText = this.isVCamRunning ? $t('Virtual webcam is Running') : $t('Virtual webcam is Offline'); @@ -128,7 +133,7 @@ export default class VirtualCamSettings extends Vue { scopedSlots={{ status: (text: string) => { return ( - + {text} ); @@ -137,9 +142,9 @@ export default class VirtualCamSettings extends Vue { />

@@ -167,7 +172,7 @@ export default class VirtualCamSettings extends Vue {