Пример #1
0
  /**
   * Create a random queue. For simplicity sake, instead of a random queue, we create a queue using
   * the first genre,
   *
   * @param musicProvider
   * @return
   */
  public static final List<MediaSession.QueueItem> getRandomQueue(MusicProvider musicProvider) {
    Iterator<String> genres = musicProvider.getGenres().iterator();
    if (!genres.hasNext()) {
      return new ArrayList<>();
    }
    String genre = genres.next();
    Iterable<MediaMetadata> tracks = musicProvider.getMusicsByGenre(genre);

    return convertToQueue(tracks);
  }
Пример #2
0
  public static final List<MediaSession.QueueItem> getPlayingQueueFromSearch(
      String query, MusicProvider musicProvider) {

    LogHelper.e(TAG, "Creating playing queue for musics from search ", query);

    return convertToQueue(musicProvider.searchMusics(query));
  }
Пример #3
0
  public static final List<MediaSession.QueueItem> getPlayingQueue(
      String mediaId, MusicProvider musicProvider) {

    // extract the category and unique music ID from the media ID:
    String[] category = MediaIDHelper.extractBrowseCategoryFromMediaID(mediaId);

    // This sample only supports genre category.
    if (!category[0].equals(MEDIA_ID_MUSICS_BY_GENRE) || category.length != 2) {
      LogHelper.e(TAG, "Could not build a playing queue for this mediaId: ", mediaId);
      return null;
    }

    String categoryValue = category[1];
    LogHelper.e(TAG, "Creating playing queue for musics of genre ", categoryValue);

    List<MediaSession.QueueItem> queue =
        convertToQueue(musicProvider.getMusicsByGenre(categoryValue));

    return queue;
  }