mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-26 03:52:01 +02:00
implements sounds
This commit is contained in:
parent
2bbce0f38b
commit
be2b3afe48
@ -424,12 +424,19 @@ int main(int argc, char * argv[])
|
||||
void playIntro()
|
||||
{
|
||||
auto audioData = CCS->videoh->getAudio(VideoPath::builtin("3DOLOGO.SMK"));
|
||||
CCS->soundh->playSound(audioData);
|
||||
int sound = CCS->soundh->playSound(audioData);
|
||||
if(CCS->videoh->openAndPlayVideo(VideoPath::builtin("3DOLOGO.SMK"), 0, 1, true, true))
|
||||
{
|
||||
audioData = CCS->videoh->getAudio(VideoPath::builtin("NWCLOGO.SMK"));
|
||||
sound = CCS->soundh->playSound(audioData);
|
||||
if (CCS->videoh->openAndPlayVideo(VideoPath::builtin("NWCLOGO.SMK"), 0, 1, true, true))
|
||||
{
|
||||
audioData = CCS->videoh->getAudio(VideoPath::builtin("H3INTRO.SMK"));
|
||||
sound = CCS->soundh->playSound(audioData);
|
||||
CCS->videoh->openAndPlayVideo(VideoPath::builtin("H3INTRO.SMK"), 0, 1, true, true);
|
||||
}
|
||||
}
|
||||
CCS->soundh->stopSound(sound);
|
||||
}
|
||||
|
||||
static void mainLoop()
|
||||
|
@ -151,7 +151,8 @@ Mix_Chunk *CSoundHandler::GetSoundChunk(std::pair<std::unique_ptr<ui8 []>, si64>
|
||||
if (cache && soundChunksRaw.find(startBytes) != soundChunksRaw.end())
|
||||
return soundChunksRaw[startBytes].first;
|
||||
|
||||
Mix_Chunk *chunk = Mix_QuickLoad_RAW(data.first.get(), (int)data.second);
|
||||
SDL_RWops *ops = SDL_RWFromMem(data.first.get(), (int)data.second);
|
||||
Mix_Chunk *chunk = Mix_LoadWAV_RW(ops, 1); // will free ops
|
||||
|
||||
if (cache)
|
||||
soundChunksRaw.insert({startBytes, std::make_pair (chunk, std::move (data.first))});
|
||||
|
@ -571,6 +571,8 @@ std::pair<std::unique_ptr<ui8 []>, si64> CVideoPlayer::getAudio(const VideoPath
|
||||
wav_hdr wav;
|
||||
wav.ChunkSize = samples.size() + sizeof(wav_hdr) - 8;
|
||||
wav.Subchunk2Size = samples.size() + sizeof(wav_hdr) - 44;
|
||||
wav.SamplesPerSec = formatAudio->streams[streamAudio]->codecpar->sample_rate;
|
||||
wav.bitsPerSample = formatAudio->streams[streamAudio]->codecpar->bits_per_coded_sample;
|
||||
auto wavPtr = reinterpret_cast<ui8*>(&wav);
|
||||
|
||||
dat = std::pair<std::unique_ptr<ui8 []>, si64>(std::make_pair(std::make_unique<ui8[]>(samples.size() + sizeof(wav_hdr)), samples.size() + sizeof(wav_hdr)));
|
||||
|
@ -295,6 +295,8 @@ void CHighScoreInputScreen::show(Canvas & to)
|
||||
{
|
||||
CCS->videoh->close();
|
||||
video = "HSLOOP.SMK";
|
||||
auto audioData = CCS->videoh->getAudio(VideoPath::builtin(video));
|
||||
sound = CCS->soundh->playSound(audioData);
|
||||
CCS->videoh->open(VideoPath::builtin(video));
|
||||
}
|
||||
else
|
||||
@ -307,6 +309,8 @@ void CHighScoreInputScreen::show(Canvas & to)
|
||||
|
||||
void CHighScoreInputScreen::activate()
|
||||
{
|
||||
auto audioData = CCS->videoh->getAudio(VideoPath::builtin(video));
|
||||
sound = CCS->soundh->playSound(audioData);
|
||||
if(!CCS->videoh->open(VideoPath::builtin(video)))
|
||||
{
|
||||
if(!won)
|
||||
@ -320,6 +324,7 @@ void CHighScoreInputScreen::activate()
|
||||
void CHighScoreInputScreen::deactivate()
|
||||
{
|
||||
CCS->videoh->close();
|
||||
CCS->soundh->stopSound(sound);
|
||||
CIntObject::deactivate();
|
||||
}
|
||||
|
||||
|
@ -95,6 +95,7 @@ class CHighScoreInputScreen : public CWindowObject
|
||||
std::shared_ptr<TransparentFilledRectangle> background;
|
||||
|
||||
std::string video;
|
||||
int sound;
|
||||
bool won;
|
||||
HighScoreCalculation calc;
|
||||
public:
|
||||
|
@ -27,6 +27,8 @@ CPrologEpilogVideo::CPrologEpilogVideo(CampaignScenarioPrologEpilog _spe, std::f
|
||||
pos = center(Rect(0, 0, 800, 600));
|
||||
updateShadow();
|
||||
|
||||
auto audioData = CCS->videoh->getAudio(spe.prologVideo);
|
||||
sound = CCS->soundh->playSound(audioData);
|
||||
CCS->videoh->open(spe.prologVideo);
|
||||
CCS->musich->playMusic(spe.prologMusic, true, true);
|
||||
voiceSoundHandle = CCS->soundh->playSound(spe.prologVoice);
|
||||
@ -62,6 +64,7 @@ void CPrologEpilogVideo::show(Canvas & to)
|
||||
void CPrologEpilogVideo::clickPressed(const Point & cursorPosition)
|
||||
{
|
||||
close();
|
||||
CCS->soundh->stopSound(sound);
|
||||
CCS->soundh->stopSound(voiceSoundHandle);
|
||||
exitCb();
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ class CPrologEpilogVideo : public CWindowObject
|
||||
|
||||
std::shared_ptr<CMultiLineLabel> text;
|
||||
|
||||
int sound = 0;
|
||||
bool voiceStopped = false;
|
||||
|
||||
public:
|
||||
|
Loading…
x
Reference in New Issue
Block a user