/* cdaudio.c SDL Example Play 10 seconds of track one on a CD. Bill Kendrick 1/2000 */ #include <stdio.h> #include <stdlib.h> #include <SDL/SDL.h> int main(int argc, char * argv[]) { SDL_CD *cdrom; /* Init SDL: */ SDL_Init(SDL_INIT_CDROM); /* Check for CDROM drive: */ if (SDL_CDNumDrives() == 0) { fprintf(stderr, "No CD drives.\n"); exit(1); } /* Open the default drive: */ cdrom = SDL_CDOpen(0); if (cdrom == NULL) { fprintf(stderr, "Can't open CD: %s\n", SDL_GetError()); exit(1); } /* Play track one, starting at the 15 second point: */ if (CD_INDRIVE(SDL_CDStatus(cdrom))) { SDL_CDPlay(cdrom, 15 * CD_FPS, 10 * CD_FPS); SDL_Delay(10000); } else { fprintf(stderr, "No CD\n"); } /* Close up and quit: */ SDL_CDClose(cdrom); SDL_Quit(); return(0); } |