diff --git a/libraries/script-engine/src/RecordingScriptingInterface.cpp b/libraries/script-engine/src/RecordingScriptingInterface.cpp index 21bb7fca3f..cbcf94662e 100644 --- a/libraries/script-engine/src/RecordingScriptingInterface.cpp +++ b/libraries/script-engine/src/RecordingScriptingInterface.cpp @@ -64,6 +64,11 @@ void RecordingScriptingInterface::playClip(NetworkClipLoaderPointer clipLoader, } void RecordingScriptingInterface::loadRecording(const QString& url, QScriptValue callback) { + if (QThread::currentThread() != thread()) { + BLOCKING_INVOKE_METHOD(this, "loadRecording", Q_ARG(const QString&, url), Q_ARG(QScriptValue, callback)); + return; + } + auto clipLoader = DependencyManager::get()->getClipLoader(url); if (clipLoader->isLoaded()) { @@ -117,6 +122,11 @@ void RecordingScriptingInterface::startPlaying() { } void RecordingScriptingInterface::setPlayerVolume(float volume) { + if (QThread::currentThread() != thread()) { + BLOCKING_INVOKE_METHOD(this, "setPlayerVolume", Q_ARG(float, volume)); + return; + } + _player->setVolume(std::min(std::max(volume, 0.0f), 1.0f)); } @@ -137,6 +147,11 @@ void RecordingScriptingInterface::setPlayFromCurrentLocation(bool playFromCurren } void RecordingScriptingInterface::setPlayerLoop(bool loop) { + if (QThread::currentThread() != thread()) { + BLOCKING_INVOKE_METHOD(this, "setPlayerLoop", Q_ARG(bool, loop)); + return; + } + _player->loop(loop); } @@ -200,6 +215,11 @@ void RecordingScriptingInterface::stopRecording() { return; } + if (QThread::currentThread() != thread()) { + BLOCKING_INVOKE_METHOD(this, "stopRecording"); + return; + } + _recorder->stop(); _lastClip = _recorder->getClip(); _lastClip->seek(0);