Magic_Game/Easy2D-Audio/Music.h

82 lines
1.9 KiB
C
Raw Normal View History

// Copyright (c) 2016-2018 Easy2D - Nomango
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#pragma once
#include "Voice.h"
namespace easy2d
{
E2D_DECLARE_SMART_PTR(Music);
// <20><><EFBFBD>ֶ<EFBFBD><D6B6><EFBFBD>
class E2D_API Music
: public virtual Object
{
public:
Music();
Music(
Resource const& res /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ */
);
virtual ~Music();
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ
bool Load(
Resource const& res /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ */
);
// <20><><EFBFBD><EFBFBD>
bool Play(
int loop_count = 0 /* <20><><EFBFBD><EFBFBD>ѭ<EFBFBD><D1AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (-1 Ϊѭ<CEAA><D1AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) */
);
// <20><>ͣ
void Pause();
// <20><><EFBFBD><EFBFBD>
void Resume();
// ֹͣ
void Stop();
// <20>رղ<D8B1><D5B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ
void Close();
// <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD>
bool IsPlaying() const;
// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
float GetVolume() const;
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
bool SetVolume(
float volume /* 1 Ϊԭʼ<D4AD><CABC><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD> 1 Ϊ<>Ŵ<EFBFBD><C5B4><EFBFBD><EFBFBD><EFBFBD>, 0 Ϊ<><CEAA>С<EFBFBD><D0A1><EFBFBD><EFBFBD> */
);
protected:
bool opened_;
bool playing_;
UINT32 size_;
BYTE* wave_data_;
Voice voice_;
};
}