Recent

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

pixelink

  • Hero Member
  • *****
  • Posts: 1243
    • Pixelink Software
[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!

Pixelink Media
LAZ 2.08 •  VSSTUDIO(.Net) 2019 • Win10 • 16G RAM • Nivida GForce RTX 2060

winni

  • Hero Member
  • *****
  • Posts: 1809
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: 1243
    • Pixelink Software
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!

Pixelink Media
LAZ 2.08 •  VSSTUDIO(.Net) 2019 • Win10 • 16G RAM • Nivida GForce RTX 2060

nouzi

  • Full Member
  • ***
  • Posts: 179
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 2.0.6 free pascal 3.0.4
Lazarus trunk  free pascal trunk 
System : linux mint 19.3 64bit  windows 7 64bit

pixelink

  • Hero Member
  • *****
  • Posts: 1243
    • Pixelink Software
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!

Pixelink Media
LAZ 2.08 •  VSSTUDIO(.Net) 2019 • Win10 • 16G RAM • Nivida GForce RTX 2060

lainz

  • Hero Member
  • *****
  • Posts: 3706
  • Leandro Diaz
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: 1809
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: 10470
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.
When you ask a question that is actually answered in the documentation, you are either lazy or a moron.

wp

  • Hero Member
  • *****
  • Posts: 7551
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.
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

lucamar

  • Hero Member
  • *****
  • Posts: 3025
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 2.0.8/FPC 3.0.4 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

winni

  • Hero Member
  • *****
  • Posts: 1809
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

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 8730
  • 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: 7551
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.
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

winni

  • Hero Member
  • *****
  • Posts: 1809
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: 1243
    • Pixelink Software
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!

Pixelink Media
LAZ 2.08 •  VSSTUDIO(.Net) 2019 • Win10 • 16G RAM • Nivida GForce RTX 2060

 

TinyPortal © 2005-2018