markjamesm / MusicSharp

MusicSharp is a lightweight TUI music player written in C#.
https://markjames.dev/blog/developing-a-cli-music-player-csharp/
GNU General Public License v3.0
57 stars 11 forks source link

Write an implementation of IPlayer for Linux or Mac #8

Open markjamesm opened 4 years ago

markjamesm commented 4 years ago

MusicSharp currently isn't cross-platform, but the player class is loosely coupled to the cross-platform GUI by using Dependency Injection (DI). Currently, the GUI class injects the Winplayer class through constructor injection to handle audio processing via the Windows-only NAudio library.

Conceivably, one could write a Linux or MacOS player class which conforms to the IPlayer interface using a cross-platform C# audio library such as Bassoon.

marijnz0r commented 4 years ago

I tried to use Bassoon for the Linux version, but the problem is this:

libsndfile doesn't support MP3 reading (due to patent concerns), so it isn't supported at the moment. It should be added soon enough to Bassoon IIRC, the patents did expire, so it's possible that MP3 decoding may be added to libsndfile in the near future.

Check http://www.mega-nerd.com/libsndfile/FAQ.html#Q020 as well.

See https://github.com/libsndfile/libsndfile/issues/258 for the issue.

See https://github.com/libsndfile/libsndfile/pull/499 for the pull request.

markjamesm commented 3 years ago

I also tried creating a cross-platform branch to test using SharpAudio for the cross-platform library:

https://github.com/markjamesm/MusicSharp/tree/cross-platform

Basic audio playback works on Windows (with some bugs) but attempting to play a file in Linux and Mac causes a crash.

markjamesm commented 11 months ago

According to this this comment by Mark Heath (creator of the NAudio library):

I am in discussions with someone who has offered to contribute a Linux IWavePlayer implementation which would be a great addition to NAudio.

So hopefully this means Linux audio support sometime in the near future.