Showing the changes to libraries/script-engine/src/RecordingScriptingInterface.cpp (1 of 2 files). Show all
Unified · Split
| @@ -44,19 +44,25 @@ float RecordingScriptingInterface::playerLength() const { · 43 unmodified lines | |||
| 44 | return _player->length(); | 44 | return _player->length(); |
| 45 | } | 45 | } |
| 46 | 46 | ||
| 47 | void RecordingScriptingInterface::loadRecording(const QString& url) { | 47 | bool RecordingScriptingInterface::loadRecording(const QString& url) { |
| 48 | using namespace recording; | 48 | using namespace recording; |
| 49 | 49 | ||
| 50 | if (QThread::currentThread() != thread()) { | 50 | auto loader = ClipCache::instance().getClipLoader(url); |
| 51 | QMetaObject::invokeMethod(this, "loadRecording", Qt::BlockingQueuedConnection, | 51 | QEventLoop loop; |
| 52 | Q_ARG(QString, url)); | 52 | QObject::connect(loader.data(), &Resource::loaded, &loop, &QEventLoop::quit); |
| 53 | return; | 53 | QObject::connect(loader.data(), &Resource::failed, &loop, &QEventLoop::quit); |
| 54 | loop.exec(); | ||
| 55 | |||
| 56 | if (!loader->isLoaded()) { | ||
| 57 | qWarning() << "Clip failed to load from " << url; | ||
| 58 | return false; | ||
| 54 | } | 59 | } |
| 55 | 60 | ||
| 56 | // FIXME make blocking and force off main thread? | 61 | _player->queueClip(loader->getClip()); |
| 57 | _player->queueClip(ClipCache::instance().getClipLoader(url)->getClip()); | 62 | return true; |
| 58 | } | 63 | } |
| 59 | 64 | ||
| 65 | |||
| 60 | void RecordingScriptingInterface::startPlaying() { | 66 | void RecordingScriptingInterface::startPlaying() { |
| 61 | if (QThread::currentThread() != thread()) { | 67 | if (QThread::currentThread() != thread()) { |
| 62 | QMetaObject::invokeMethod(this, "startPlaying", Qt::BlockingQueuedConnection); | 68 | QMetaObject::invokeMethod(this, "startPlaying", Qt::BlockingQueuedConnection); |