Sign in to follow this  
Followers 0
gil900

Playing mp3 files inside the exe file with SoundPlay()

10 posts in this topic

#1 ·  Posted (edited)

Hello,

i want to know if the function SoundPlay() can get a mp3 sound source from the exe file itself.

in my case, the mp3 files will be inside the exe file in some way and i want to play these files directly from the exe file and without stopping the script("0 = continue script while sound is playing (default)").

i want to do this with SoundPlay() if it is possible.

 
 If not then I need to do it with another function.

Some important points to me:
* Continue script while sound is playing.
* Ability to stop the sound.
* No need for external dll file
* Will work under vista , win7 , win8

I still  did not choose the way I store files in the exe .. I'll deal with this trouble in the future.
 

Thanks for helpers!

 

Edited by gil900

Share this post


Link to post
Share on other sites



By reading the AutoIt Help Function Reference for SoundPlay, I will say, no. Cause the parameter of the function is the path to the file to be played.

Since the exe will have the information of the sound inside (if its possible), the function will not know how to extract the sound from the rest of the info.

But maybe im wrong :sweating:

Share this post


Link to post
Share on other sites

gil900,

Zedna's Resources UDF will allow you to play .wav files from within the resource table - but at some cost given the likely size of the sound files. :(

Otherwise, you could always FileInclude the sound files, play them once they are extracted, and delete them on exit. ;)

As to your additional playing requirements - look at the _Sound UDF which gives you much more control over the sound file than SoundPlay. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Another way: 

 

Br,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

 

On 29.11.2013 at 10:27 AM, UEZ said:

Another way: 

 

Br,

UEZ

Thank you!

I loved the way how you save the file exe file.

 

I checked the two things:

1) the way how you save the file in the exe.

2) playing the mp3.

 

About 2), it is a nearly perfect. But the problem is that it does not work if it is compiled in 64bit .. I need it to work even when it is compiled in 64bit.

 

But for now, what is more worrisome to me is 1).

I like this way (how you store a file in exe).

But I did a memory test and I noticed something wrong.

 

Please download the attached example and open the exe file.

The explanation about what I found appears in the example.

test.zip

EDIT:

I reuploaded the test. i had a little mistake before

Edited by gil900

Share this post


Link to post
Share on other sites

It's not wrong, it's got to put the information for the script somewhere, even if you're not using the function it's going to get loaded.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

It's not wrong, it's got to put the information for the script somewhere, even if you're not using the function it's going to get loaded.

And that's exactly what I want to prevent.

No need to use the mp3 files all the time...

 

now it look for you small problem because more 800 K is not a big deal.

but what will happens when there are more and more mp3 files? the Additional 800K  can easily change more few megas. Now it is big deal!

i think that with this >Resources UDF, this problem will not occur.

I'm right?

Edited by gil900

Share this post


Link to post
Share on other sites

gil900,

Storing the sound files in the resource table will still increase the size of the executable. However you store the files (FileInstall, resource table, external dll, etc) you have to find the space somewhere - they cannot magically appear when you want to play them. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

I used fmod.dll because of the smaller DLL size than bass.dll. If you want you can use the x64 bass.dll version and compile your script as x64 executable.

Today most of the PCs have more than 2GB memory and it should be a big problem to embed some binary data into the exe without getting in trouble but you are right that the memory usage of my method is much higher than using resource UDF.

Using a 9.70 mb MP3 file and compiled script without UPX:

 

Resource UDF ->

  • exe size: 10.6 mb
  • memory usage (working set) without calling the function: 9484 kb
  • memory usage (working set) loading the resource: 30320 kb

 

Embedded as Base64 ->

  • exe size: 14.5 mb
  • memory usage (working set) without calling the function: 51740 kb
  • memory usage (working set) calling the function: 63492 kb

 

Used AutoIt version 3.3.9.23.

 

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

I used fmod.dll because of the smaller DLL size than bass.dll. If you want you can use the x64 bass.dll version and compile your script as x64 executable.

Today most of the PCs have more than 2GB memory and it should be a big problem to embed some binary data into the exe without getting in trouble but you are right that the memory usage of my method is much higher than using resource UDF.

Using a 9.70 mb MP3 file and compiled script without UPX:

 

Resource UDF ->

  • exe size: 10.6 mb
  • memory usage (working set) without calling the function: 9484 kb
  • memory usage (working set) loading the resource: 30320 kb

 

Embedded as Base64 ->

  • exe size: 14.5 mb
  • memory usage (working set) without calling the function: 51740 kb
  • memory usage (working set) calling the function: 63492 kb

 

Used AutoIt version 3.3.9.23.

 

Br,

UEZ

I knew I was right.. :)

So I have to decide which method to use.

There are some questions that will affect the final decision. one of them still have no answer(And you can not answer that).

At the end of development, I am going to encrypt the exe file.

1) If I use the method title="">Resources UDF then - is it likely to be critical problems with the files that inside the exe file?

I mean - the encryption of the exe file can cause to the Resources UDF not to work?

I guess so..

if it is true, is there a solution to this problem? Is the solution is complicated?

2) If all of my  mp3 files will take about maximum 1.2mb, then more 1.2mb to the memory use(not in the hardisk as M23 thinking) is not big deal.. so in this case i think I prefer your method. Because it might save me a lot of headache later in development

Edited by gil900

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0