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