How do I play an MP3 file using Lazarus on macOS - macos

I'd like to be able to play an MP3 file programmatically, using Lazarus on macOS.
Lazarus 2.0 (fpc 3.0.4) on macOS is working great for me, but one thing I cannot manage to do is to play an MP3 file programmatically.
I managed to compile and run the OALSoundManager demo project, but only WAV files can be played that way.
I spent several hours following various leads from the freepascal forum, but I still could not manage to do the basic play operations:
Load an MP3 file
Start playing it.
Get the current playing position (e.g. during OnTimer).
Be notified when it stops.
I'm OK with using any common library. Of course the less dependencies the better.
Once I can play the file I can figure out the rest, but it would be great if the example also showed:
Start playing from a given time position
Pause/Restart
Thank you very much for any help!

You might be able to use Castle Engine and OpenAL.
You can install Castle Engine from with-in Lazarus. In the main menu under "Package" -> "Online Package Manager" you will be able to filter and install "castle".
Then you should be able to open the example project:
https://github.com/castle-engine/castle-engine/blob/master/examples/audio/alplay.lpr
Goodluck,

Related

Simple effect processing in AudioKit example for MacOS files needed

I have a unique filter that I want to use while playing Audio files on MacOS and am trying to start based on an AudioKit example whereby I just replace a current effect with new code with my filtering. However, I can't find an example that is close to what I want and the amount of effort required to do from scratch is a bit too much. Is anyone aware of such examples that I can use? I've looked through all of the examples on AudioKit they either just play audio files or have effects but assume microphone data. Thanks
In the Developer directory of AudioKit you'll find an example called "ExtendingAudioKit" which is probably going to be your best template for how to set up a project that uses AudioKit for the base, but allows you to develop custom DSP external to AudioKit.

How do I use OGG with SDL_Mixer?

I can't seem to get SDL_Mixer to initialize with OGG support enabled. I know that I must link with libogg, libvorbis and libvorbisfile but it still won't work. I have .dylibs, .frameworks and .as of these three libraries and I've tried them all.
I'm copying the dylibs/frameworks into the Frameworks folder of the app package in the build phases tab.
I have Runpath Search Paths set to #executable_path/../Frameworks in the build settings tab.
But Mix_Init(MIX_INIT_OGG) keeps returning the error OGG support not available.
I'm using the latest Homebrew versions of all of the mentioned libraries. I'm not sure what else to try.
I have a finished game with 300MB of wavs as the music.
Update
I’ve managed to mix some Objective C with C++ and get some sound playing with AVAudioPlayer but it’s horrendous code. I’m having to cast to void * to make sure my music player class is compatible with my C++ code base. The garbage collector is so annoying. All it does is get in your way. You have to fight it with bridge casts.
I’d really like to use SDL_Mixer or a simple C library.
I got the Objective C music player fully implemented but I just can’t stand Objective C. I found a brilliant library called stb_vorbis. I’ve used a few of the other stb libraries so I knew this one would be great. Playing the audio data from this library is actually pretty easy. All I really had to do was call stb_vorbis_get_samples_short_interleaved inside of SDL2’s audio callback. I didn’t have to do any mixing because I only need to play music. The implementation was so simple that it actually worked perfectly the first time I ran it! This because stb_vorbis and SDL2 are both C libraries so they just make sense (unlike Objective C which should be burned).
TL;DR
If you just want to play music and either can’t use SDL_Mixer or don’t want to use SDL_Mixer then you can just feed the data from stb_vorbis into SDL2’s audio callback.

Xamarin.Forms video streaming library that supports RTSP video feeds

I am using Plugin.MediaManager NuGet package to provide cross-platform video player for my app. However, it does not support playing RTSP video streams. Is there any other library that supports this?
I have looked around and the most common ones are platform-specific libraries such as KXmovie and Managed Media Aggregation but I am a little intimidated by the thought of having to port and/or recompile them.
The best case is if there is a Xamarin.Forms compatible NuGet package available. Failing that, an iOS library that requires binding, but not recompiling. As a last resort, something that needs to be compiled and linking manually, but works out of the box.
OK so the resounding conclusion is that one does not exist with Xamarin bindings. I will start with this project on GitHub and see if I can compile and generate the bindings myself.
A bit late, but there is now. LibVLCSharp supports RTSP (and many other stuff).

Playing audio file with golang

How one would play audio file in go language?
I have function and want sound to be played as notification when event happens.
I could not find anything about playing sound file in go lang just some web browser based music players but it wasnt helpful too much.
You could use the PortAudio Go bindings (go get github.com/gordonklaus/portaudio) for this.
You will have to build or install PortAudio on your system. Consult http://portaudio.com/docs/v19-doxydocs/tutorial_start.html for this.
A complete example for playing back a sound file is located at https://github.com/gordonklaus/portaudio/blob/master/examples/play.go
If it's an MP3 file, you can use go-mp3 Library. go-mp3 is popular library to play MP3; MP3 decoder is in pure Go.
Or this one, https://github.com/faiface/beep. Beep uses go-mp3 under the hood

Stream audio on Mac

I have been using AVAudioPlayer on the iPhone and iPad. I can't find anything that comes close on the Mac. Does anyone know where to find a library like that ?
What I want is a library that can stream songs from the internet so the user does not need to download the whole song.
NSSound can play songs from the internet but it does not stream, it just downloads the song and starts to play.
I know ffmpeg works on the Mac and supports streaming. As an added bonus, it works on Linux and Windows too.
Matt Gallagher has a series of articles on his website regarding this, streaming audio on the iPhone and on the Mac as well. He has this project posted on github as well.
It's pretty popular and I've personally used it on an iPhone project and it worked well. It comes with an included Mac sample project which also works well.

Resources