EMI: Implement opcode PlaySound

This commit is contained in:
Joel Teichroeb 2012-02-17 20:06:04 -08:00
parent a979958479
commit faa0c3430a
2 changed files with 17 additions and 0 deletions

View File

@ -111,6 +111,7 @@ protected:
DECLARE_LUA_OPCODE(FreeSound);
DECLARE_LUA_OPCODE(PlayLoadedSound);
DECLARE_LUA_OPCODE(StopSound);
DECLARE_LUA_OPCODE(PlaySound);
DECLARE_LUA_OPCODE(GetSoundVolume);
DECLARE_LUA_OPCODE(SetSoundVolume);
DECLARE_LUA_OPCODE(PlaySoundFrom);

View File

@ -246,6 +246,22 @@ void Lua_V2::StopSound() {
}
}
void Lua_V2::PlaySound() {
lua_Object strObj = lua_getparam(1);
//FIXME: get the second param
lua_getparam(2);
if (!lua_isstring(strObj))
return;
const char *str = lua_getstring(strObj);
AIFFTrack *track = new AIFFTrack(Audio::Mixer::kSFXSoundType);
Common::SeekableReadStream *stream = g_resourceloader->openNewStreamFile(str);
track->openSound(str, stream);
track->play();
}
void Lua_V2::ImSetMusicVol() {
// This only seems to be used in the demo.
lua_Object volumeObj = lua_getparam(1);