Android: My encounter with the worst apis

Lately I have been working with MediaPlayer on Android. I went to Android docs, read the description of the apis. Great! Let's think a rough algo and start working on the app.

I wrote a simple app which just streams a video and provided media player controls in the app for seeking, play pause etc. Pushed it on my device and goofed around with it. Play, pause working great. Video is streaming nicely. What about seeking? Let's seek to some X position. BAAAAM!!! The whole app became unresponsive. I couldn't interact with my device any more. I thought may be I am doing something wrong so I better review the code. After reviewing I couldn't find anything that I might have been doing on the main thread which could have caused this ANR. I searched the internet and found a few questions on Stackoverflow complaining about the same issue and guess what those questions were posted back in 2011 and 2012. I asked some of those devs and to my surprise they had the assumption of these bugs being fixed long ago, but here I am scolding Google for not fixing the issues and releasing premature api's for the media player.

Let's forget about the UI responsiveness for a bit and focus on other apis. I implemented listeners for buffering callbacks. The algo for the app was developed keeping the documentation of those callbacks in the mind, however when I pushed the app on the device, the behavior of the app was totally unexpected. Forget about stuff that shouldn't be happening, things that should have been happening either never happened or occurred seldom. After extensive testing I found that the behavior of the callbacks was totally undefined. Either Android docs failed to mention other possible scenarios for them or they were the bastard child of the messed up code.

Now I looked towards lollipop in the hope that this crappy behavior might have been resolved in the latest and greatest OS. Google again didn't fail to surprise me. Not only the apis that weren't working on Pre-lollipop devices were still in the same buggy state, the apis that were working stopped working altogether. Now I am sitting ducks, frustrated by the piece of shit Google has provided in the name of Media Player, trying to patch the known issues in my player code making it a spaghetti code.

The only solution I can think of is abandon Media Player and write your own player from the scratch, which is a major pain in the ass or use some open source player.

FUCK YOU Google!!!

Comments

Popular posts from this blog

Noir A8: Battery Friendly Jelly Bean Rom

ICS Themed Rom For Noir A2

Exploring Redux in React Native: Building a Test App with Example Code