mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-09 01:22:21 +02:00
Merge pull request #11424 from ctrlaltdavid/21548
Fix recording just made not playing back if reload it
This commit is contained in:
commit
84786ac8e3
2 changed files with 19 additions and 6 deletions
|
@ -54,9 +54,24 @@ float RecordingScriptingInterface::playerLength() const {
|
|||
return _player->length();
|
||||
}
|
||||
|
||||
void RecordingScriptingInterface::playClip(NetworkClipLoaderPointer clipLoader, const QString& url, QScriptValue callback) {
|
||||
_player->queueClip(clipLoader->getClip());
|
||||
|
||||
if (callback.isFunction()) {
|
||||
QScriptValueList args { true, url };
|
||||
callback.call(_scriptEngine->globalObject(), args);
|
||||
}
|
||||
}
|
||||
|
||||
void RecordingScriptingInterface::loadRecording(const QString& url, QScriptValue callback) {
|
||||
auto clipLoader = DependencyManager::get<recording::ClipCache>()->getClipLoader(url);
|
||||
|
||||
if (clipLoader->isLoaded()) {
|
||||
qCDebug(scriptengine) << "Recording already loaded from" << url;
|
||||
playClip(clipLoader, url, callback);
|
||||
return;
|
||||
}
|
||||
|
||||
// hold a strong pointer to the loading clip so that it has a chance to load
|
||||
_clipLoaders.insert(clipLoader);
|
||||
|
||||
|
@ -69,12 +84,7 @@ void RecordingScriptingInterface::loadRecording(const QString& url, QScriptValue
|
|||
if (auto clipLoader = weakClipLoader.toStrongRef()) {
|
||||
qCDebug(scriptengine) << "Loaded recording from" << url;
|
||||
|
||||
_player->queueClip(clipLoader->getClip());
|
||||
|
||||
if (callback.isFunction()) {
|
||||
QScriptValueList args { true, url };
|
||||
callback.call(_scriptEngine->globalObject(), args);
|
||||
}
|
||||
playClip(clipLoader, url, callback);
|
||||
|
||||
// drop our strong pointer to this clip so it is cleaned up
|
||||
_clipLoaders.remove(clipLoader);
|
||||
|
|
|
@ -88,6 +88,9 @@ protected:
|
|||
|
||||
QSharedPointer<BaseScriptEngine> _scriptEngine;
|
||||
QSet<recording::NetworkClipLoaderPointer> _clipLoaders;
|
||||
|
||||
private:
|
||||
void playClip(recording::NetworkClipLoaderPointer clipLoader, const QString& url, QScriptValue callback);
|
||||
};
|
||||
|
||||
#endif // hifi_RecordingScriptingInterface_h
|
||||
|
|
Loading…
Reference in a new issue