?
So Problem behoben. Hab mich für die Thread-Methode entschieden. und zwar sollte es ein Programm sein, das mit fmod.dll MP3s aus einem Verzeichnis spielt Hier könnt ihr mal den Quellcode angucken:
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include "wincompat.h"
#include "fmod.h"
#include "fmod_errors.h"
#include <dirent.h>
#include <string.h>
#include <conio.h>
#define BUF_SIZE 255
FSOUND_STREAM *sample;
int check;
int lp;
int l; // Lange der Datei in MS
DWORD WINAPI ThreadFunc(LPVOID data)
{
char chr;
for(;;)
{
chr=_getch();
if(chr==' ')
{
if(check==0)
{
FSOUND_Stream_Stop(sample);
lp=FSOUND_Stream_GetTime(sample)+3;
check=1;
}
else
{
FSOUND_Stream_Play(FSOUND_FREE, sample);
FSOUND_Stream_SetTime(sample,lp+45);
lp=0;
check=0;
}
fflush(stdin);
}
if(chr=='n')
{
FSOUND_Stream_SetTime(sample,l-12);
}
Sleep(30);
}
// gibt den Wert zurück den du bekommen hast
return((DWORD)data);
} // end ThreadFunc
using namespace std;
int main()
{
HANDLE hThread[1];
DWORD dwThreadID;
int p; // Aktuelle Lange der Musikdatei
float percent;// Aktuelle Prozentanzahl wiedergegeben
char pfad[150]; // Erzeugt den Pfad
DIR *hdir; // Verzeichnis Varia
struct dirent *entry;
if (FSOUND_GetVersion() < FMOD_VERSION)
{
printf("Error : You are using the wrong DLL version! You should be using FMOD %.02f\n", FMOD_VERSION);
exit(1);
}
FSOUND_Init(44100, 128, 0);
hdir = opendir("Musk");
do
{
entry = readdir(hdir);
if (entry)
{
sprintf(pfad,"Musk/%s",entry->d_name);
if((strcmp(entry->d_name,".")==0) || (strcmp(entry->d_name,"..")==0))
continue;
sample=FSOUND_Stream_Open(pfad,FSOUND_NORMAL,0,0);
FSOUND_Stream_SetMode(sample, FSOUND_LOOP_OFF);
FSOUND_Stream_Play(FSOUND_FREE, sample);
l=FSOUND_Stream_GetLengthMs(sample);
printf("%s\n",entry->d_name);
printf("Gesamtlange in Sekunden: %d s\n",l/1000);
printf ("Verganghende Zeit: \n\n");
hThread[1]= CreateThread( NULL,
0,
ThreadFunc,
(LPVOID)0,
0,
&dwThreadID);
for(; ;)
{
p=FSOUND_Stream_GetTime(sample);
percent=100/(float)l;
percent*=(float)p;
printf("\r");
printf("%d s %0.2f Prozent",p/1000,percent);
Sleep(80);
if(FSOUND_Stream_GetTime(sample)==l)
{
FSOUND_Stream_Stop(sample);
break;
}
}
// Auf die Threads warten, bis sie fertig sind
WaitForMultipleObjects( 1, // Anzahl der Threads, auf die gewartete werden muss
hThread, // Handles der Threads
TRUE,INFINITE); // Wie lange soll gewartet werden, INFINITE = unendlich lange
// Alle Threads sollten beendet sein
CloseHandle(hThread[1]);
printf("\n\n");
}
}while (entry);
closedir(hdir);
system("pause");
return 0;
}
Gruß PillePalle