GSOC 2022: Adding BrainzPlayer in Android App

Personal Information

Name: Ashutosh Aswal

IRC nick: yellowhatpro

Email: yellowhatpro3119@gmail.com

Github: yellowhatpro

Time Zone: UTC+05:30

BrainzPlayer in Android App

Project Overview

MusicBrainz Android app has got some nice features that showcase various Brainz abilities.

Currently, the app lacks the Brainz Player feature, which if integrated, will be a great enhancement. This feature will let users play songs locally on their phones, create playlists, easily tag their songs and let them add like/hate feedback to songs.

This project aims to integrate the BrainzPlayer feature into the android app.

My contributions up till now:

My PRs: Check Out

My Commits: Check Out

Implementation

1. Implement a media player which can play songs present in the user’s local storage.

This requires Android’s media3 libraries. Primarily, we will be using following libraries:

  1. media3-exoplayer : offers simple functions for playing media via the ExoPlayer.

  2. media3-ui : mainly contains views for displaying controls for playback in the UI.

  3. media3-session :offers objects to create and interact with media sessions.

image

MediaController and Exoplayer implement the Player interface that can be used to communicate with UI Components.

The Player interface avoids the need for connecting components that reduces the amount of code to be written and simplifies things.

2. Allow the user to add songs to the queue and handle the lifecycle such that songs can be played even after the fragments etc are changed.

This mainly requires MediaBrowserServiceCompat extended service , that enables apps to browse media content. This service class helps in playing the songs, handling the lifecycle of the songs so that they can be played in the background.

For queuing songs in a playlist, we will be needing Room DAOs that give us an interface to access playlist items.

3. Put the songs being currently played in the notification tray

With the help of Media Controls, we can give a dedicated space for controlling our Brainz Player’s media playbacks and media resumptions.

For implementing media controls, we will be using MediaStyle class object with MediaSession token.

Couple more features that will be available when the user provides their ListenBrainz token in the settings.These features are:

4. Allow the user to like/dislike the song on LB

We can use ListenBrainz Recording Recommendation Feedback APIs .

These API endpoints allow for the submission and retrieval of feedback for a user’s recordings.

We can:

  • post a recommendation using endpoint POST /1/recommendation/feedback/submit

with provided authorization header and the feedback in the payload.

  • remove the feedback we gave by POST /1/recommendation/feedback/delete

with provided authorization header and the recording mbid in the payload.

5. Allow the user to open the respective link to MB

With the Brainz Player integrated into the MusicBrainz app itself, one can search for the entity directly in the MusicBrainz data from the app itself.

Timeline

Following is the timeline for the 350 hours of GSoC coding period I’ll be devoted to:

Pre-Community Bonding Period (April):

Migrating existing features from XML-based layouts to Compose.

Community Bonding Period (May-June):

Continue working on compose migration. Discuss with my mentors the new UI for the app that blends well with Brainz Player . Work on the UI redesign implementation.

Week 1,2

Setting up the services and libraries required for the BrainzPlayer implementation.

This includes setting up Exoplayer, MediaSessionCallback, MediaController, a bit of dagger for exoplayer, and the Service for the BP.

Week 3

Getting the player the access to the local storage using MediaStore APIs.

Week 4

Setting up Media Controls to implement notifications feature.

Week 5

Implement the Player interface that deals the playback commands, like play, pause, skip etc.

Week 6,7

Setup useful modals, repositories and databases.

Repositories and DAOs are to be made for playlists to implement the songs queues, and to implement other features like history of songs played, most played songs.

Week 8

Setup required ViewModels.

Week 9

Work on finalized UI of the Brainz Player, and start implementing it.

Week 10,11

BUGS FIXING: Since UI and Services components are expected to cover by this time, it will be time to test them all in various conditions.

Discovering and fixing as much bugs as possible in this period.

Week 12

Adding features specific to ListenBrainz, like adding feature to like/hate the listens.

I will be doing documentation and testing side by side with the addition of new features.

Stretch goals

Adding more features to BrainzPlayer that includes user customizable playback speed and play features, mono audio and a blacklist feature to block music source from specific directories.

Also, get the work approved by my mentors.

Detailed Information About Yourself

My name is Ashutosh Aswal. I am a sophomore pursuing Bachelors in CSE from Punjab Engineering College , Chandigarh, India.

Tell us about the computer(s) you have available for working on your SoC project!

I have my HP Pavilion ec0101ax, with Ryzen 5 3550H and 24 gigs of RAM.

When did you first start programming?

I began my programming journey with C++ in 11th grade.

What type of music do you listen to? (Please list a series of MBIDs as examples.)

I mostly listen to Indie music artists like The Local Train, Nikhil D’Souza, Anuj Jain etc.

What aspects of the project you’re applying for the interest you the most?

I love android development and listening to music, so there’s no better project than MusicBrainz that will keep me engaged and happy.

Have you ever used MusicBrainz to tag your files?

Yes, I have.

Have you contributed to other Open Source projects? If so, which projects and can we see some of your code?

I have participated in a few open-source events.

The one that describes my work best is Sampoorna.

What sorts of programming projects have you done on your own time?

I have done mostly android projects. I do have an interest in various other domains and have tried a few small projects before like python discord bot, web scraping, game development using Pygame and Unity, and a bit of frontend web-dev.

How much time do you have available, and how would you plan to use it?

I will be providing ~35 hours per week to the project. There maybe few ups and downs due to exams and ongoing college curriculum (We are not having vacations, summer semester it is 〒▽〒).

3 Likes

Thanks for the proposal.
In general, the idea looks well defined to me. I do think we should discuss more and rewrite the timeline you suggest. I’m not sure whether it will take the first 2 weeks just to setup the services and libraries. If so, please elaborate more on that point. Similarly, Week 6-7 should be elaborated more. Can we implement the tests side by side instead of pushing them to week 10-11 and 13?
Also, documentation should be done side by side as the work progresses. We can keep a period for verifying it in the last week.
Other than that you suggest to be working around 35 hours per week which exceeds the 350 hour timeline. Maybe, add some stretch goals to the timeline?
But yeah, things look good! :slight_smile:

2 Likes

Thanks for the valuable suggestions sir, I have made the required changes now. Please do have a look now O(∩_∩)O

1 Like

The proposal looks good to me. I have no further comments on it :slight_smile:

Thanks and all the best!

1 Like

Thank you sir (๑•̀ㅂ•́)و✧