Crystal Space
Welcome,
Guest
. Please
login
or
register
.
May 22, 2013, 11:42:07 pm
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Search:
Advanced search
9224
Posts in
2230
Topics by
5385
Members
Latest Member:
Ritatondreau
Crystal Space
Crystal Space Development
Support
Playing music from XML map file.. help!
« previous
next »
Pages:
[
1
]
Author
Topic: Playing music from XML map file.. help! (Read 1823 times)
maharaja
Jr. Member
Posts: 52
Playing music from XML map file.. help!
«
on:
December 08, 2008, 08:00:47 pm »
Hi all, and happy holidays to everyone. Here's my annual posting(lol)
To this day I have not understood how do you play a sound from an XML file?
In the good old articles on community site (Structure of an XML world file- part 1 & 2) it says to add:
<sounds>
<sound name="tada.wav">
<file>/std/data/tada.wav</file>
</sound>
</sounds>
But this dont work! The message I get is: "Unable to create sound data from /std/data/tada.wav"
I can very well play music from my C++ files but what I NEED to know is how can I play music from XML file.
The music file is perfectly ok.
Using CS & CEL 1.2.1 on WinXP with Win32 1.2_002 libraries. Everything working fine!
Any help would be highly appreciated!
cheers!
Logged
Vincent
Full Member
Posts: 191
Re: Playing music from XML map file.. help!
«
Reply #1 on:
December 19, 2008, 11:04:29 pm »
Hi,
does that work better ?
<sounds>
<sound name="tada.wav" file="/std/data/tada.wav" />
</sounds>
Note that doesn't "play" the sound, it only loads it and assign it a name, so you can find and play it from code (no need to load the file beforehand)...
If you use CEL and pcsound property class, you might be able to play it, but then it all depends on how your entity is set up (behaviour, etc.).
Logged
maharaja
Jr. Member
Posts: 52
Re: Playing music from XML map file.. help!
«
Reply #2 on:
January 04, 2009, 08:22:45 am »
Hi,
At present I'm playing background music from code as follows:
bool ClientMain::LoadSound ()
{
const char* fname = "/std/data/tada.wav";
csRef<iVFS> vfs = csQueryRegistry<iVFS> (GetObjectRegistry ());
csRef<iDataBuffer> soundbuf = vfs->ReadFile (fname);
if (!soundbuf)
return ReportError ("Can't load file '%s'!", fname);
csRef<iSndSysData> snddata = sndloader->LoadSound (soundbuf);
if (!snddata)
return ReportError ("Can't load sound '%s'!", fname);
csRef<iSndSysStream> sndstream = sndrenderer->CreateStream (snddata,
CS_SND3D_ABSOLUTE);
if (!sndstream)
return ReportError ("Can't create stream for '%s'!", fname);
sndsource = sndrenderer->CreateSource (sndstream);
if (!sndsource)
return ReportError ("Can't create source for '%s'!", fname);
sndsource3d = scfQueryInterface<iSndSysSourceSoftware3D> (sndsource);
sndsource3d->SetPosition (GetSoundPos (0));
sndsource3d->SetVolume (1.0f);
sndstream->SetLoopState (CS_SNDSYS_STREAM_LOOP);
sndstream->Unpause ();
//sndsrc->SetVolume( 1.0 );
return true;
}
Now... if I instead "load" the music from XML file as:
<sounds>
<sound name="bgmusic" file="/std/data/tada.wav" />
</sounds>
How do I access '´bgmusic' from the code and what I have to do to 'play' it?
Sorry if it sounds too basic... never tried like this before.
Thanks!
«
Last Edit: January 04, 2009, 08:27:48 am by maharaja
»
Logged
res
Develazyoper
CS Developer
Full Member
Posts: 206
Re: Playing music from XML map file.. help!
«
Reply #3 on:
January 04, 2009, 08:54:17 pm »
You should be able to query that sound with the FindSoundByName() method from the iSndSysManager instance in the object registry. See:
http://crystalspace3d.org/docs/online/api/structiSndSysManager.html
Logged
Pages:
[
1
]
« previous
next »
Jump to:
Please select a destination:
-----------------------------
Crystal Space Development
-----------------------------
=> General Crystal Space Discussion
=> Support
-----------------------------
Crystal Space Project Development
-----------------------------
=> Feature Requests
=> Plugins
=> Bug Reports
-----------------------------
Crystal Space Development
-----------------------------
=> Game Content Creation
-----------------------------
Miscellaneous
-----------------------------
=> Article/Tutorial Requests
=> Article/Tutorial Discussion
-----------------------------
Crystal Space Project Development
-----------------------------
=> Development Discussion
-----------------------------
Crystal Space Projects
-----------------------------
=> Project Discussion
=> WIP Projects
=> Finished Projects
-----------------------------
Associate Projects
-----------------------------
=> CEL Discussion
=> Crystal Core Discussion
=> CrystalBlend Discussion
-----------------------------
Crystal Space Project Development
-----------------------------
=> Google Summer of Code
-----------------------------
Associate Projects
-----------------------------
=> Apricot (Open Game)
=> Ares Project
Loading...