* * *

Author Topic: Strange behaviour ("seeing" files)  (Read 2479 times)

Handoko

  • Hero Member
  • *****
  • Posts: 2598
  • My goal: build my own game engine using Lazarus
Re: Strange behaviour ("seeing" files)
« Reply #15 on: May 03, 2018, 06:33:45 am »
Hello, I'm back with my investigation result.

The PlayCommand of your playsound1 is play, which was automatically detected when the playsound1 is created (when you drop the component on the form).

And that is the problem. The program "play" doesn't exist on my computer. When running your program, I got no sound. And if I set the build mode to "Debug" and run the program again, I will get EProcess exception.

Why this issue happens?

TPlaySound will automatically find the first available sound player program on the user computer when an instance of TPlaySound is created, and the data will be stored. Unfortunately, it won't automatically refresh the data if the source code is recompiled or the executable program is run on other computers.

How to solve the issue?

If you build and run the program on your computer only, it is okay. But if you want to share it to others, you should empty the PlayCommand property. Because TPlaySound will redetect any available command if that string is empty.


Sorry, I misguided you previously. When I tested your program I wasn't aware that you used TPlaySound by dropping the component on the form. And because if I set breakpoints inside TPlaySound, none of them can be reached (which is caused by the debug option configured on the package). I only needed to add TPlaySound.Create then recompiled and run the program, I heard the sound because it will create a new instance of TPlaySound and force it to detect the PlayCommand. That's why I thought you need to manually call the constructor too.
« Last Edit: May 03, 2018, 02:50:56 pm by Handoko »

wp

  • Hero Member
  • *****
  • Posts: 4965
Re: Strange behaviour ("seeing" files)
« Reply #16 on: May 03, 2018, 09:17:34 am »
if I set breakpoints inside TPlaySound, none of them can be reached (which is cause by the debug option configured on the package).
The easiest way to make a package accessible for the debugger is to go to "Project" > "Project Options" > "Additions and overrides" and to add the Custom Option "-gw2" (or any other type of debug info). Then, when you compile your project all required packages will be recompiled with this debug info, and the breakpoints within the package code will be respected.
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

Handoko

  • Hero Member
  • *****
  • Posts: 2598
  • My goal: build my own game engine using Lazarus
Re: Strange behaviour ("seeing" files)
« Reply #17 on: May 03, 2018, 09:30:30 am »
The easiest way to make a package accessible for the debugger is to go to "Project" > "Project Options" > "Additions and overrides" and to add the Custom Option "-gw2" (or any other type of debug info). Then, when you compile your project all required packages will be recompiled with this debug info, and the breakpoints within the package code will be respected.

Thank you for the info.

justnewbie

  • Full Member
  • ***
  • Posts: 129
Re: Strange behaviour ("seeing" files)
« Reply #18 on: May 03, 2018, 09:44:55 am »
@Handoko: great investigation, valuable info, thanks!

minesadorada

  • Hero Member
  • *****
  • Posts: 569
  • Retired
Re: Strange behaviour ("seeing" files)
« Reply #19 on: May 03, 2018, 02:03:43 pm »
Thanks for the input guys.  I'll take another look at my code in the next week or so and fix some of the problems you have raised.
GPL Apps: Health MonitorRetro Ski Run
OnlinePackageManager Components: LazAutoUpdate, LongTimer, PoweredBy, ScrollText, PlaySound, CryptINI

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus