[Gambas-user] is possible to "inglobe" data (audio, video, etc) into gambas code?
Bruce Steers
bsteers4 at gmail.com
Tue Sep 19 20:41:06 CEST 2023
On Tue, 19 Sept 2023 at 19:08, Benoît Minisini <
benoit.minisini at gambas-basic.org> wrote:
> Le 19/09/2023 à 19:59, Bruce Steers a écrit :
> >
> >
> > On Tue, 19 Sept 2023 at 16:39, <roberto.premoli at tiscali.it
> > <mailto:roberto.premoli at tiscali.it>> wrote:
> >
> > Il 17.09.2023 14:00 Bruce Steers ha scritto:
> >
> > > On Sun, 17 Sept 2023 at 00:48, wrote:
> > >
> > >> hello,
> > >> my need is ti advise the user with sound: i just discovered how
> to
> > >> play
> > >> a audio with
> > >>
> > >> music.load("/path/to/clip.mp3")
> > >> music.play()
> > >>
> > >> and it run smooth.
> > >>
> > >> Anyway, it coud happen that clip.mp3 can be corrupted, deleted,
> etc.
> > >>
> > >> So the qeustion is:
> > >>
> > >> it is possible to "inglobe" int into the source code of gambas?
> > >>
> > >> it will allow me to avoid to manage the extenal clip.mp3 because
> it
> > >> will be always inside the program.
> > >>
> > >> As alternative, is possible to generate some advise sound
> > equivalent
> > >> to
> > >> "allert", "incamig call", "new mail", etc with primitive of
> gambas
> > >> without use external audio sounds clip?
> > >>
> > >> Thanks,
> > >> Roberto
> > >
> > > do you just mean "include" your sound files with the executable?
> > > that is fairly simple.
> > > Just create a folder in your project directory, for example
> "sounds"
> > > (you
> > > must not use .hidden folder names unless it's name is .public)
> > > Put your clip.mp3 file into the sounds folder then access it like
> > > this..
> > > music.load("./sounds/clip.mp3")
> > > or
> > > music.load("sounds/clip.mp3")
> > > BruceS
> >
> > i already did this, but it is not "INSIDE" the code, is still a
> > separate file.
> > it is "WITH" the executable, i want it "INSIDE" the executable. is it
> > possible?
> >
> >
> > Yes it should be inside the executable.
> >
> > It will not be included if it's name begins with a dot like .my_mp3.mp3
> > It will not be included if it's folder name begins with a dot like
> > .my_mp3s/My_.mp3
> >
> > otherwise the file should be inside the executable.
> >
> > you can read the executables contents using gba3 -l
> > eg.
> > gba3 -l /my/dir/My_Project.gambas
> >
> > if your mp3's are not hidden or in a hidden folder then they should be
> > inside and accessible with the uri's i previously mentioned.
> >
> > Post a sample project where the mp3 is not being inside the executable
> > and i'll see if i can find the issue.
> >
> > Respects
> > BruceS
> >
>
> Note that if you use Music.Load(), as this SDL function cannot read
> inside Gambas archive, a copy of the file is done in the process
> temporary directory so that SDL can use it.
>
> Regards,
>
> --
> Benoît Minisini
aah yes so you would want code something like this if you have a clip.mp3
file in a folder called sounds in the project dir...
Public sClipFile As String = "./sounds/clip.mp3"
Public Sub Form_Load()
PlayInternalMusic(sClipFile)
End
Public Sub PlayInternalMusic(sFile As String)
Dim sTempName As String = File.Dir(Temp()) &/ File.Name(sFile)
If Not Exist(sTempName) Then Copy sFile To sTempName
Music.Load(sTempName)
Music.Play()
End
Respects
BruceS
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20230919/1ccbabfd/attachment.htm>
More information about the User
mailing list