예제 #1
0
 /**
  * @param context
  * @param list
  * @param position
  * @param force_shuffle
  */
 private static void playAll(Context context, long[] list, int position, boolean force_shuffle) {
   if (list.length == 0 || mService == null) {
     return;
   }
   try {
     if (force_shuffle) {
       mService.setShuffleMode(ApolloService.SHUFFLE_NORMAL);
     }
     long curid = mService.getAudioId();
     int curpos = mService.getQueuePosition();
     if (position != -1 && curpos == position && curid == list[position]) {
       // The selected file is the file that's currently playing;
       // figure out if we need to restart with a new playlist,
       // or just launch the playback activity.
       long[] playlist = mService.getQueue();
       if (Arrays.equals(list, playlist)) {
         // we don't need to set a new list, but we should resume
         // playback if needed
         mService.play();
         return;
       }
     }
     if (position < 0) {
       position = 0;
     }
     mService.open(list, force_shuffle ? -1 : position);
     mService.play();
   } catch (RemoteException ex) {
     ex.printStackTrace();
   }
 }
예제 #2
0
  /** @return current track ID */
  public static long getCurrentAudioId() {

    if (MusicUtils.mService != null) {
      try {
        return mService.getAudioId();
      } catch (RemoteException ex) {
      }
    }
    return -1;
  }