mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 16:36:54 +02:00
Merge pull request #6451 from jherico/rec5
Force synchronous loading of clips in JS
This commit is contained in:
commit
879c42c269
2 changed files with 14 additions and 8 deletions
|
@ -44,19 +44,25 @@ float RecordingScriptingInterface::playerLength() const {
|
||||||
return _player->length();
|
return _player->length();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RecordingScriptingInterface::loadRecording(const QString& url) {
|
bool RecordingScriptingInterface::loadRecording(const QString& url) {
|
||||||
using namespace recording;
|
using namespace recording;
|
||||||
|
|
||||||
if (QThread::currentThread() != thread()) {
|
auto loader = ClipCache::instance().getClipLoader(url);
|
||||||
QMetaObject::invokeMethod(this, "loadRecording", Qt::BlockingQueuedConnection,
|
QEventLoop loop;
|
||||||
Q_ARG(QString, url));
|
QObject::connect(loader.data(), &Resource::loaded, &loop, &QEventLoop::quit);
|
||||||
return;
|
QObject::connect(loader.data(), &Resource::failed, &loop, &QEventLoop::quit);
|
||||||
|
loop.exec();
|
||||||
|
|
||||||
|
if (!loader->isLoaded()) {
|
||||||
|
qWarning() << "Clip failed to load from " << url;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME make blocking and force off main thread?
|
_player->queueClip(loader->getClip());
|
||||||
_player->queueClip(ClipCache::instance().getClipLoader(url)->getClip());
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void RecordingScriptingInterface::startPlaying() {
|
void RecordingScriptingInterface::startPlaying() {
|
||||||
if (QThread::currentThread() != thread()) {
|
if (QThread::currentThread() != thread()) {
|
||||||
QMetaObject::invokeMethod(this, "startPlaying", Qt::BlockingQueuedConnection);
|
QMetaObject::invokeMethod(this, "startPlaying", Qt::BlockingQueuedConnection);
|
||||||
|
|
|
@ -25,7 +25,7 @@ public:
|
||||||
RecordingScriptingInterface();
|
RecordingScriptingInterface();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void loadRecording(const QString& url);
|
bool loadRecording(const QString& url);
|
||||||
|
|
||||||
void startPlaying();
|
void startPlaying();
|
||||||
void pausePlayer();
|
void pausePlayer();
|
||||||
|
|
Loading…
Reference in a new issue