BackgroundMusicComponent.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #pragma once
  9. #include <AzCore/Component/Component.h>
  10. #include <IAudioSystem.h>
  11. namespace MultiplayerSample
  12. {
  13. class BackgroundMusicComponent
  14. : public AZ::Component
  15. , protected Audio::AudioTriggerNotificationBus::Handler
  16. {
  17. public:
  18. AZ_COMPONENT(MultiplayerSample::BackgroundMusicComponent, "{FA774915-3CDD-4370-B7C9-8F891A006973}");
  19. static void Reflect(AZ::ReflectContext* context);
  20. static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& services);
  21. static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
  22. static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& services);
  23. void Activate() override;
  24. void Deactivate() override;
  25. protected:
  26. void ReportTriggerFinished(Audio::TAudioControlID triggerId) override;
  27. private:
  28. size_t m_trackIndex = 0;
  29. bool m_shuffle = false;
  30. AZStd::vector<AZStd::string> m_playlist;
  31. Audio::IAudioSystem* m_audioSystem = nullptr;
  32. Audio::TATLIDType m_currentTrackTriggerId = INVALID_AUDIO_CONTROL_ID;
  33. };
  34. }