Magic_Game/src/utils/Player.h

95 lines
2.2 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
2019-01-22 10:23:12 +08:00
#include "../core/include-forwards.h"
#include "../core/Resource.h"
2018-11-25 20:25:46 +08:00
#include <unordered_map>
namespace easy2d
{
// <20><><EFBFBD>ֲ<EFBFBD><D6B2><EFBFBD><EFBFBD><EFBFBD>
class E2D_API Player
2018-11-17 23:24:16 +08:00
: protected Noncopyable
{
using MusicMap = Map<size_t, MusicPtr>;
2018-11-25 20:25:46 +08:00
public:
Player();
~Player();
// Ԥ<><D4A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ
bool Load(
2019-01-21 21:24:45 +08:00
Resource const& res /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ */
);
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
bool Play(
Resource const& res, /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ */
int loop_count = 0 /* <20><><EFBFBD><EFBFBD>ѭ<EFBFBD><D1AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (-1 Ϊѭ<CEAA><D1AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) */
);
// <20><>ͣ<EFBFBD><CDA3><EFBFBD><EFBFBD>
void Pause(
Resource const& res /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ */
);
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void Resume(
Resource const& res /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ */
);
// ֹͣ<CDA3><D6B9><EFBFBD><EFBFBD>
void Stop(
Resource const& res /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ */
);
// <20><>ȡ<EFBFBD><C8A1><EFBFBD>ֲ<EFBFBD><D6B2><EFBFBD>״̬
bool IsPlaying(
Resource const& res /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ */
);
// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
float GetVolume() const;
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void SetVolume(
float volume /* 1.0 Ϊԭʼ<D4AD><CABC><EFBFBD><EFBFBD> */
);
// <20><>ͣ<EFBFBD><CDA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void PauseAll();
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void ResumeAll();
// ֹͣ<CDA3><D6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void StopAll();
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2018-11-12 20:46:54 +08:00
void ClearCache();
protected:
2018-11-25 20:25:46 +08:00
float volume_;
MusicMap musics_cache_;
};
}