public void play() throws IOException {
  MediaExtractor extractor=null;
  MediaCodec decoder=null;
  if (!mSourceFile.canRead()) {
    throw new FileNotFoundException("Unable to read " + mSourceFile);
  }
  try {
    extractor=new MediaExtractor();
    extractor.setDataSource(mSourceFile.toString());
    int trackIndex=selectTrack(extractor);
    if (trackIndex < 0) {
      throw new RuntimeException("No video track found in " + mSourceFile);
    }
    extractor.selectTrack(trackIndex);
    MediaFormat format=extractor.getTrackFormat(trackIndex);
    String mime=format.getString(MediaFormat.KEY_MIME);
    decoder=MediaCodec.createDecoderByType(mime);
    decoder.configure(format,mOutputSurface,null,0);
    decoder.start();
    doExtract(extractor,trackIndex,decoder,mFrameCallback);
  }
  finally {
    if (decoder != null) {
      decoder.stop();
      decoder.release();
      decoder=null;
    }
    if (extractor != null) {
      extractor.release();
      extractor=null;
    }
  }
}

public void play ( ) throws IOException { MediaExtractor extractor = null ; MediaCodec decoder = null ; if ( ! mSourceFile . canRead ( ) ) { throw new FileNotFoundException ( "Unable to read " + mSourceFile ) ; } try { extractor = new MediaExtractor ( ) ; extractor . setDataSource ( mSourceFile . toString ( ) ) ; int trackIndex = selectTrack ( extractor ) ; if ( trackIndex < 0 ) { throw new RuntimeException ( "No video track found in " + mSourceFile ) ; } extractor . selectTrack ( trackIndex ) ; MediaFormat format = extractor . getTrackFormat ( trackIndex ) ; String mime = format . getString ( MediaFormat . KEY_MIME ) ; decoder = MediaCodec . createDecoderByType ( mime ) ; decoder . configure ( format , mOutputSurface , null , 0 ) ; decoder . start ( ) ; doExtract ( extractor , trackIndex , decoder , mFrameCallback ) ; } finally { if ( decoder != null ) { decoder . stop ( ) ; decoder . release ( ) ; decoder = null ; } if ( extractor != null ) { extractor . release ( ) ; extractor = null ; } } }
decodes the video stream , sending frames to the surface . < p > does not return until video playback is complete , or we get a " stop " signal from framecallback .
