Recent

Author Topic: [SOLVED] There must be a better way of playing MP3s  (Read 12489 times)

pixelink

  • Hero Member
  • *****
  • Posts: 1269
[SOLVED] There must be a better way of playing MP3s
« on: October 02, 2019, 10:08:01 pm »
I made this simple app to play just MP3 files.
However, All I could come up with was using WMP.

BUT, it is very buggy. The ActiceX control crashes quite often while playing.

Isn't there a simple and easier way to just play an MP3 without installing a huge library?
« Last Edit: October 12, 2019, 10:36:35 pm by pixelink »
Can't Type - Forgetful - Had Stroke = Forgive this old man!
LAZ 4.2.0 •  VSSTUDIO(.Net) 2022 • Win11 • 32G RAM • Nvida RTX 4070 Ti Super

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: There must be a better way of playing MP3s
« Reply #1 on: October 02, 2019, 10:54:08 pm »
Hi!

There is an example how to use the VLC as videoplayer but you can use it the same way as audioplayer:

http://lazplanet.blogspot.com/2018/01/how-to-make-simple-video-player-in.html

Winni

pixelink

  • Hero Member
  • *****
  • Posts: 1269
Re: There must be a better way of playing MP3s
« Reply #2 on: October 02, 2019, 11:27:11 pm »
Hi!

There is an example how to use the VLC as videoplayer but you can use it the same way as audioplayer:

http://lazplanet.blogspot.com/2018/01/how-to-make-simple-video-player-in.html

Winni

Yeah, I am aware of that too, but I want to get away from ActX
Can't Type - Forgetful - Had Stroke = Forgive this old man!
LAZ 4.2.0 •  VSSTUDIO(.Net) 2022 • Win11 • 32G RAM • Nvida RTX 4070 Ti Super

nouzi

  • Sr. Member
  • ****
  • Posts: 326
Re: There must be a better way of playing MP3s
« Reply #3 on: October 02, 2019, 11:34:32 pm »
My English is  bad
Lazarus last version free pascal last version
Lazarus trunk  free pascal trunk 
System : Linux mint  64bit  Windows 7 64bit

pixelink

  • Hero Member
  • *****
  • Posts: 1269
Re: There must be a better way of playing MP3s
« Reply #4 on: October 03, 2019, 12:46:16 am »
See  https://youtu.be/esA0Juwq9EE


Dude... didn't you even read my post above.

I don't want use an actX control.
Can't Type - Forgetful - Had Stroke = Forgive this old man!
LAZ 4.2.0 •  VSSTUDIO(.Net) 2022 • Win11 • 32G RAM • Nvida RTX 4070 Ti Super

lainz

  • Hero Member
  • *****
  • Posts: 4741
  • Web, Desktop & Android developer
    • https://lainz.github.io/
Re: There must be a better way of playing MP3s
« Reply #5 on: October 03, 2019, 01:58:05 am »
Well the other option is installing the huge library, but you don't like that too.  :)

Try UOS package.
https://wiki.freepascal.org/uos
« Last Edit: October 03, 2019, 02:12:11 am by lainz »

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: There must be a better way of playing MP3s
« Reply #6 on: October 03, 2019, 02:28:51 am »
Hi!

I don't know a "small" solution to play mp3 files. I think there is no.

Then the other way round:

Convert your mp3 file to wav. And then it is really simple in Windows:

Code: Pascal  [Select][+][-]
  1. uses ......., MMSystem;
  2.  
  3. begin
  4. sndPlaySound('C:\sounds\holy.wav', snd_Async or snd_NoDefault);
  5. end;
  6.  
  7.  

Winni

Thaddy

  • Hero Member
  • *****
  • Posts: 18729
  • To Europe: simply sell USA bonds: dollar collapses
Re: There must be a better way of playing MP3s
« Reply #7 on: October 03, 2019, 08:27:20 am »
See here : http://www.looprecorder.de/tut_l3codec.php uses the ACM codec.
If Europe sells their USA bonds the USD will collapse. Europe can affort that given average state debts. The USA can't affort that. Just an advice...

wp

  • Hero Member
  • *****
  • Posts: 13353
Re: There must be a better way of playing MP3s
« Reply #8 on: October 03, 2019, 12:48:39 pm »
It will not be possible to play mp3 "out of the box". A small extension is using BASS. You need the bass.dll from https://www.un4seen.com/, free for non-commercial projects, cross-platform. I am attaching a small demo prepared for playing mp3, wav, ogg and flac files (I don't know, BASS maybe can handle more formats, I only checked the mentioned ones). Your code requires only a few lines (my Sound* routines). The sample comes with the bass.dll for 32 bit windows. Note that you must replace it by the 64-bit version if you want to compile the demo for 64 bit, otherwise the demo will abort immediately.

lucamar

  • Hero Member
  • *****
  • Posts: 4217
Re: There must be a better way of playing MP3s
« Reply #9 on: October 03, 2019, 12:54:00 pm »
Another solution which I use in a small "sound library" tool I have is simply to use a TASyncProcess (or just TProcess) to call SoX in play mode. Sox is almost ideal for this because it's small has lots of features (though I just use the "play" part) and is multi-platform.

Drawback, of course, is that you need to install it in the target computer along with your application.

Note that you can use your own preferred command-line player this way; it need not be sox.
« Last Edit: October 03, 2019, 12:56:10 pm by lucamar »
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: There must be a better way of playing MP3s
« Reply #10 on: October 03, 2019, 01:43:06 pm »

Additions to wp:

I would not say that the BASS library is "small".

And as pixellink has his company it must be pointed out that BASS is only free for non-commercial use.

Supported file formats of soundfiles and playlists are

Code: Pascal  [Select][+][-]
  1. SuffixOK : array[0..19]  of string = (  
  2.                                        '.mp3',
  3.                                        '.ogg',
  4.                                        '.wav',
  5.                                        '.mp2',
  6.                                        '.mp1',
  7.                                        '.aiff',
  8.                                        '.m2a',
  9.                                        '.mpa',
  10.                                        '.m1a',
  11.                                        '.mpg',
  12.                                        '.mpeg',
  13.                                        '.aif',
  14.                                        '.mp3pro',
  15.                                        '.bwf',
  16.                                        '.mus',
  17.                                        '.pls',
  18.                                        '.m3u',
  19.                                        '.flac',
  20.                                        '.fla',
  21.                                        '.mp4'  );      

There are extension libraries for CDs, Mixer and a lot more.

It works without any problems on Linux and Windows.

Winni

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12645
  • FPC developer.
Re: There must be a better way of playing MP3s
« Reply #11 on: October 03, 2019, 01:50:49 pm »
This link seems to suggest DirectShow.

wp

  • Hero Member
  • *****
  • Posts: 13353
Re: There must be a better way of playing MP3s
« Reply #12 on: October 03, 2019, 02:05:57 pm »
I would not say that the BASS library is "small".
A dll which is smaller than the forum upload limit of 250 kB *is* small nowadays.

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: There must be a better way of playing MP3s
« Reply #13 on: October 03, 2019, 02:40:02 pm »
Okay. Too old fashioned me.

I started once with 64 k Ram .....

Winni
« Last Edit: October 03, 2019, 02:43:12 pm by winni »

pixelink

  • Hero Member
  • *****
  • Posts: 1269
Re: There must be a better way of playing MP3s
« Reply #14 on: October 03, 2019, 10:05:38 pm »
Thanks everyone... I will check all this out.
Can't Type - Forgetful - Had Stroke = Forgive this old man!
LAZ 4.2.0 •  VSSTUDIO(.Net) 2022 • Win11 • 32G RAM • Nvida RTX 4070 Ti Super

 

TinyPortal © 2005-2018