mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 05:57:29 +02:00
Implemented snap sound using sound injector
This commit is contained in:
parent
889b054085
commit
023d03d9f8
3 changed files with 27 additions and 7 deletions
Binary file not shown.
|
@ -594,7 +594,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
||||||
_aboutToQuit(false),
|
_aboutToQuit(false),
|
||||||
_notifiedPacketVersionMismatchThisDomain(false),
|
_notifiedPacketVersionMismatchThisDomain(false),
|
||||||
_maxOctreePPS(maxOctreePacketsPerSecond.get()),
|
_maxOctreePPS(maxOctreePacketsPerSecond.get()),
|
||||||
_lastFaceTrackerUpdate(0)
|
_lastFaceTrackerUpdate(0),
|
||||||
|
_snapshotSound(nullptr)
|
||||||
{
|
{
|
||||||
auto steamClient = PluginManager::getInstance()->getSteamClientPlugin();
|
auto steamClient = PluginManager::getInstance()->getSteamClientPlugin();
|
||||||
setProperty(hifi::properties::STEAM, (steamClient && steamClient->isRunning()));
|
setProperty(hifi::properties::STEAM, (steamClient && steamClient->isRunning()));
|
||||||
|
@ -1453,6 +1454,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
||||||
return entityServerNode && !isPhysicsEnabled();
|
return entityServerNode && !isPhysicsEnabled();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
QFileInfo inf = QFileInfo(PathUtils::resourcesPath() + "sounds/snap.wav");
|
||||||
|
_snapshotSound = DependencyManager::get<SoundCache>()->getSound(QUrl::fromLocalFile(inf.absoluteFilePath()));
|
||||||
|
|
||||||
QVariant testProperty = property(hifi::properties::TEST);
|
QVariant testProperty = property(hifi::properties::TEST);
|
||||||
qDebug() << testProperty;
|
qDebug() << testProperty;
|
||||||
if (testProperty.isValid()) {
|
if (testProperty.isValid()) {
|
||||||
|
@ -1785,6 +1789,8 @@ void Application::cleanupBeforeQuit() {
|
||||||
DependencyManager::destroy<AudioClient>();
|
DependencyManager::destroy<AudioClient>();
|
||||||
DependencyManager::destroy<AudioInjectorManager>();
|
DependencyManager::destroy<AudioInjectorManager>();
|
||||||
|
|
||||||
|
// delete _snapshotSound;
|
||||||
|
// _snapshotSound = nullptr;
|
||||||
qCDebug(interfaceapp) << "Application::cleanupBeforeQuit() complete";
|
qCDebug(interfaceapp) << "Application::cleanupBeforeQuit() complete";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6405,15 +6411,24 @@ void Application::loadAddAvatarBookmarkDialog() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::takeSnapshot(bool notify, bool includeAnimated, float aspectRatio) {
|
void Application::takeSnapshot(bool notify, bool includeAnimated, float aspectRatio) {
|
||||||
postLambdaEvent([notify, includeAnimated, aspectRatio, this] {
|
|
||||||
QMediaPlayer* player = new QMediaPlayer();
|
|
||||||
QFileInfo inf = QFileInfo(PathUtils::resourcesPath() + "sounds/snap.wav");
|
|
||||||
player->setMedia(QUrl::fromLocalFile(inf.absoluteFilePath()));
|
|
||||||
player->play();
|
|
||||||
|
|
||||||
|
//keep sound thread out of event loop scope
|
||||||
|
|
||||||
|
AudioInjectorOptions options;
|
||||||
|
options.localOnly = true;
|
||||||
|
options.stereo = true;
|
||||||
|
|
||||||
|
if (_snapshotSoundInjector) {
|
||||||
|
_snapshotSoundInjector->setOptions(options);
|
||||||
|
_snapshotSoundInjector->restart();
|
||||||
|
} else {
|
||||||
|
QByteArray samples = _snapshotSound->getByteArray();
|
||||||
|
_snapshotSoundInjector = AudioInjector::playSound(samples, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
postLambdaEvent([notify, includeAnimated, aspectRatio, this] {
|
||||||
// Get a screenshot and save it
|
// Get a screenshot and save it
|
||||||
QString path = Snapshot::saveSnapshot(getActiveDisplayPlugin()->getScreenshot(aspectRatio));
|
QString path = Snapshot::saveSnapshot(getActiveDisplayPlugin()->getScreenshot(aspectRatio));
|
||||||
|
|
||||||
// If we're not doing an animated snapshot as well...
|
// If we're not doing an animated snapshot as well...
|
||||||
if (!includeAnimated || !(SnapshotAnimated::alsoTakeAnimatedSnapshot.get())) {
|
if (!includeAnimated || !(SnapshotAnimated::alsoTakeAnimatedSnapshot.get())) {
|
||||||
// Tell the dependency manager that the capture of the still snapshot has taken place.
|
// Tell the dependency manager that the capture of the still snapshot has taken place.
|
||||||
|
@ -6424,6 +6439,7 @@ void Application::takeSnapshot(bool notify, bool includeAnimated, float aspectRa
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::shareSnapshot(const QString& path, const QUrl& href) {
|
void Application::shareSnapshot(const QString& path, const QUrl& href) {
|
||||||
postLambdaEvent([path, href] {
|
postLambdaEvent([path, href] {
|
||||||
// not much to do here, everything is done in snapshot code...
|
// not much to do here, everything is done in snapshot code...
|
||||||
|
|
|
@ -73,6 +73,7 @@
|
||||||
#include <model/Skybox.h>
|
#include <model/Skybox.h>
|
||||||
#include <ModelScriptingInterface.h>
|
#include <ModelScriptingInterface.h>
|
||||||
|
|
||||||
|
#include "Sound.h"
|
||||||
|
|
||||||
class OffscreenGLCanvas;
|
class OffscreenGLCanvas;
|
||||||
class GLCanvas;
|
class GLCanvas;
|
||||||
|
@ -80,6 +81,7 @@ class FaceTracker;
|
||||||
class MainWindow;
|
class MainWindow;
|
||||||
class AssetUpload;
|
class AssetUpload;
|
||||||
class CompositorHelper;
|
class CompositorHelper;
|
||||||
|
class AudioInjector;
|
||||||
|
|
||||||
namespace controller {
|
namespace controller {
|
||||||
class StateController;
|
class StateController;
|
||||||
|
@ -682,6 +684,8 @@ private:
|
||||||
QTimer _addAssetToWorldErrorTimer;
|
QTimer _addAssetToWorldErrorTimer;
|
||||||
|
|
||||||
FileScriptingInterface* _fileDownload;
|
FileScriptingInterface* _fileDownload;
|
||||||
|
AudioInjector* _snapshotSoundInjector{ nullptr };
|
||||||
|
SharedSoundPointer _snapshotSound;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue