Building a .Net Core Mp3 player with Avalonia

2017-07-23.png

Recently I started a new job where all the workstations were mac’s. This presented a situation where some of the programs I use every day were no longer available as they do not have macos versions.  One of these hit me really hard, MusicBee the media player I use to listen to music while I worked is a windows only application and I really don’t like itunes. I tired a few other solutions and did not find one that met my standards of what I want in a media player, so I did what any developer would do: decided to make my own.

So the gears started to turn in my head, how will I make such a program? Macos has mono and there are some UI libraries for it but the results have a very particular ‘gtk look’ and that would also mean I would need to install mono on any windows machine I want to run it on later. A few months back I read on hacker news someone was attempting to create a cross platform UI library for .netcore called Avalonia and thought it could be a good place to start.

This would be my first .net core application and like many people coming from the full .net framework I had to wade through the seas of nuget packages hoping that I could find libraries that had been ported to .net core or .net standard. After trying a few out in various test applications I found a id3 tag framework, a audio playback framework, a embedded db framework which all had support.

Avalonia so far seems to do the job but does have some rough edges as its currently in a alpha state. The main downside I have had so far is the lack of a designer. While in past jobs I have written all my XAML by hand and not with any designers like the one in visual studio or blend I have always used the split view to see what the changes looked like. Without this it has led me to making small changes, building and running the program to see if I placed things where I want them and they look good. This process has slowed me down dramatically. Another thing is the lack of documentation which once again can be forgiven a bit since it is an alpha release. To find out how things work has involved reading the code and tests on their github page. Platform differences are also noticeable when it is running on windows and on macos. For example the list box vertical spacing seems to be different on mac where the text appears more towards the top of each row rather than the center. In general Avalonia does work and runs pretty smoothly, I’d recommend using it.

I don’t know where I’ll end with this project. When things become a bit more refined I might put the code up on github. MusicBee after many years of trying different mp3 players became my default but it is closed source and only runs on windows. Maybe people would appreciate something a little different.

Leave a comment