# Same problem

**URL:** <https://discourse.libsdl.org/t/same-problem/8748>\
**Category:** SDL Development\
**Created:** [May 15, 2003, 1:15pm UTC](https://discourse.libsdl.org/t/same-problem/8748 "2003-05-15T13:15:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hri](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/h/3e96dc/32.png) [@Hri](https://discourse.libsdl.org/u/Hri)\
**Post date:** [May 15, 2003, 1:15pm UTC](https://discourse.libsdl.org/t/same-problem/8748/1 "2003-05-15T13:15:01Z")

</div>

I’ve read this discussion and I’ve decided to try loading wav from a zip  
and I got the same problem.  
SDL\_GetError reports: Error reading from datastream.  
I do not have problem reading images though.  
I have compiled zziplib 10.80 (I can’t believe I’ve done it 😉 and I use  
the latest precompiled SDL for Windows.

I have tried both SDL\_LoadWav and Mix\_LoadWAV\_RW and I get the same  
error. Bellow is part of the code (nothing nice).

Isn’t there Mix\_LoadMUS\_RW? How can I load MOD, MP3 or other files from  
a zip to play them with SDL\_mixer?

I would like to have all the data into a zip file for now.

SDL\_RWops \*rw;

// Audio mode  
int audioRate = 44100;  
int audioChannels = 2;  
int audioBuffer = 4096;  
Uint16 audioFormat = AUDIO\_S16;

if ( ( rw = SDL\_RWFromZZIP(“data1/ir\_begin.wav”, “rb”) ) == NULL )  
{  
printf(" ERROR: %s\n",SDL\_GetError());  
exit(2);  
}  
/\*SDL\_AudioSpec wav\_spec;

SDL\_AudioSpec \*music1;  
Uint32 wav\_length;  
Uint8 \*wav\_buffer;

music1 = SDL\_LoadWAV\_RW( rw, 0, &wav\_spec, &wav\_buffer, &wav\_length );

```
if ( music1 == NULL )

```

{  
printf( “XM sound file load failed: %s\n”,  
SDL\_GetError()  
);  
//exit( 2 );  
}\*/

Mix\_Chunk \*music2;  
music2 = Mix\_LoadWAV\_RW( rw, 0);  
if ( music2 == NULL )  
{  
printf( “XM sound file load failed: %s\n”,  
Mix\_GetError()  
);  
//exit( 2 );  
}

SDL\_FreeRW(rw);

---

<div class="post-metadata">

**Author:** ![David\_Hedbor](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/david_hedbor/32/2440_2.png) [@David\_Hedbor](https://discourse.libsdl.org/u/David_Hedbor)\
**Post date:** [May 15, 2003, 3:45pm UTC](https://discourse.libsdl.org/t/same-problem/8748/2 "2003-05-15T15:45:01Z")

</div>

“Hr. Hristov” \<hr\_hristov at [hotmail.com](http://hotmail.com)\> writes:

> Isn’t there Mix\_LoadMUS\_RW? How can I load MOD, MP3 or other files from  
> a zip to play them with SDL\_mixer?

1. Load from zip and write to temporary file.
2. Mix\_LoadMUS from the temporary file
3. Delete temporary file.

Note that this works on Unix (the deletion part) since the reference  
is kept until you close the program / unload the music. On Windows  
(and other platforms) this might very well not work.

So the real answer for most cases is that you can’t - music has to  
come directly from disk.–  
[Below is a random fortune, which is unrelated to the above message.]  
Q: How many Harvard MBA’s does it take to screw in a light bulb?  
A: Just one. He grasps it firmly and the universe revolves around him.
