Recent

Author Topic: Playing WAV files in Windows and Linux  (Read 7966 times)

minesadorada

  • Sr. Member
  • ****
  • Posts: 452
  • Retired
Playing WAV files in Windows and Linux
« on: September 13, 2014, 11:21:06 am »
I was looking for a simple way to play a WAV file, Sync and ASync that would work in Windows and Linux.

After a lot of searching around, I found lots of complicated solutions which were overkill for the task, so I made some simple code that did the job without fuss.

The code is wrapped into a component which you can find in the CCR  (playsoundpackage) and the Wiki page is here

Tested on Windows Vista 32-bit and Linux Mint 64-bit.  Lazarus 1.2.4, FPC 2.6.4

Improvements welcome..
« Last Edit: September 13, 2014, 12:54:45 pm by minesadorada »
GPL Apps: Health MonitorRetro Ski Run
OnlinePackageManager Components: LazAutoUpdate, LongTimer, PoweredBy, ScrollText, PlaySound, CryptINI

Leledumbo

  • Hero Member
  • *****
  • Posts: 8744
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Playing WAV files in Windows and Linux
« Reply #1 on: September 13, 2014, 02:33:35 pm »
Nice, at least it should work for Linux. ALSA is almost always built-in so I guess aplay will always be there. However, don't you think adding PlayerCmd property is better? Also, aplay is not limited to play WAV only ;)

minesadorada

  • Sr. Member
  • ****
  • Posts: 452
  • Retired
Re: Playing WAV files in Windows and Linux
« Reply #2 on: September 13, 2014, 04:47:30 pm »
Nice, at least it should work for Linux.
Thanks - that was the intent.  I found fpsound (the simplest alternative) didn't work in 64-bit Linux BTW.
ALSA is almost always built-in so I guess aplay will always be there.
I am a dilettante in Linux.  That's why I asked for help/improvements.  It would be good if FPC could access the same low-level drivers as all those players seem to do.
However, don't you think adding PlayerCmd property is better? Also, aplay is not limited to play WAV only ;)
I wanted to keep it simple for Linux newbies like me that only know sndPlaySnd and WAV files, but I fully take your point.  As it is, it could play other formats. Feel free to improve my simple code to a better alternative that could accommodate more platforms.
GPL Apps: Health MonitorRetro Ski Run
OnlinePackageManager Components: LazAutoUpdate, LongTimer, PoweredBy, ScrollText, PlaySound, CryptINI

minesadorada

  • Sr. Member
  • ****
  • Posts: 452
  • Retired
Re: Playing WAV files in Windows and Linux
« Reply #3 on: September 14, 2014, 05:07:30 pm »
V.0.0.3
Added the PlayCommand property to the component.
OnCreate it does all the scanning and picks the first available choice into the property, which the developer can then easily over-ride.

Thanks for the suggestion Leledumbo.
GPL Apps: Health MonitorRetro Ski Run
OnlinePackageManager Components: LazAutoUpdate, LongTimer, PoweredBy, ScrollText, PlaySound, CryptINI

Leonnearlo

  • Newbie
  • Posts: 1
Re: Playing WAV files in Windows and Linux
« Reply #4 on: December 01, 2017, 11:33:14 am »
How about converting the WAV files to Windows and Linux friendly formats with a good converter? This HEVC converter can deal with both video and audio conversion. Help it works for you.

 

TinyPortal © 2005-2018