@Override
  public void onServiceConnected(ComponentName name, IBinder service) {
    mService = IPlayerService.Stub.asInterface(service);
    if (bound) {
      Log.d(TAG, "Service Connected");
    } else {
      Log.d(TAG, "Service Connected, but was unbound in the meantime");
      return;
    }

    try {
      mService.registerCallback(mCallback, 0);
    } catch (RemoteException e) {
      throw new RuntimeException(e);
    }

    for (Opt o : options) {
      setOption(o.opt, o.arg);
    }
    options.clear();

    if (modToPlay != null) {
      playMod(modToPlay);
      modToPlay = null;
    }
  }
示例#2
0
  @Override
  public void setOption(String opt, Object val) {
    final int k, v;
    if (opt.equals("active")) {
      isActive = (Boolean) val;
      Log.d(TAG, ">>>>>>>>>> VICEPLUGIN IS " + (isActive ? "ACTIVE" : "NOT ACTIVE"));
      return;
    } else if (opt.equals("filter")) {
      k = OPT_FILTER;
      v = (Boolean) val ? 1 : 0;
    } else if (opt.equals("ntsc")) {
      k = OPT_NTSC;
      v = (Integer) val;
    } else if (opt.equals("resampling")) {
      k = OPT_RESAMPLING;
      v = (Integer) val;
    } else if (opt.equals("filter_bias")) {
      k = OPT_FILTER_BIAS;
      v = (Integer) val;
    } else if (opt.equals("sid_model")) {
      k = OPT_SID_MODEL;
      v = (Integer) val;
    } else {
      return;
    }

    if (!libraryLoaded) {
      optMap.put(k, v);
    } else {
      N_setOption(k, v);
    }
  }
 public void bindService(Context ctx, Handler h) {
   handler = h;
   Log.d(TAG, "binding");
   Intent i = new Intent(ctx, PlayerService.class);
   bound = true;
   ctx.startService(i);
   ctx.bindService(i, this, Context.BIND_AUTO_CREATE);
 }
 @Override
 public void onServiceDisconnected(ComponentName name) {
   Log.d(TAG, "Service Disconnected!");
   if (handler != null) {
     Message msg = handler.obtainMessage(999);
     handler.sendMessage(msg);
   }
 }
 public void unbindService(Context ctx) {
   Log.d(TAG, "Unbinding");
   handler = null;
   bound = false;
   if (mService != null) {
     try {
       mService.unRegisterCallback(mCallback);
     } catch (RemoteException e) {
       // throw new RuntimeException(e);
     }
   }
   ctx.unbindService(this);
 }