Lazarus

Programming => Graphics and Multimedia => Audio and Video => Topic started by: pixelink on October 02, 2019, 10:08:01 pm

Title: [SOLVED] There must be a better way of playing MP3s
Post by: pixelink 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?
Title: Re: There must be a better way of playing MP3s
Post by: winni 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 (http://lazplanet.blogspot.com/2018/01/how-to-make-simple-video-player-in.html)

Winni
Title: Re: There must be a better way of playing MP3s
Post by: pixelink 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 (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
Title: Re: There must be a better way of playing MP3s
Post by: nouzi on October 02, 2019, 11:34:32 pm
See  https://youtu.be/esA0Juwq9EE 
Title: Re: There must be a better way of playing MP3s
Post by: pixelink 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.
Title: Re: There must be a better way of playing MP3s
Post by: lainz 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
Title: Re: There must be a better way of playing MP3s
Post by: winni 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
Title: Re: There must be a better way of playing MP3s
Post by: Thaddy on October 03, 2019, 08:27:20 am
See here : http://www.looprecorder.de/tut_l3codec.php uses the ACM codec.
Title: Re: There must be a better way of playing MP3s
Post by: wp 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.
Title: Re: There must be a better way of playing MP3s
Post by: lucamar 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.
Title: Re: There must be a better way of playing MP3s
Post by: winni 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
Title: Re: There must be a better way of playing MP3s
Post by: marcov on October 03, 2019, 01:50:49 pm
This link  (https://www.pascalgamedevelopment.com/archive/index.php/t-4833.html) seems to suggest DirectShow.
Title: Re: There must be a better way of playing MP3s
Post by: wp 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.
Title: Re: There must be a better way of playing MP3s
Post by: winni on October 03, 2019, 02:40:02 pm
Okay. Too old fashioned me.

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

Winni
Title: Re: There must be a better way of playing MP3s
Post by: pixelink on October 03, 2019, 10:05:38 pm
Thanks everyone... I will check all this out.
Title: Re: There must be a better way of playing MP3s
Post by: pixelink on October 10, 2019, 08:51:31 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.

Okay WP, I got this working.

It seems all I need is a Pause function.
I tried SoundPause(FChannel, FileNameEdit1.FileName);
But get error "identifer not found"

Is there a page docs somewhere so I can paw over it??
I don't see one on their site.

UPDATE:
Got this to work... but stops the playback and not pause it. So, when you click play again it starts over.

Code: Pascal  [Select][+][-]
  1. BASS_ChannelPause(FChannel);

Thanks
Title: Re: There must be a better way of playing MP3s
Post by: pixelink on October 10, 2019, 08:54:50 pm
Well the other option is installing the huge library, but you don't like that too.  :)

Try UOS package.
https://wiki.freepascal.org/uos

I downloaded this and only the samples without fpGUI works.
I can't get aggPas installed for fpgui, gives me errors.. plus it is really old.

But, the UOS may work if I can't get any further with BASS.

It may be big, but the WMP active X is just to buggy, Crashes all the time. I did research and WMP crash is a well known issue.
Don't want to use wmp.dll
Title: Re: There must be a better way of playing MP3s
Post by: winni on October 10, 2019, 09:17:09 pm
Hi!

Pause in Bass is very simple. Just
Code: Pascal  [Select][+][-]
  1.  
  2. BASS_ChannelPause(Stream);

And start it again with

Code: Pascal  [Select][+][-]
  1. BASS_ChannelPlay(Stream, False);

All the routines are documented in the bass.chm in the package.

Winni


Title: Re: There must be a better way of playing MP3s
Post by: pixelink on October 10, 2019, 09:57:44 pm
Hi!

Pause in Bass is very simple. Just
Code: Pascal  [Select][+][-]
  1.  
  2. BASS_ChannelPause(Stream);

And start it again with

Code: Pascal  [Select][+][-]
  1. BASS_ChannelPlay(Stream, False);

All the routines are documented in the bass.chm in the package.

Winni


Perfect... I was close.
I had the play correct.

However, I had for my resume button play, True instead of false

This will work for now.

I did find the docs and I am in the process of converting the delphi examples to LAZ so I can see what BASS does.


THANKS
Title: Re: There must be a better way of playing MP3s
Post by: pixelink on October 12, 2019, 10:36:19 pm
Well, I was able to get the BASS system working
Here is a screenshot of the app.

THANKS FOR EVERYONES HELP!!!
Title: Re: There must be a better way of playing MP3s
Post by: alaa123456789 on July 03, 2020, 05:49:38 pm
Well, I was able to get the BASS system working
Here is a screenshot of the app.

THANKS FOR EVERYONES HELP!!!

could you please share the code

thanks
Title: Re: [SOLVED] There must be a better way of playing MP3s
Post by: alaa123456789 on July 06, 2020, 06:56:51 pm
hey guys

you could have this advance application from this link

https://youtu.be/85kCaxS_Kig

thanks
TinyPortal © 2005-2018