mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 08:04:01 +02:00
Force synchronous loading of clips in JS
This commit is contained in:
parent
00c8ccb6b0
commit
cc2a7cbda8
2 changed files with 14 additions and 8 deletions
|
@ -44,19 +44,25 @@ float RecordingScriptingInterface::playerLength() const {
|
|||
return _player->length();
|
||||
}
|
||||
|
||||
void RecordingScriptingInterface::loadRecording(const QString& url) {
|
||||
bool RecordingScriptingInterface::loadRecording(const QString& url) {
|
||||
using namespace recording;
|
||||
|
||||
if (QThread::currentThread() != thread()) {
|
||||
QMetaObject::invokeMethod(this, "loadRecording", Qt::BlockingQueuedConnection,
|
||||
Q_ARG(QString, url));
|
||||
return;
|
||||
auto loader = ClipCache::instance().getClipLoader(url);
|
||||
QEventLoop loop;
|
||||
QObject::connect(loader.data(), &Resource::loaded, &loop, &QEventLoop::quit);
|
||||
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(ClipCache::instance().getClipLoader(url)->getClip());
|
||||
_player->queueClip(loader->getClip());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void RecordingScriptingInterface::startPlaying() {
|
||||
if (QThread::currentThread() != thread()) {
|
||||
QMetaObject::invokeMethod(this, "startPlaying", Qt::BlockingQueuedConnection);
|
||||
|
|
|
@ -25,7 +25,7 @@ public:
|
|||
RecordingScriptingInterface();
|
||||
|
||||
public slots:
|
||||
void loadRecording(const QString& url);
|
||||
bool loadRecording(const QString& url);
|
||||
|
||||
void startPlaying();
|
||||
void pausePlayer();
|
||||
|
|
Loading…
Reference in a new issue