Recent

Author Topic: TPlaySound - doesn't play sounds and causes error in debug mode.  (Read 8269 times)

Areso

  • New Member
  • *
  • Posts: 21
    • My Github
Hello there.
I have compiled and installed component from CCR 'playsoundpackage'. I picked demo project from component's folder and compile it. It works wonderful under Windows, but under Ubuntu 12.04 32 bit in Lazarus (1.4.4, FPC 2.6.4) in debug mode I have an error:
Quote
    Project PlaySound component demo raised exception class 'EProcess' with message: Cannot execute empty command-line
    At address 819FD07
Highlighted: playsound1.Execute;

Compiled demo project under Ubuntu doesn't crash and doesn't play any sounds. It appears I have a pulseaudio (daemon running and Ubuntu plays any music and sounds well from DE and any other multimedia programms). Is there something I missed?
Lazarus 1.4.4, FPC 2.6.4, target platforms: Windows, Linux (both x86).

minesadorada

  • Sr. Member
  • ****
  • Posts: 452
  • Retired
Re: TPlaySound - doesn't play sounds and causes error in debug mode.
« Reply #1 on: March 17, 2016, 08:16:37 am »
TPlaysound isn't a very clever component :)

Under Linux it tries to play WAV sounds using whatever it can find, and it tries the following commands in order:
play, aplay, paplay,mplayer, CMus, pacat, ffplay, cvlc, canberra-gtk-play.

If I can't find any of those executables on your system it's supposed to show an exception message (rather than crash!)

As for a solution for you; in the uplaysound code, you could add more Linux player executables in the GetNonWindowsPlayCommand function.
GPL Apps: Health MonitorRetro Ski Run
OnlinePackageManager Components: LazAutoUpdate, LongTimer, PoweredBy, ScrollText, PlaySound, CryptINI

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 1228
Re: TPlaySound - doesn't play sounds and causes error in debug mode.
« Reply #2 on: March 17, 2016, 09:09:13 am »
hello,
to play sound files under linux  you can try  acs package or uos library  (work also under windows).

Friendly, J.P
« Last Edit: March 17, 2016, 09:20:17 am by Jurassic Pork »
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

minesadorada

  • Sr. Member
  • ****
  • Posts: 452
  • Retired
Re: TPlaySound - doesn't play sounds and causes error in debug mode.
« Reply #3 on: March 17, 2016, 12:29:58 pm »
At revision: 4566
I added an extra Try-Except to the execute method with an error message in case of failure.

Jurassic Pork has the best solution for Linux use.  TplaySound was only ever a quick-and-dirty way to port a Windows app that uses WAV files to Linux with minimal memory use.

Ideally the Linux part of TPlaysound would use a native sound library as J.P. suggests.  Anyone want to implement it? :)
GPL Apps: Health MonitorRetro Ski Run
OnlinePackageManager Components: LazAutoUpdate, LongTimer, PoweredBy, ScrollText, PlaySound, CryptINI

Areso

  • New Member
  • *
  • Posts: 21
    • My Github
Re: TPlaySound - doesn't play sounds and causes error in debug mode.
« Reply #4 on: March 18, 2016, 02:10:50 pm »
TPlaysound isn't a very clever component :)

Under Linux it tries to play WAV sounds using whatever it can find, and it tries the following commands in order:
play, aplay, paplay,mplayer, CMus, pacat, ffplay, cvlc, canberra-gtk-play.
Thanks. It's very nice of you.
When I first tried your library, I have those errors under Ubuntu:
Quote
uplaysound.pas(218,66) Error: Wrong number of parameters specified for call to "Terminate"
uplaysound.pas(218,66) Error: Wrong number of parameters specified for call to "Terminate"
To get rid of them I corrected your code
Code: Pascal  [Select][+][-]
  1. if SoundPlayerSyncProcess <> nil then SoundPlayerSyncProcess.Terminate;
  2. if SoundPlayerAsyncProcess <> nil then SoundPlayerAsyncProcess.Terminate;
  3.  
with this
Code: Pascal  [Select][+][-]
  1. if SoundPlayerSyncProcess <> nil then SoundPlayerSyncProcess.Terminate(0);
  2. if SoundPlayerAsyncProcess <> nil then SoundPlayerAsyncProcess.Terminate(0);
to make it compile without errors. Probably I get wrong there.
Also, I checked installed apps, installed 'play' (Ubuntu hinted this is from 'sox' package), paplay was already installed, aplay was probably too, and I installed mplayer to be sure. I tried updated lib, but it's still no use: still get the error as above or no sound.
« Last Edit: March 18, 2016, 02:21:17 pm by Areso »
Lazarus 1.4.4, FPC 2.6.4, target platforms: Windows, Linux (both x86).

Areso

  • New Member
  • *
  • Posts: 21
    • My Github
Re: TPlaySound - doesn't play sounds and causes error in debug mode.
« Reply #5 on: March 18, 2016, 02:13:50 pm »
hello,
to play sound files under linux  you can try  acs package or uos library  (work also under windows).

Friendly, J.P
Thank you, I will try latest, because I need a crossplatform code.
Lazarus 1.4.4, FPC 2.6.4, target platforms: Windows, Linux (both x86).

Areso

  • New Member
  • *
  • Posts: 21
    • My Github
Re: TPlaySound - doesn't play sounds and causes error in debug mode.
« Reply #6 on: May 25, 2017, 09:11:00 pm »
At revision: 4566
I added an extra Try-Except to the execute method with an error message in case of failure.

Jurassic Pork has the best solution for Linux use.  TplaySound was only ever a quick-and-dirty way to port a Windows app that uses WAV files to Linux with minimal memory use.

Ideally the Linux part of TPlaysound would use a native sound library as J.P. suggests.  Anyone want to implement it? :)

Did you ever try your library in Arch?
Lazarus 1.4.4, FPC 2.6.4, target platforms: Windows, Linux (both x86).

wp

  • Hero Member
  • *****
  • Posts: 11830
Re: TPlaySound - doesn't play sounds and causes error in debug mode.
« Reply #7 on: May 26, 2017, 09:15:45 am »
TPlaysound isn't a very clever component
I fully disagree. It is very clever instead because it looks for what's is already there instead of loading tons of dependencies into the component or program.

minesadorada

  • Sr. Member
  • ****
  • Posts: 452
  • Retired
Re: TPlaySound - doesn't play sounds and causes error in debug mode.
« Reply #8 on: May 26, 2017, 08:24:40 pm »
TPlaysound isn't a very clever component
I fully disagree. It is very clever instead because it looks for what's is already there instead of loading tons of dependencies into the component or program.
Thank you for the complement @wp.  Coming from you, it has weight.  It's true that I looked at native libraries and thought - why; when all I need to do is play a Windows WAV file in Linux?

I have always been a 'boots and braces' programmer - looking for solutions that are simple rather than 'clever'.

My submitted components are not clever, but at least I contribute without ego and hope for/expect improvements from more clever programmers. (and always younger - bah!)

I wish there was more collaboration among the Lazarus community to improve open source code and components.  I remember working with (the late) @bigchimp on Health Monitor and LazAutoUpdate and learning a lot about FireBird integration and threading code.

In the absence of a public Lazarus repository, I often copy/paste forum code into text-files which I can re-use.  I'm sure other folk do it also.

More public collaboration and code-sharing would benefit us all.  I made a new category in the wiki called 'code snippets' for this purpose.

There are perceived issues with 'ownership' of open-source code which I think is often ridiculous.

To me - a liberal license says: "improve me please!"

I'll be honest - all my submitted components need improvement.  Anyone up for it?

I will always give copious credit in source code.  I am retired and in no need of a CV - so feel free!
« Last Edit: May 26, 2017, 09:19:09 pm by minesadorada »
GPL Apps: Health MonitorRetro Ski Run
OnlinePackageManager Components: LazAutoUpdate, LongTimer, PoweredBy, ScrollText, PlaySound, CryptINI

 

TinyPortal © 2005-2018