Esempio n. 1
0
 /** @param index */
 public static void setQueuePosition(int index) {
   if (mService == null) return;
   try {
     mService.setQueuePosition(index);
   } catch (RemoteException e) {
   }
 }
Esempio n. 2
0
 /** @return current track's queue position */
 public static int getQueuePosition() {
   if (mService == null) return 0;
   try {
     return mService.getQueuePosition();
   } catch (RemoteException e) {
   }
   return 0;
 }
Esempio n. 3
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();
   }
 }
Esempio n. 4
0
 /** @return duration of a track */
 public static long getDuration() {
   if (mService != null) {
     try {
       return mService.duration();
     } catch (RemoteException e) {
     }
   }
   return 0;
 }
Esempio n. 5
0
  /** Toggle favorites */
  public static void toggleFavorite() {

    if (mService == null) return;
    try {
      mService.toggleFavorite();
    } catch (RemoteException e) {
      e.printStackTrace();
    }
  }
Esempio n. 6
0
 /**
  * @param from The index the item is currently at.
  * @param to The index the item is moving to.
  */
 public static void moveQueueItem(final int from, final int to) {
   try {
     if (mService != null) {
       mService.moveQueueItem(from, to);
     } else {
     }
   } catch (final RemoteException ignored) {
   }
 }
Esempio n. 7
0
  /** @return if music is playing */
  public static boolean isPlaying() {
    if (mService == null) return false;

    try {
      return mService.isPlaying();
    } catch (RemoteException e) {
    }
    return false;
  }
Esempio n. 8
0
  /** @return current track name */
  public static String getTrackName() {

    if (mService != null) {
      try {
        return mService.getTrackName();
      } catch (RemoteException ex) {
      }
    }
    return null;
  }
Esempio n. 9
0
  /** @return current track ID */
  public static long getCurrentAudioId() {

    if (MusicUtils.mService != null) {
      try {
        return mService.getAudioId();
      } catch (RemoteException ex) {
      }
    }
    return -1;
  }
Esempio n. 10
0
  /** @return current album ID */
  public static long getCurrentAlbumId() {

    if (mService != null) {
      try {
        return mService.getAlbumId();
      } catch (RemoteException ex) {
      }
    }
    return -1;
  }
Esempio n. 11
0
  /**
   * @param id
   * @return removes track from a playlist
   */
  public static int removeTrack(long id) {
    if (mService == null) return 0;

    try {
      return mService.removeTrack(id);
    } catch (RemoteException e) {
      e.printStackTrace();
    }
    return 0;
  }
Esempio n. 12
0
  /** @return */
  public static long[] getQueue() {

    if (mService == null) return sEmptyList;

    try {
      return mService.getQueue();
    } catch (RemoteException e) {
      e.printStackTrace();
    }
    return sEmptyList;
  }
Esempio n. 13
0
 /** Method that removes all tracks from the current queue */
 public static void removeAllTracks() {
   try {
     if (mService == null) {
       long[] current = MusicUtils.getQueue();
       if (current != null) {
         mService.removeTracks(0, current.length - 1);
       }
     }
   } catch (RemoteException e) {
   }
 }
Esempio n. 14
0
  /**
   * @param mContext
   * @param list
   */
  public static void addToCurrentPlaylist(Context mContext, long[] list) {

    if (mService == null) return;
    try {
      mService.enqueue(list, ApolloService.LAST);
      String message =
          mContext
              .getResources()
              .getQuantityString(
                  R.plurals.NNNtrackstoplaylist, list.length, Integer.valueOf(list.length));
      Toast.makeText(mContext, message, Toast.LENGTH_SHORT).show();
    } catch (RemoteException ex) {
    }
  }
Esempio n. 15
0
 public static void notifyWidgets(String what) {
   try {
     mService.notifyChange(what);
   } catch (Exception e) {
   }
 }