title: How do I create a custom media player to play a custom codec in Android?
body: <p>n00b here (first Android project). I have been given a custom video codec that has been integrated with an Android firmware build. It's an .so file containing a class that inherits from MediaPlayerInterface, as well as a custom MediaPlayerService implementation to return instances of the custom codec class from the create() factory function for the appropriate file types.</p>
  
  <p>I want to use this codec as part of a video player application that can be installed on phones that do not contain the codec in firmware, by putting the .so file in my libs/armeabi folder and calling it via JNI.</p>
  
  <p>From the answer to <a href="https://stackoverflow.com/questions/4678739/adding-video-codec-to-android">this question</a> I gather that it is not possible to do this within the MediaPlayer framework, and I have to create a new media player from the ground up. To start with, I implemented a UI in Java, and set it up to use a custom view (instead of VideoView), which extends SurfaceView and used an instance of the MediaPlayer class to play videos. Then I replaced this instance of MediaPlayer with a custom media player Java class. I've set up the JNI interface, mimicking the way android_media_MediaPlayer.cpp does it, and calling the MediaPlayer C++ class in the JNI code. Now I need to replace <i>that</i> with a custom C++ media player class.</p>
  
  <p>This is where I'm starting to run into problems. What is the recommended approach for implementing a custom player? Is there one? Is there some online documentation for any of this stuff besides trawling through the source? How much of the framework can I use and how much do I have to reimplement myself? Will I have to implement my own equivalent to MediaPlayerService?</p>
  
  <p>Any tips greatly appreciated.</p>