change: make Music extends Ref.
This commit is contained in:
parent
a924eed280
commit
2db8fc1021
|
|
@ -25,7 +25,6 @@
|
||||||
namespace e2d
|
namespace e2d
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
// 随机数产生器
|
// 随机数产生器
|
||||||
class Random
|
class Random
|
||||||
{
|
{
|
||||||
|
|
@ -71,6 +70,7 @@ namespace e2d
|
||||||
|
|
||||||
// 音乐
|
// 音乐
|
||||||
class Music
|
class Music
|
||||||
|
: public Ref
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Music();
|
Music();
|
||||||
|
|
@ -89,7 +89,7 @@ namespace e2d
|
||||||
|
|
||||||
// 播放
|
// 播放
|
||||||
bool Play(
|
bool Play(
|
||||||
int loop_count = 0
|
int loop_count = 0 /* 播放循环次数 (-1 为循环播放) */
|
||||||
);
|
);
|
||||||
|
|
||||||
// 暂停
|
// 暂停
|
||||||
|
|
@ -112,7 +112,7 @@ namespace e2d
|
||||||
|
|
||||||
// 设置音量
|
// 设置音量
|
||||||
bool SetVolume(
|
bool SetVolume(
|
||||||
float volume /* 1.0 为原始音量 */
|
float volume /* 1 为原始音量, 大于 1 为放大音量, 0 为最小音量 */
|
||||||
);
|
);
|
||||||
|
|
||||||
// 获取 IXAudio2SourceVoice 对象
|
// 获取 IXAudio2SourceVoice 对象
|
||||||
|
|
@ -146,7 +146,7 @@ namespace e2d
|
||||||
// 播放音乐
|
// 播放音乐
|
||||||
bool Play(
|
bool Play(
|
||||||
const String& file_path, /* 音乐文件路径 */
|
const String& file_path, /* 音乐文件路径 */
|
||||||
int loop_count = 0 /* 重复播放次数,设置 -1 为循环播放 */
|
int loop_count = 0 /* 播放循环次数 (-1 为循环播放) */
|
||||||
);
|
);
|
||||||
|
|
||||||
// 暂停音乐
|
// 暂停音乐
|
||||||
|
|
@ -177,7 +177,7 @@ namespace e2d
|
||||||
// 播放音乐
|
// 播放音乐
|
||||||
bool Play(
|
bool Play(
|
||||||
const Resource& res, /* 音乐资源 */
|
const Resource& res, /* 音乐资源 */
|
||||||
int loop_count = 0 /* 重复播放次数,设置 -1 为循环播放 */
|
int loop_count = 0 /* 播放循环次数 (-1 为循环播放) */
|
||||||
);
|
);
|
||||||
|
|
||||||
// 暂停音乐
|
// 暂停音乐
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ bool e2d::Player::Load(const String & file_path)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
delete music;
|
music->Release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -109,7 +109,7 @@ bool e2d::Player::Load(const Resource& res)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
delete music;
|
music->Release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -198,7 +198,7 @@ void e2d::Player::ClearCache()
|
||||||
|
|
||||||
for (const auto& pair : musics_)
|
for (const auto& pair : musics_)
|
||||||
{
|
{
|
||||||
delete pair.second;
|
pair.second->Release();
|
||||||
}
|
}
|
||||||
musics_.clear();
|
musics_.clear();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue