mirror of
https://github.com/overte-org/overte.git
synced 2025-04-08 08:14:48 +02:00
Fixes on web and QML audio sync
This commit is contained in:
parent
8eb8cb0994
commit
b817143e2e
2 changed files with 14 additions and 10 deletions
|
@ -65,21 +65,26 @@ var EventBridge;
|
|||
// 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.onload = function(){
|
||||
window.addEventListener("load",function(event) {
|
||||
setTimeout(function() {
|
||||
EventBridge.forceHtmlAudioOutputDeviceUpdate();
|
||||
console.log(":: Window Loaded");
|
||||
}, 1200);
|
||||
};
|
||||
document.onclick = function(){
|
||||
}, false);
|
||||
|
||||
document.addEventListener("click",function(){
|
||||
setTimeout(function() {
|
||||
EventBridge.forceHtmlAudioOutputDeviceUpdate();
|
||||
console.log(":: Window Clicked");
|
||||
}, 1200);
|
||||
};
|
||||
document.onchange = function(){
|
||||
}, false);
|
||||
|
||||
document.addEventListener("change",function(){
|
||||
setTimeout(function() {
|
||||
EventBridge.forceHtmlAudioOutputDeviceUpdate();
|
||||
console.log(":: Window Changes");
|
||||
}, 1200);
|
||||
};
|
||||
}, false);
|
||||
|
||||
tempEventBridge._callbacks.forEach(function (callback) {
|
||||
EventBridge.scriptEventReceived.connect(callback);
|
||||
|
|
|
@ -139,7 +139,6 @@ public:
|
|||
QThread::msleep(_runDelayMs);
|
||||
}
|
||||
auto audioIO = DependencyManager::get<AudioClient>();
|
||||
QString deviceName = audioIO->getActiveAudioDevice(QAudio::AudioOutput).deviceName();
|
||||
for (auto player : _container->findChildren<QMediaPlayer*>()) {
|
||||
auto mediaState = player->state();
|
||||
QMediaService *svc = player->service();
|
||||
|
@ -156,7 +155,7 @@ public:
|
|||
for (int i = 0; i < outputs.size(); i++) {
|
||||
QString output = outputs[i];
|
||||
QString description = out->outputDescription(output);
|
||||
if (description == deviceName) {
|
||||
if (description == _newTargetDevice) {
|
||||
deviceOuput = output;
|
||||
break;
|
||||
}
|
||||
|
@ -171,7 +170,7 @@ public:
|
|||
player->stop();
|
||||
}
|
||||
}
|
||||
qDebug() << "QML Audio changed to " << deviceName;
|
||||
qDebug() << "QML Audio changed to " << _newTargetDevice;
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -700,7 +699,7 @@ void OffscreenQmlSurface::forceQmlAudioOutputDeviceUpdate() {
|
|||
} else {
|
||||
auto audioIO = DependencyManager::get<AudioClient>();
|
||||
QString deviceName = audioIO->getActiveAudioDevice(QAudio::AudioOutput).deviceName();
|
||||
int waitForAudioQmlMs = 500;
|
||||
int waitForAudioQmlMs = 200;
|
||||
// The audio device need to be change using oth
|
||||
new AudioHandler(_rootItem, deviceName, waitForAudioQmlMs);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue