Eseguire un CDROM mediante le funzioni del API di SDL
Da Gambas-it.org - Wikipedia.
Versione del 28 lug 2024 alle 04:49 di Vuott (Discussione | contributi) (Creata pagina con "La libreria '''SDL''' ci permette di eseguire il contenuto audio di un CDROM. Le funzioni, utili per gestire il CDROM, nella versione obsoleta, ma ancora funzionante, "''libS...")
La libreria SDL ci permette di eseguire il contenuto audio di un CDROM.
Le funzioni, utili per gestire il CDROM, nella versione obsoleta, ma ancora funzionante, "libSDL-1.2:1.2.68 ".
Mostriamo un semplice esempio pratico:
Library "libSDL-1.2:1.2.68" Private Const SDL_INIT_CDROM As Integer = &h100 Private Enum CD_TRAYEMPTY, CD_STOPPED, CD_PLAYING, CD_PAUSED, CD_ERROR = -1 ' int SDL_Init(Uint32 flags) ' Initialize the SDL library. Private Extern SDL_Init(flags As Integer) As Integer ' int SDL_CDNumDrives(void) ' Returns the number of CD-ROM drives on the system. Private Extern SDL_CDNumDrives() As Integer ' SDL_CD *SDL_CDOpen(int drive) ' Opens a CD-ROM drive for access. Private Extern SDL_CDOpen(drive As Integer) As Pointer ' CDstatus SDL_CDStatus(SDL_CD *cdrom) ' Returns the current status of the given drive. Private Extern SDL_CDStatus(cdrom As Pointer) As Integer ' int SDL_CDPlayTracks(SDL_CD *cdrom, int start_track, int start_frame, int ntracks, int nframes)) ' SDL_CDPlayTracks plays the given CD starting at track start_track, for ntracks tracks. Private Extern SDL_CDPlayTracks(cdrom As Pointer, start_track As Integer, start_frame As Integer, ntracks As Integer, nframes As Integer) As Integer ' void SDL_CDClose(SDL_CD *cdrom) ' Closes the given cdrom handle. Private Extern SDL_CDClose(cdrom As Pointer) ' void SDL_Quit(void) ' Shuts down all SDL subsystems and frees the resources allocated to them. Private Extern SDL_Quit() Public Sub Main() Dim cd As Pointer SDL_Init(SDL_INIT_CDROM) If SDL_CDNumDrives() == 0 Then Print "Nessun Driver CDRom connesso !" Chiusura() Endif cd = SDL_CDOpen(0) If cd == 0 Then Print "Impossibile aprire il CD-Rom !" Chiusura() Endif If SDL_CDStatus(cd) == 1 Then ' Esegue l'intero CDRom. ' (Se si vuole eseguire una traccia determinata, si porrà il numero della sua posizione nel 4° argomento della seguente funzione). SDL_CDPlayTracks(cd, 0, 0, 0, 0) Endif SDL_CDClose(cd) Chiusura() End Private Procedure Chiusura() SDL_Quit() Quit End