From 51f5942a7f832e685208fb05e93fd567c6a72845 Mon Sep 17 00:00:00 2001 From: Wayne Chen Date: Wed, 21 Nov 2018 13:36:36 -0800 Subject: [PATCH] adding sound to login screen --- .../resources}/sounds/crystals_and_voices.mp3 | Bin interface/src/Application.cpp | 30 ++++++++++++++++-- interface/src/Application.h | 2 ++ scripts/system/interstitialPage.js | 2 +- 4 files changed, 30 insertions(+), 4 deletions(-) rename {scripts/system/assets => interface/resources}/sounds/crystals_and_voices.mp3 (100%) diff --git a/scripts/system/assets/sounds/crystals_and_voices.mp3 b/interface/resources/sounds/crystals_and_voices.mp3 similarity index 100% rename from scripts/system/assets/sounds/crystals_and_voices.mp3 rename to interface/resources/sounds/crystals_and_voices.mp3 diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index ae7d4c3cca..cb34ea8eee 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1033,8 +1033,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo _maxOctreePPS(maxOctreePacketsPerSecond.get()), _lastFaceTrackerUpdate(0), _snapshotSound(nullptr), - _sampleSound(nullptr) - + _sampleSound(nullptr), + _loginStateSound(nullptr) { auto steamClient = PluginManager::getInstance()->getSteamClientPlugin(); @@ -2286,6 +2286,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo }); _snapshotSound = DependencyManager::get()->getSound(PathUtils::resourcesUrl("sounds/snapshot/snap.wav")); + _loginStateSound = DependencyManager::get()->getSound(PathUtils::resourcesUrl("sounds/crystals_and_voices.mp3")); // Monitor model assets (e.g., from Clara.io) added to the world that may need resizing. static const int ADD_ASSET_TO_WORLD_TIMER_INTERVAL_MS = 1000; @@ -2634,6 +2635,10 @@ void Application::cleanupBeforeQuit() { _snapshotSoundInjector->stop(); } + if (_loginStateSoundInjector != nullptr) { + _loginStateSoundInjector->stop(); + } + // destroy Audio so it and its threads have a chance to go down safely // this must happen after QML, as there are unexplained audio crashes originating in qtwebengine DependencyManager::destroy(); @@ -2945,6 +2950,12 @@ static void addDisplayPluginToMenu(const DisplayPluginPointer& displayPlugin, in void Application::showLoginScreen() { auto accountManager = DependencyManager::get(); auto dialogsManager = DependencyManager::get(); + if (!_loginStateSound->isReady()) { + connect(_loginStateSound.data(), &Sound::ready, this, &Application::showLoginScreen); + return; + } else { + disconnect(_loginStateSound.data(), &Sound::ready, this, &Application::showLoginScreen); + } if (!accountManager->isLoggedIn()) { if (!isHMDMode()) { auto toolbar = DependencyManager::get()->getToolbar("com.highfidelity.interface.toolbar.system"); @@ -2956,6 +2967,15 @@ void Application::showLoginScreen() { loginData["action"] = "login dialog shown"; UserActivityLogger::getInstance().logAction("encourageLoginDialog", loginData); _window->setWindowTitle("High Fidelity Interface"); + if (!_loginStateSoundInjector) { + AudioInjectorOptions options; + options.localOnly = true; + options.position = getMyAvatar()->getHeadPosition(); + options.loop = true; + options.volume = 0.4f; + options.stereo = true; + _loginStateSoundInjector = AudioInjector::playSound(_loginStateSound, options); + } } else { resumeAfterLoginDialogActionTaken(); } @@ -5298,6 +5318,7 @@ void Application::pauseUntilLoginDetermined() { // disconnect domain handler. nodeList->getDomainHandler().disconnect(); + } void Application::resumeAfterLoginDialogActionTaken() { @@ -8670,7 +8691,7 @@ void Application::updateLoginDialogOverlayPosition() { auto newOverlayPositionVec = (cameraPositionVec + offset) + (upVec * -0.1f); auto newOverlayOrientation = glm::inverse(glm::quat_cast(glm::lookAt(newOverlayPositionVec, cameraPositionVec, upVec))) * Quaternions::Y_180; - if (pointAngle > 30.0f) { + if (pointAngle > 40.0f) { QVariantMap properties { {"position", vec3toVariant(newOverlayPositionVec)}, {"orientation", quatToVariant(newOverlayOrientation)} @@ -8695,6 +8716,9 @@ void Application::onDismissedLoginDialog() { _loginDialogOverlayID = OverlayID(); _loginStateManager.tearDown(); } + if (_loginStateSoundInjector != nullptr) { + _loginStateSoundInjector->stop(); + } resumeAfterLoginDialogActionTaken(); } diff --git a/interface/src/Application.h b/interface/src/Application.h index 573919cd26..1e9f30dfc1 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -794,6 +794,8 @@ private: AudioInjectorPointer _snapshotSoundInjector; SharedSoundPointer _snapshotSound; SharedSoundPointer _sampleSound; + AudioInjectorPointer _loginStateSoundInjector; + SharedSoundPointer _loginStateSound; DisplayPluginPointer _autoSwitchDisplayModeSupportedHMDPlugin; QString _autoSwitchDisplayModeSupportedHMDPluginName; diff --git a/scripts/system/interstitialPage.js b/scripts/system/interstitialPage.js index e4dc778985..8dd94623b7 100644 --- a/scripts/system/interstitialPage.js +++ b/scripts/system/interstitialPage.js @@ -21,7 +21,7 @@ var TEXTURE_EPSILON = 0.01; var isVisible = false; var VOLUME = 0.4; - var tune = SoundCache.getSound(Script.resolvePath("/~/system/assets/sounds/crystals_and_voices.mp3")); + var tune = SoundCache.getSound(Script.resourcesPath() + "sounds/crystals_and_voices.mp3"); var sample = null; var MAX_LEFT_MARGIN = 1.9; var INNER_CIRCLE_WIDTH = 4.7;