ScummVM API documentation
plaympp_api.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 
23 #ifndef QDENGINE_QDCORE_UTIL_PLAYMPP_API_H
24 #define QDENGINE_QDCORE_UTIL_PLAYMPP_API_H
25 
26 #include "audio/mixer.h"
27 
28 namespace Common {
29 class SeekableReadStream;
30 }
31 
32 namespace QDEngine {
33 
34 class MpegSound;
35 
36 class mpegPlayer {
37 public:
40  MPEG_STOPPED,
41  MPEG_PAUSED,
42  MPEG_PLAYING
43  };
44 
45  ~mpegPlayer();
46 
47  bool play(const Common::Path file, bool loop = false, int vol = 256);
48  bool stop();
49  bool pause();
50  bool resume();
51 
52  bool is_enabled() const {
53  return _is_enabled;
54  }
56  void enable(bool need_resume = true) {
57  _is_enabled = true;
58  if (need_resume) resume();
59  }
61  void disable() {
62  _is_enabled = false;
63  pause();
64  }
65 
66  mpeg_status_t status() const;
67  bool is_playing() const {
68  return (status() == MPEG_PLAYING);
69  }
70 
71  uint32 volume() const {
72  return _volume;
73  }
74  void set_volume(uint32 vol);
75 
76  void syncMusicSettings();
77 
78  static bool init_library(void *dsound_device);
79  static void deinit_library();
80 
81  static mpegPlayer &instance();
82 
83 private:
84 
85  mpegPlayer();
86 
88  bool _is_enabled;
89  bool _paused;
90 
92  uint32 _volume;
93  uint32 _cur_track_volume;
94 
95  Audio::SoundHandle _soundHandle;
96 
97  Common::SeekableReadStream *_stream = nullptr;
98 
99  Common::Path _file;
100 };
101 
102 } // namespace QDEngine
103 
104 #endif // QDENGINE_QDCORE_UTIL_PLAYMPP_API_H
Definition: plaympp_api.h:36
void enable(bool need_resume=true)
Разрешает проигрывание музыки.
Definition: plaympp_api.h:56
Definition: path.h:52
mpeg_status_t
Состояние.
Definition: plaympp_api.h:39
Definition: stream.h:745
Definition: mixer.h:49
Базовый класс для игровых ресурсов.
Definition: console.h:28
Definition: algorithm.h:29
void disable()
Запрещает проигрывание музыки.
Definition: plaympp_api.h:61