RcuDev / SimpleMediaPlayer

Simple Android media3 service
Apache License 2.0
111 stars 13 forks source link

Example using SimpleMediaPlayer #2

Closed maxrave-dev closed 1 year ago

maxrave-dev commented 1 year ago

I am beginner, so can you make a tutorial or any example using this Service? Thank you very much

ondrejsml commented 1 year ago

I second this. Example is essential for such project. Please provide minimal viable foolproof guide in Readme. I just need to be able to give the SimpleMediaPlayer file or URL and make it play in given PlayerView. And it needs to create notification when the app is minimized so that it continues playing, that's all. If this can be done in 10 lines of code then your work was successful! :-)

RcuDev commented 1 year ago

Thanks for the feedback.

It's really just an example of how I would implement the media3 service with notifications, rather than how it should be used.

Similarly, all information about its usage is available in the SimpleMediaViewModel.

The loadData method shows how to initialize the player, with one song or with several, and directly all the data provided creates a notification that is also available both in the background and on the lock screen.

In the init of the SimpleMediaViewModel, a collect of the event flow that the service has is also made, in such a way that we can update the UI or do what we want if we have a custom UI player.

In the onUIEvent method it handles user events and passes them on to the SimpleMediaServiceHandler to update its state.

These are only implementation details, since it is also possible to use media 3's own UI player and the events executed by the user will be automatically handled by the media3 service.

I hope these explanations help you. I'll close the issue and if you have any other questions, open another one and I'll review it.

Thank you so much.

maxrave-dev commented 1 year ago

But your code in ViewModel using Jetpack Compose. I don't know how to convert or implement in normal Android Coding Style. Can you make a version of normal Android coding style? Thanks