home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Elysian Archive
/
AmigaElysianArchive.iso
/
sound
/
sampplay
/
intsnd.lha
/
playsound.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-01-20
|
2KB
|
87 lines
#include <stdio.h>
#include <Intuition/Intuition.h>
#include <string.h>
#include <exec/types.h>
#include "filewindow.h"
#include "easysound.h"
extern USHORT FileWindow();
struct IntuitionBase *IntuitionBase;
struct IntuiMessage *your_message;
/*POINTER TO SOUND*/
CPTR TheSoundFile;
char MyMessage[50];
void CloseAll();
void main()
{
/* Declare variable to use for FileWindow */
USHORT operation;
UBYTE file[TOTAL_LENGTH];
int Done=1;
BOOL ok=FALSE;
char MyTitle[50]="Play What File";
/* Open Intuiton libarary */
if ( (IntuitionBase = (struct IntuitionBase *)
OpenLibrary("intuition.library",33)) == NULL)
{
printf("Can't open intuition library");
exit();
}
while(Done==1)
{
/* Open File Window (requester)*/
operation=FileWindow(
MyTitle, /*Title*/
NULL, /*extension*/
0,0, /*x,y positon */
NULL, /*screen (Workbench)*/
file /*file with path*/
);
/* What does user want to do? */
switch(operation)
{
case LOAD: Done--; strcpy(MyMessage,"Gaget should not work"); break;
case SAVE: /* Prepare And Play Sound File */
StopSound(LEFT1);
StopSound(RIGHT1);
TheSoundFile = PrepareSound(file);
if ( !TheSoundFile )
strcpy(MyTitle,"Can't prepare sound");
else
{
ok=PlaySound (TheSoundFile, MAXVOLUME, LEFT1, NORMALRATE, 1 );
ok=PlaySound (TheSoundFile, MAXVOLUME, RIGHT1, NORMALRATE, 1);
if(ok==FALSE)
strcpy(MyTitle,"Not played succesfully");
else
strcpy(MyTitle,"Play What File");
}
break;
case CANCEL:
case QUIT: Done--; strcpy(MyMessage,"Done"); break;
case PANIC:
default: Done--; strcpy(MyMessage,"ERROR");break;
}
}
CloseAll(MyMessage);
}
void CloseAll()
{
printf("%s\n",MyMessage);
StopSound(LEFT1);
StopSound(RIGHT1);
if (TheSoundFile)
RemoveSound(TheSoundFile);
if (IntuitionBase)
CloseLibrary(IntuitionBase);
exit();
}