system
1
|
|
|
|
Attention |
Topic was automatically imported from the old Question2Answer platform. |
|
Asked By |
ondesic |
I am using the following code in c# where audSound
is an AudioStreamPlayer
AudioStreamOGGVorbis d = GD.Load("C:/Sounds/mad.ogg") as AudioStreamOGGVorbis;
audSound.Stream = d;
audSound.Play();
This will work if it in a in the"res://" folder, but I can’t get it to load outside this folder. Could someone help?
system
2
|
|
|
|
Reply From: |
ondesic |
I wish more people would respond on this forum. Here is the solution that worked for me:
public void OpenSong(string path)
{
File file = new File();
Error err = file.Open(path, File.ModeFlags.Read);
byte[] b = file.GetBuffer((int)file.GetLen());
if(path.Extension() == "wav")
{
AudioStreamSample a = new AudioStreamSample();
a.Format = AudioStreamSample.FormatEnum.Format16Bits;
a.Stereo = true;
a.Data = b;
audSound.Stream = a;
}
else if(path.Extension() == "ogg")
{
AudioStreamOGGVorbis d = new AudioStreamOGGVorbis();
d.Data = b;
audSound.Stream = d;
}
audSound.Play();
}