android music player ExoPlayer

android music player ExoPlayer

RxMusicPlayer

An android music player using ExoPlayer and RxJava2.

Introduction

RxMusicPlayer is a part of our music player in Orfium new android application. Using subjects and sealed classes, media manager can emit the latest state of exoplayer, allowing views and classes to observe it and react according to its state, without the need to have a reference to the media manager or exoplayer itself.

Initialization

Before start using RxMusicPlayer you have to call the method that starts the Media Service

Usage

Create a Media item class that contains all the necessary data information and call playStop extension function on it.

Example:

You can also check if a Media item is currently playing

or add/remove it from queue

If you wish not to use the extension functions you can use RxMusicPlayer action to emit a new action that the MediaManager will handle. Here is the full list of actions that the MediaManager can handle

Example:

To observe the changes on media player state just subscribe to RxMusicPlayer state, that will emit the current PlaybackState along with the current Media item on Queue. When a new observer subscribes to RxMusicPlayer state, it immediately gets notified about the current PlaybackState. You can find all states here

RxMusicPlayer allows you to observe changes in media queue list and the current playback position of exoplayer

Setup

The latest libary version is 

Add the JitPack repository in your build.gradle (top level module):

And add the dependency in the build.gradle of the module:

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

(Visited 69 times, 1 visits today)

You May Also Like

About the Author: Android Developer

This is Mohammad I am Android Application Developer. I am the founder of Android Tutorial Online blog. I am programming lover and professional blogger from India. I spend most of my time doing programming and helping other programmers. This Android tutorial online blog for learning and share Android code.
My Chatbot
Powered by Replace Me