Page 1 of 1
pb-macos-audioplayer
Posted: Sun Apr 18, 2021 2:05 pm
by deseven
A simple wrapper built around macOS AVAudioPlayer. Totally asynchronous, but NOT threadsafe. Should support mp3, m4a, aac, wav, aiff, alac natively and everything else with the help of FFmpeg.
Basic usage:
Code: Select all
IncludeFile "audioplayer.pbi"
If audioplayer::load(0,"file.mp3")
Debug "Playing file " + audioplayer::getPath(0)
Debug "File duration: " + StrD(audioplayer::getDuration(0)) + " sec"
audioplayer::play(0)
Delay(5100)
audioplayer::pause(0)
Debug "Played: " + StrD(audioplayer::getCurrentTime(0)) + " sec"
audioplayer::stop(0)
audioplayer::free(0)
EndIf
The most recent version and more complex example can be found on github:
https://github.com/deseven/pb-macos-audioplayer
Re: pb-macos-audioplayer
Posted: Sun Apr 18, 2021 4:36 pm
by mrbungle
thank you!
Re: pb-macos-audioplayer
Posted: Tue Apr 20, 2021 10:52 pm
by mk-soft
Hello Deseven,
if you finally use the return value for Boolean in procedures no longer "Procedure.b foo()", but simply "Procedure foo()", everything is good.
If you use type ".b" (byte), it must be additionally filtered in the ASM code and thus generates more unnecessary ASM code.

Re: pb-macos-audioplayer
Posted: Tue Apr 20, 2021 11:04 pm
by deseven
Ah, thanks for the clarification, I'm not even sure where i got this habit from.
Updated the code.
Re: pb-macos-audioplayer
Posted: Thu Oct 07, 2021 1:45 pm
by deseven
In the new version I decided to get rid of PB sound library, since it's completely broken, see:
viewtopic.php?f=24&t=77779
viewtopic.php?f=24&t=78013
viewtopic.php?f=24&t=77630
And with the amount of attention macOS build of PB gets these days it's very likely that it won't be fixed for several years or at all.
So this module now uses FFmpeg to cover formats not supported natively by AVAudioPlayer, such as FLAC or OGG. It's totally optional and if you don't need to play those then nothing needs to be done
More info in the readme -
https://github.com/deseven/pb-macos-aud ... /README.md
Re: pb-macos-audioplayer
Posted: Wed Nov 10, 2021 4:27 pm
by deseven
Updated once again, you can now create multiple instances by defining the ID or just passing #PB_Any as a first argument.
Re: pb-macos-audioplayer
Posted: Thu Nov 11, 2021 12:36 am
by mrbungle
Thank you for making this!
Re: pb-macos-audioplayer
Posted: Thu Nov 11, 2021 4:46 am
by kenmo
I don't have an *immediate* need for this, but still, thank you deseven!
Re: pb-macos-audioplayer
Posted: Thu Nov 11, 2021 11:05 am
by jamirokwai
Great! Thanks, that may be useful in the near future

Re: pb-macos-audioplayer
Posted: Thu Nov 11, 2021 4:02 pm
by deseven
Thanks for the kind words, guys!
I mostly wrote it for my
macOS music player, but it's great if someone else can find it useful.
Re: pb-macos-audioplayer
Posted: Fri Nov 12, 2021 1:09 pm
by jamirokwai
Hi deseven,
I just checked out your player. Nice!
However, in main.pb, PB 5.7.3 throws the error "Line 146: setCurrentTime(): Incorrect number of parameters.". Maybe, the player-component I downloaded from GItHub is too new...
One perfect addition would be internet-radio stations by URL, maybe using BASS? This way, I could ditch iTunes

And you could let users show the player, where ffmpeg and other tools and libraries reside.
Re: pb-macos-audioplayer
Posted: Fri Nov 12, 2021 2:15 pm
by deseven
Hi. Glad you liked it
jamirokwai wrote: Fri Nov 12, 2021 1:09 pm
However, in main.pb, PB 5.7.3 throws the error "Line 146: setCurrentTime(): Incorrect number of parameters.". Maybe, the player-component I downloaded from GItHub is too new...
Yeah, I've uploaded the latest changes for ichm, now it should be buildable with the latest version of all modules.
jamirokwai wrote: Fri Nov 12, 2021 1:09 pm
One perfect addition would be internet-radio stations by URL, maybe using BASS? This way, I could ditch iTunes
Sorry, no plans for that at all, there are many players for macOS that already do that perfectly. Maybe someday, but definitely not in the near future, there are many other things I want to introduce as soon as possible.
jamirokwai wrote: Fri Nov 12, 2021 1:09 pm
And you could let users show the player, where ffmpeg and other tools and libraries reside.
Not sure what you mean by this, can you explain?
Re: pb-macos-audioplayer
Posted: Fri Nov 12, 2021 3:21 pm
by jamirokwai
deseven wrote: Fri Nov 12, 2021 2:15 pm
Hi. Glad you liked it
jamirokwai wrote: Fri Nov 12, 2021 1:09 pm
However, in main.pb, PB 5.7.3 throws the error "Line 146: setCurrentTime(): Incorrect number of parameters.". Maybe, the player-component I downloaded from GItHub is too new...
Yeah, I've uploaded the latest changes for ichm, now it should be buildable with the latest version of all modules.
Great. I will have a look!
jamirokwai wrote: Fri Nov 12, 2021 1:09 pm
One perfect addition would be internet-radio stations by URL, maybe using BASS? This way, I could ditch iTunes
Sorry, no plans for that at all, there are many players for macOS that already do that perfectly. Maybe someday, but definitely not in the near future, there are many other things I want to introduce as soon as possible.
Ok. Sounds reasonable

Maybe, I have some time to look into it. After all, you open sourced the player.
jamirokwai wrote: Fri Nov 12, 2021 1:09 pm
And you could let users show the player, where ffmpeg and other tools and libraries reside.
Not sure what you mean by this, can you explain?
You open preferences window, and if your player didn't find the appropriate ffmpeg or lyrics-lib, etc, it opens a OpenFileRequester() and lets the user point to the binary.
Re: pb-macos-audioplayer
Posted: Fri Nov 12, 2021 3:50 pm
by deseven
jamirokwai wrote: Fri Nov 12, 2021 3:21 pm
You open preferences window, and if your player didn't find the appropriate ffmpeg or lyrics-lib, etc, it opens a OpenFileRequester() and lets the user point to the binary.
Ah, I see.
FFmpeg is included in the release, it's a part of the distribution (releases are here -
https://github.com/deseven/iCanHazMusic/releases)
External lyrics module is a very temporary solution, I plan to get rid of it in time. Ideally the application should be self-sufficient.