/**
   * Default constructor. The same as Android's MediaPlayer().
   *
   * <p>When done with the MediaPlayer, you should call {@link #release()}, to free the resources.
   * If not released, too many MediaPlayer instances may result in an exception.
   *
   * @param preferHWDecoder MediaPlayer will try to use hardware accelerated decoder if true
   */
  public MediaPlayer(Context ctx, boolean preferHWDecoder) {
    mContext = ctx;

    String LIB_ROOT = Vitamio.getLibraryPath();
    if (preferHWDecoder) {
      if (!NATIVE_OMX_LOADED.get()) {
        if (Build.VERSION.SDK_INT > 17) loadOMX_native(LIB_ROOT + "libOMX.18.so");
        else if (Build.VERSION.SDK_INT > 13) loadOMX_native(LIB_ROOT + "libOMX.14.so");
        else if (Build.VERSION.SDK_INT > 10) loadOMX_native(LIB_ROOT + "libOMX.11.so");
        else loadOMX_native(LIB_ROOT + "libOMX.9.so");
        NATIVE_OMX_LOADED.set(true);
      }
    } else {
      unloadOMX_native();
      NATIVE_OMX_LOADED.set(false);
    }

    Looper looper;
    if ((looper = Looper.myLooper()) != null) mEventHandler = new EventHandler(this, looper);
    else if ((looper = Looper.getMainLooper()) != null)
      mEventHandler = new EventHandler(this, looper);
    else mEventHandler = null;

    native_init();
  }