-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmusic.h
More file actions
32 lines (29 loc) · 697 Bytes
/
music.h
File metadata and controls
32 lines (29 loc) · 697 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include<stdio.h>
#include<windows.h>
#include<mmsystem.h>
#pragma comment(lib,"winmm.lib")
DWORD WINAPI _playmusic(LPVOID wavpath)
{
//PlaySound((char*)wavpath,0,SND_FILENAME|SND_NOWAIT);
char *c=NULL;
char *c1="open ";
char *c2=" alias a1 wait";
size_t l=strlen(c1)+strlen((char*)wavpath)+strlen(c2)+1;
c=(char*)calloc(l,sizeof(char));
if(!c)return 0;
strcat(c,c1);
strcat(c,(char*)wavpath);
strcat(c,c2);
mciSendString(c,NULL,0,NULL);
mciSendString("play a1",0,0,0);
free(c);
return 0;
}
int playmusic(const char* wavpath)
{
CreateThread(NULL, 0, _playmusic,(LPVOID)wavpath, 0, NULL);
return 0;
}
void playeatmusic(){
playmusic("eat.wav");
}