public static List<MediaSession.QueueItem> getPlayingQueue(
      String mediaId, MusicProvider musicProvider) {

    // extract the browsing hierarchy from the media ID:
    String[] hierarchy = MediaIDHelper.getHierarchy(mediaId);

    if (hierarchy.length != 2) {
      LogHelper.e(TAG, "Could not build a playing queue for this mediaId: ", mediaId);
      return null;
    }

    String categoryType = hierarchy[0];
    String categoryValue = hierarchy[1];
    LogHelper.d(TAG, "Creating playing queue for ", categoryType, ",  ", categoryValue);

    Iterable<MediaMetadata> tracks = null;
    // This sample only supports genre and by_search category types.
    if (categoryType.equals(MEDIA_ID_MUSICS_BY_GENRE)) {
      tracks = musicProvider.getMusicsByGenre(categoryValue);
    } else if (categoryType.equals(MEDIA_ID_MUSICS_BY_SEARCH)) {
      tracks = musicProvider.searchMusicBySongTitle(categoryValue);
    }

    if (tracks == null) {
      LogHelper.e(TAG, "Unrecognized category type: ", categoryType, " for media ", mediaId);
      return null;
    }

    return convertToQueue(tracks, hierarchy[0], hierarchy[1]);
  }
Пример #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 String getGender(String code) {
   if (sGenderHashMap == null || sGenderHashMap.isEmpty()) {
     initGenderMap();
   }
   LogHelper.e("omg", "gender" + code + " |" + sGenderHashMap.containsKey(code.trim()));
   if (sGenderHashMap.containsKey(code.trim())) {
     return sGenderHashMap.get(code.trim());
   }
   return code;
 }
Пример #4
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;
  }
Пример #5
0
 public static long parseStringToLongTime(String time, String format) {
   SimpleDateFormat sdf = new SimpleDateFormat(format, Locale.CHINA);
   sdf.setTimeZone(TimeZone.getTimeZone("GMT+800"));
   try {
     long result = sdf.parse(time.trim()).getTime();
     LogHelper.e("parseStringToLongTime", time + "|" + result);
     return result;
   } catch (Exception e) {
     return -1;
   }
 }