@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;
    }
  }
 public boolean dumpWav(String modName, String destFile, int length, int flags) {
   try {
     return mService.dumpWav(modName, destFile, length, flags);
   } catch (RemoteException e) {
     e.printStackTrace();
   }
   return false;
 }
 public void stop() {
   try {
     mService.stop();
   } catch (RemoteException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
 }
 public byte[] getBinaryData(int what) {
   try {
     return mService.getBinaryData(what);
   } catch (RemoteException e) {
     e.printStackTrace();
   }
   return null;
 }
 public boolean seekTo(int msec) {
   try {
     return mService.seekTo(msec);
   } catch (RemoteException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
   return false;
 }
 public boolean playPause(boolean play) {
   try {
     return mService.playPause(play);
   } catch (RemoteException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
   return false;
 }
 public boolean setSubSong(int song) {
   try {
     return mService.setSubSong(song);
   } catch (RemoteException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
   return false;
 }
 public boolean playPlaylist(String path, int index) {
   try {
     return mService.playPlaylist(path, index);
   } catch (RemoteException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
   return false;
 }
 public boolean playList(java.lang.String[] names, int startIndex) {
   try {
     return mService.playList(names, startIndex);
   } catch (RemoteException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
   return false;
 }
Пример #10
0
 public Map<String, Object> getSongInfo() {
   try {
     String[] s = mService.getSongInfo();
     return arrayToMap(s);
   } catch (RemoteException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
   return null;
 }
Пример #11
0
  public boolean playMod(String name) {
    if (mService == null) {
      modToPlay = name;
      return true;
    }

    try {
      return mService.playMod(name);
    } catch (RemoteException e) {
      return false;
    }
  }
Пример #12
0
 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);
 }
Пример #13
0
  public void setOption(int opt, String arg) {

    if (mService == null) {
      options.add(new Opt(opt, arg));
      return;
    }

    try {
      mService.setOption(opt, arg);
    } catch (RemoteException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }