Showing the changes to libraries/script-engine/src/RecordingScriptingInterface.cpp (1 of 2 files). Show all
Unified · Split
| @@ -54,9 +54,24 @@ float RecordingScriptingInterface::playerLength() const { · 53 unmodified lines | |||
| 54 | return _player->length(); | 54 | return _player->length(); |
| 55 | } | 55 | } |
| 56 | 56 | ||
| 57 | void RecordingScriptingInterface::playClip(NetworkClipLoaderPointer clipLoader, const QString& url, QScriptValue callback) { | ||
| 58 | _player->queueClip(clipLoader->getClip()); | ||
| 59 | |||
| 60 | if (callback.isFunction()) { | ||
| 61 | QScriptValueList args{ true, url }; | ||
| 62 | callback.call(_scriptEngine->globalObject(), args); | ||
| 63 | } | ||
| 64 | } | ||
| 65 | |||
| 57 | void RecordingScriptingInterface::loadRecording(const QString& url, QScriptValue callback) { | 66 | void RecordingScriptingInterface::loadRecording(const QString& url, QScriptValue callback) { |
| 58 | auto clipLoader = DependencyManager::get<recording::ClipCache>()->getClipLoader(url); | 67 | auto clipLoader = DependencyManager::get<recording::ClipCache>()->getClipLoader(url); |
| 59 | 68 | ||
| 69 | if (clipLoader->isLoaded()) { | ||
| 70 | qCDebug(scriptengine) << "Recording already loaded from" << url; | ||
| 71 | playClip(clipLoader, url, callback); | ||
| 72 | return; | ||
| 73 | } | ||
| 74 | |||
| 60 | // hold a strong pointer to the loading clip so that it has a chance to load | 75 | // hold a strong pointer to the loading clip so that it has a chance to load |
| 61 | _clipLoaders.insert(clipLoader); | 76 | _clipLoaders.insert(clipLoader); |
| 62 | 77 | ||
| @@ -69,12 +84,7 @@ void RecordingScriptingInterface::loadRecording(const QString& url, QScriptValue · 6 unmodified lines | |||
| 69 | if (auto clipLoader = weakClipLoader.toStrongRef()) { | 84 | if (auto clipLoader = weakClipLoader.toStrongRef()) { |
| 70 | qCDebug(scriptengine) << "Loaded recording from" << url; | 85 | qCDebug(scriptengine) << "Loaded recording from" << url; |
| 71 | 86 | ||
| 72 | _player->queueClip(clipLoader->getClip()); | 87 | playClip(clipLoader, url, callback); |
| 73 | |||
| 74 | if (callback.isFunction()) { | ||
| 75 | QScriptValueList args { true, url }; | ||
| 76 | callback.call(_scriptEngine->globalObject(), args); | ||
| 77 | } | ||
| 78 | 88 | ||
| 79 | // drop our strong pointer to this clip so it is cleaned up | 89 | // drop our strong pointer to this clip so it is cleaned up |
| 80 | _clipLoaders.remove(clipLoader); | 90 | _clipLoaders.remove(clipLoader); |