Posts

Showing posts from February, 2015

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 th