[Gambas-user] sdl2 application
charlesbukowski.italy at gmail.com
Tue May 3 21:15:07 CEST 2022
Hi, I have tried your code but I am getting "Null Object" error at runtime
at line "audio.play(sample)", after selecting file in Dialog.OpenFile().
Il giorno mar 3 mag 2022 alle ore 17:46 T Lee Davidson <
t.lee.davidson at gmail.com> ha scritto:
> On 5/3/22 08:28, Charles Bukowski wrote:
> > Hello, I am writing a simple application that plays a self made .wav
> file using sdl2.
> > It is a main form with a button that opens another form with three
> buttons : one to choose the file to play, one to close form
> > and go back to main and the other to close the application.It works, but
> the sample is played for eight (???) times only;
> > clicking on the button for the ninth time and further, sound channel is
> > Furthermore, Is it possible to declare event handlers of the second form
> No. Event handlers must be Public methods so the event loop manager can
> "see" them.
> See http://gambaswiki.org/wiki/doc/object-model#t7
> Attempting to play the sound file for the ninth time, the sound is not
> muted. It simply does not play.
> It appears that creating and destroying the Channel multiple times causes
> a resource lock. It should not be necessary to
> re-create the Channel every time a WAV file is to be played. It can be
> created once when the form is opened.
> Try this code:
> ' Gambas class file
> Private audio As Channel
> Public Sub Form_Open()
> audio = New Channel As "audio"
> Private Sub PlayAudio()
> Dim sample As Sound
> Dim Filename As String
> Dialog.Filter = ["*.wav;*.mp3", "audio files"]
> Dialog.Path = Application.Path
> If Dialog.OpenFile() Then Return 'User clicked cancel. No selection,
> back to calling form.
> Filename = Dialog.Path
> sample = Sound.load(Filename)
> sample = Null 'destoy sound object
> BTW, Quit should not be used to close a graphical application. Your
> QuitProgram button click event handler should be:
> Public Sub QuitProgram_Click()
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the User