abarisain / dmix

A modern MPD Client for Android.
Apache License 2.0
587 stars 205 forks source link

Use Exoplayer instead of MediaPlayer #802

Open noahhaon opened 8 years ago

noahhaon commented 8 years ago

MediaPlayer has lots of issues and quality varies a lot across android versions, and really limits options like setting buffer size, etc. Instead, perhaps investigate the use of Exoplayer and only fall back to MediaPlayer on very old API versions.

https://google.github.io/ExoPlayer/guide.html

abarisain commented 8 years ago

That would be a nice enhancement, even more since ExoPlayer is maintained by google

noahhaon commented 8 years ago

It is their recommended upgrade path from MediaPlayer, and would give the opportunity to resolve a lot of reported dmix issues w/r/t buffer control, and get rid of some hacks to deal with MediaPlayer issues.

I don't have a tremendous amount of Android dev experience, but I am experienced with Java development and would be happy to contribute. There are some other usability changes I would like to make to playlist management that might be worth incorporating upstream.

@abarisain Do you have a development/emulator environment for Ubuntu/Debian that you prefer for your work on this project?

abarisain commented 8 years ago

I think changes to the playlist management should be discussed prior to implementing: there's a chance that we don't see the project the same way, and I'd hate for you to sumbit a PR that we won't merge.

I too think that @avuton might be interested in the ExoPlayer migration. He worked around his fair share of MediaPlayer bugs ;)

Anyway, for development, you should use Android Studio. MPDroid only supports gradle as its build system, so you can work with vim/emacs/sublime and use the gradle CLI, but if you want a fully featured IDE, get Android Studio. (Don't know if mpdroid requires AS 2.0 beta or 1.5 stable though) For emulators, I often dev on a real device, but genymotion works really well, I strongly advise it :)

Also, don't forget to start from the dev branch! Mpdroid has little activity these days, but Exoplayer would really be welcome :)

noahhaon commented 8 years ago

Thanks. If @avuton wants to grab this, then great - otherwise its something I'd be interested in taking a look at over the next couple weeks as I have time.

Probably better to discuss the playlist feature in another issue, but what I'm after is an option that locks track switching (or prompts) when reordering the Now Playing playlist. Too often when reordering the Now Playing playlist, I end up switching tracks, and with the buffering delays, this ends up with a minute plus delay to get back to the previous track on a low-bitrate stream. A real party killer ;)

My digitizer on my nexus 7 2013 may be flaky, or it may be an issue w/ the drag-drop interface on MPDroid, but it seems like a confirmation prompt or just a button to disable track switching when in Now Playing would be a simple fix for my issue.

avuton commented 8 years ago

Yes, I'd love to see this, if it improves things. With that said, to me, it's a high bar. Since Lollipop MR1, there have been, generally, no bugs with regard to MediaPlayer. I use the streaming service, minimally, a couple of hours a day. The service could use some work to fix the problems where it times out and never returns, but, that's a totally separate thing. It took a lot of work (10+ hours working around one MediaPlayer bug I can recall), trial and error, to get to this point.

With all that said, the only thing I recommend is no option; we can't afford to maintain both, so, if exoplayer is better, and the implementation is solid, it should completely replace MediaPlayer.

I also don't have time to do this. Right now, my commits are pretty small if at all, and are, generally, relegated to the MPD interface library. I would be thrilled to help, review and test the code though. Despite how it might sound, I don't expect this to be easy or bug free.

Finally, the class you'll be looking for is StreamHandler.java.

noahhaon commented 8 years ago

Yeah I started looking at StreamHandler.java when investigating, and I saw a lot of code in there to work around MediaPlayer issues - so I figured exoplayer had the potential to get rid of a lot of that cruft if it was indeed an improvement over MediaPlayer.

The biggest issue for me (and a few other issue reporters, it looks like) is being able adjust the buffer size. If you stream low bitrate streams (e.g. 96kbps) it can take 30+ seconds to fill the buffer on Marshmallow before it begins playing. Of course there could be users who may benefit from being able to set a larger buffer, as well.

Thanks for your response! I certainly understand being busy, and when I get around to a first cut of this, I would certainly appreciate some of your time to review and test.

nachoparker commented 7 years ago

Hi, since I wrote issue https://github.com/abarisain/dmix/issues/816 I have also been interesting in helping fix this.

I also do not have much time but I could probably make an effort to help for a few months

FAUSheppy commented 6 years ago

has anybody done something in that direction by now or do i have to do it by myself :P ?

antgel commented 5 years ago

Yet another mere user asking if anyone got anywhere with this? When streaming from mpd, it's 20 seconds before the song starts on my local WiFi. a bit of a shame in what would otherwise be a great replacement for Google Play Music. Ampache has browser playing issues, Airsonic doesn't compile, etc etc...