/* * Fetches mp3 audio file ID3 information using mp3agic library */ private void setTrackInformation() { try { Mp3File mp3 = new Mp3File(file.getPath()); if (mp3.hasId3v2Tag()) { title = mp3.getId3v2Tag().getTitle(); album = mp3.getId3v2Tag().getAlbum(); artist = mp3.getId3v2Tag().getArtist(); } } catch (Exception e) { e.printStackTrace(); } }
public String getTrack() { if (mp3File.hasId3v2Tag() && mp3File.getId3v2Tag().getTrack() != null) { return mp3File.getId3v2Tag().getTrack(); } if (mp3File.hasId3v1Tag() && mp3File.getId3v1Tag().getTrack() != null) { return mp3File.getId3v1Tag().getTrack(); } return UNKNOWN_TRACK; }
public String getTitle() { if (mp3File.hasId3v2Tag() && mp3File.getId3v2Tag().getTitle() != null) { return mp3File.getId3v2Tag().getTitle(); } if (mp3File.hasId3v1Tag() && mp3File.getId3v1Tag().getTitle() != null) { return mp3File.getId3v1Tag().getTitle(); } return NO_TITLE; }
public String getArtist() { if (mp3File.hasId3v2Tag() && mp3File.getId3v2Tag().getArtist() != null) { return mp3File.getId3v2Tag().getArtist(); } if (mp3File.hasId3v1Tag() && mp3File.getId3v1Tag().getArtist() != null) { return mp3File.getId3v1Tag().getArtist(); } return UNKNOWN_ARTIST; }
public long getDuration() { return mp3File.getLengthInSeconds(); }
public int getBitrate() { return mp3File.getBitrate(); }