![]() |
mit sdl eine WAV-datei abspielen
Hallo!
Ich bin gerade am verzweifeln: Wie kann ich denn (ohne sdl_mixer) mit sdl eine wav-Datei im Endlosschlaufe abspielen? Oder auch einfach nur überhaupt? Ich bekomme es einfach nicht hin :( |
AW: mit sdl eine WAV-datei abspielen
Hi!
ich habe es jetzt hinbekommen:
Delphi-Quellcode:
Mein Fehler was das mir smpeg fehlte -_-
program project1;
{$mode delphi}{$H+} uses cthreads, Classes,sdl,sdl_mixer; var audio_rate:integer; audio_format:UInt16; audio_channels:integer; audio_buffers:integer; sound:PMix_Chunk; screen:PSDL_Surface; channel:integer; {$IFDEF WINDOWS}{$R project1.rc}{$ENDIF} begin if (SDL_Init(SDL_INIT_VIDEO or SDL_INIT_AUDIO) <>0) then begin writeln('[ERROR] Can''t init SDL: '+SDL_GetError()); exit; end; audio_rate:=22050; audio_format:=AUDIO_S16SYS; audio_channels:=2; audio_buffers:=4096; if (Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers)<>0) then begin writeln('[ERROR] Can''t init SDL_Mixer: '+Mix_GetError()); exit; end; sound:=Mix_LoadWAV('/home/peter/LazProjekte/TsdlG/data/music/game-musik.wav'); if (sound=nil) then begin writeln('[ERROR] Can''t load Wav: '+Mix_GetError()); exit; end; screen:=SDL_SetVideoMode(320,240,0,SDL_ANYFORMAT); if (screen=nil) then begin writeln('[ERROR] Can''t set video mode: '+SDL_GetError()); exit; end; channel:=Mix_PlayChannel(-1, sound, 0); if (channel=-1) then begin writeln('[ERROR] Can''t play Wav file: '+Mix_GetError()); exit; end; while(Mix_Playing(channel) <> 0) do ; Mix_FreeChunk(sound); Mix_CloseAudio(); SDL_Quit(); end. Danach ging es auch mit sdl_mixer :) |
Alle Zeitangaben in WEZ +1. Es ist jetzt 12:38 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz