title: How apply a filter on MediaPlayer using a SurfaceView?
body: <p>I need perform a filter on draw of one video playing on android (MediaPlayer), this filter just will turn the background to transparent, but how I can read the bytes to process? because android seems don't run alpha channel movies :(</p>
  
  <p>I need this to put a video in a fullscreen overlaying the camera preview (AR). That's why I need the movie background transparent.</p>
  
  <p>My idea be send the MediaPlayer frame data (bitmap data) to NDK process, then back a processed bitmap to surfaceview.</p>
  
  <p>PS: Android API8, target 2.2+</p>
  
  <p>Follow My code bellow:</p>
  
  <pre><code>import android.content.Context;
  import android.graphics.Canvas;
  import android.graphics.Color;
  import android.graphics.Paint;
  import android.util.Log;
  import android.view.SurfaceView;
  
  public class MovieSurfaceView extends SurfaceView {
  
      public MovieSurfaceView(Context context) {
          super(context);
      }
  
      @Override
      protected void onDraw(Canvas c) {
          super.onDraw(c);
      }
  
  }
  
  /** The main activity for the ImageTargets sample. */
  public class ImageTargets extends Activity  implements SurfaceHolder.Callback
  {
      private MovieSurfaceView mPreview;
  
      private MediaPlayer mMediaPlayer;
  
      private SurfaceHolder holder;
  
      private String videoPath = "/LAST.3g2";
  
      protected void onCreate(Bundle savedInstanceState)
      {
          DebugLog.LOGD("ImageTargets::onCreate");
          super.onCreate(savedInstanceState);
          initApplicationAR();
      }
  
      private void initApplicationAR()
      {        
  
          mPreview = new MovieSurfaceView(this);
  
          addContentView(mPreview, new LayoutParams(
              LayoutParams.FILL_PARENT,
              LayoutParams.FILL_PARENT));
  
          //        holder = mGlView.getHolder();
          holder = mPreview.getHolder();
          holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
          holder.addCallback(this);
      }
  
  
      @Override
      public void surfaceChanged(SurfaceHolder arg0, int arg1, int arg2, int arg3) {
  
      }
  
  
      @Override
      public void surfaceCreated(SurfaceHolder arg0) {
          mMediaPlayer = new MediaPlayer();
  
          mMediaPlayer.setDisplay(holder);
  
          mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); 
  
          mMediaPlayer.setOnPreparedListener(new OnPreparedListener() 
          {
              public void onPrepared(MediaPlayer mp) 
              {
                  mp.start();
              }
          }
          );
  
          mMediaPlayer.setOnCompletionListener(new OnCompletionListener() 
          {
  
              @Override
                  public void onCompletion(MediaPlayer mp) 
              {
                  mp.reset();
              }
          }
          );
  
          iniPlayer();
      }
  
  
      @Override
          public void surfaceDestroyed(SurfaceHolder arg0) 
      {
          // TODO Auto-generated method stub
  
      }  
  
  
  }
  </code></pre>