Merge pull request #473 from Armored-Dragon/ForceHtmlAudioOutputDeviceUpdate-fix

ForceHtmlAudioOutputDeviceUpdate fix
This commit is contained in:
Dale Glass 2023-06-24 12:37:38 -07:00 committed by GitHub
commit ba5c9a2911
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 24 deletions

2
.gitignore vendored
View file

@ -50,6 +50,8 @@ local.properties
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
# Workspace
*.code-workspace
# Xcode
*.xcodeproj

View file

@ -1,8 +1,6 @@
//
// createGlobalEventBridge.js
//
// Created by Anthony J. Thibault on 9/7/2016
// Copyright 2016 High Fidelity, Inc.
// Copyright 2023 Overte e.V.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
@ -25,37 +23,40 @@ var EventBridge;
this.emitWebEvent = function (message) {
self._messages.push(message);
};
};
}
EventBridge = new TempEventBridge();
var webChannel = new QWebChannel(qt.webChannelTransport, function (channel) {
var webChannel = new QWebChannel(qt.webChannelTransport, (channel) => {
//
// replace the TempEventBridge with the real one.
var tempEventBridge = EventBridge;
EventBridge = channel.objects.eventBridge;
// TODO: These event listeners cause issues. Most likely the function is not being exposed to this scope. This may be causing issues!
// To be able to update the state of the output device selection for every element added to the DOM
// we need to listen to events that might precede the addition of this elements.
// A more robust hack will be to add a setInterval that look for DOM changes every 100-300 ms (low performance?)
window.addEventListener("load",function(event) {
setTimeout(function() {
EventBridge.forceHtmlAudioOutputDeviceUpdate();
}, 1200);
}, false);
document.addEventListener("click",function(){
setTimeout(function() {
EventBridge.forceHtmlAudioOutputDeviceUpdate();
}, 1200);
}, false);
document.addEventListener("change",function(){
setTimeout(function() {
EventBridge.forceHtmlAudioOutputDeviceUpdate();
}, 1200);
}, false);
// window.addEventListener("load",function(event) {
// setTimeout(function() {
// EventBridge.forceHtmlAudioOutputDeviceUpdate();
// }, 1200);
// }, false);
// document.addEventListener("click",function(){
// setTimeout(function() {
// EventBridge.forceHtmlAudioOutputDeviceUpdate();
// }, 1200);
// }, false);
// document.addEventListener("change",function(){
// setTimeout(function() {
// EventBridge.forceHtmlAudioOutputDeviceUpdate();
// }, 1200);
// }, false);
tempEventBridge._callbacks.forEach(function (callback) {
EventBridge.scriptEventReceived.connect(callback);
});