audio.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /* audio.h - audio player
  2. * Copyright (C) 2017 caryoscelus
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #ifndef STUDIO_MAIN_AUDIO_H_0BD8ABBD_AB43_58DF_BCCA_172630D4F535
  18. #define STUDIO_MAIN_AUDIO_H_0BD8ABBD_AB43_58DF_BCCA_172630D4F535
  19. #include <core/std/string.h>
  20. #include <generic/context_listener.h>
  21. class QMediaPlayer;
  22. namespace rainynite::studio {
  23. class AudioPlayer : public ContextListener {
  24. public:
  25. AudioPlayer();
  26. virtual ~AudioPlayer();
  27. void set_context(shared_ptr<EditorContext> context) override;
  28. void update(core::Time time);
  29. private:
  30. void update_audio();
  31. private:
  32. string cached_file;
  33. boost::signals2::connection node_connection;
  34. shared_ptr<core::AbstractNode> audio_node;
  35. unique_ptr<QMediaPlayer> player;
  36. bool is_playing;
  37. };
  38. } // namespace rainynite::studio
  39. #endif