ShitEngine
基于 C++20 与 SDL3 的轻量级 2D 游戏引擎
载入中...
搜索中...
未找到
AudioTrack.h
浏览该文件的文档.
1#pragma once
2#include "../Core/Core.h"
3
4struct MIX_Track;
5
6namespace Shit {
7
9
10// SHIT_API:AudioPlayer 在引擎外被按值持有(EngineContext),
11// 析构/移动需要跨 DLL 导出符号
13public:
14 AudioTrack(const AudioTrack&) = delete;
15 AudioTrack& operator=(const AudioTrack&) = delete;
17 AudioTrack& operator=(AudioTrack&&) noexcept;
19
20 void pause();
21 void resume();
22 void stop();
23 void setVolume(float gain);
24 float getVolume() const;
25 void setLooping(int loopCount); // -1 = 无限, 0 = 不循环, N = N 次
26 int getLooping() const { return m_loops; }
27
28 bool isPlaying() const;
29 bool isPaused() const;
30 bool isFinished() const;
31
32private:
33 friend class AudioPlayer;
34 friend class AudioTrackGroup;
35 AudioTrack() = default;
36 explicit AudioTrack(MIX_Track* handle);
37
38 MIX_Track* m_handle = nullptr;
39 float m_gain = 1.0f;
40 int m_loops = 0;
41 AudioTrackGroup* m_group = nullptr;
42 bool m_started = false;
43 bool m_paused = false;
44};
45
46} // namespace Shit
#define SHIT_API
定义 Core.h:14
定义 AudioPlayer.h:12
void setLooping(int loopCount)
friend class AudioTrackGroup
定义 AudioTrack.h:34
bool isPlaying() const
bool isFinished() const
bool isPaused() const
friend class AudioPlayer
定义 AudioTrack.h:33
AudioTrack(AudioTrack &&) noexcept
void setVolume(float gain)
float getVolume() const
AudioTrack(const AudioTrack &)=delete
int getLooping() const
定义 AudioTrack.h:26
AudioTrack & operator=(const AudioTrack &)=delete
定义 AudioPlayer.h:10