public String getKeyStart() {
   String start_key = null;
   // txxx start key
   FrameBodyTXXX txxx_frame = getTXXXFrame(TXXX_KEY_START);
   if (txxx_frame != null) {
     start_key = txxx_frame.getText();
   }
   if (StringUtil.isValid(start_key)) return start_key;
   // tkey
   if (id3v2 != null) {
     AbstractID3v2Frame frame = getFrame(FRAME_KEY);
     if (frame != null) {
       FrameBodyTKEY frame_body = (FrameBodyTKEY) frame.getBody();
       if (frame_body != null) {
         start_key = frame_body.getText();
       }
     }
   }
   // txxx key/initialkey/fkey
   txxx_frame = getTXXXFrame(TXXX_KEY);
   if (txxx_frame != null) {
     start_key = txxx_frame.getText();
   }
   if (StringUtil.isValid(start_key)) return start_key;
   txxx_frame = getTXXXFrame(TXXX_KEY_INITIAL);
   if (txxx_frame != null) {
     start_key = txxx_frame.getText();
   }
   if (StringUtil.isValid(start_key)) return start_key;
   txxx_frame = getTXXXFrame(TXXX_KEY_FINALSCRATCH);
   if (txxx_frame != null) {
     start_key = txxx_frame.getText();
   }
   return start_key;
 }
 public String getTime() {
   String time = null;
   FrameBodyTXXX txxx_frame = getTXXXFrame(TXXX_TIME);
   if (txxx_frame != null) {
     time = txxx_frame.getText();
   }
   if (StringUtil.isValid(time)) return time;
   if (id3v2 != null) {
     AbstractID3v2Frame frame = getFrame(FRAME_LENGTH);
     if (frame != null) {
       FrameBodyTLEN frame_body = (FrameBodyTLEN) frame.getBody();
       if (frame_body != null) {
         try {
           int milliseconds = Integer.parseInt(frame_body.getText());
           time = StringUtil.seconds_to_time(milliseconds / 1000);
         } catch (Exception e) {
           log.error("getTime(): error getting length=", e);
         }
       }
     }
     if (StringUtil.isValid(time)) return time;
     frame = getFrame(FRAME_TIME);
     if (frame != null) {
       FrameBodyTIME frame_body = (FrameBodyTIME) frame.getBody();
       if (frame_body != null) {
         time = frame_body.getText();
       }
     }
   }
   return time;
 }
 public String getArtist() {
   String artist = null;
   // lead performer
   if (id3v2 != null) {
     AbstractID3v2Frame frame = getFrame(FRAME_LEAD_PERFORMER);
     if (frame != null) {
       FrameBodyTPE1 frameBody = (FrameBodyTPE1) frame.getBody();
       artist = frameBody.getText();
     }
     if (StringUtil.isValid(artist)) return artist;
   }
   if (id3v1 != null) {
     artist = getFirstValue(id3v1.getArtist());
     if (StringUtil.isValid(artist)) return artist;
   }
   if (id3v2 != null) {
     // composer
     AbstractID3v2Frame frame = getFrame(FRAME_COMPOSER);
     if (frame != null) {
       FrameBodyTCOM frameBody = (FrameBodyTCOM) frame.getBody();
       artist = frameBody.getText();
     }
     if (StringUtil.isValid(artist)) return artist;
     // original performer
     frame = getFrame(FRAME_ORIGINAL_PERFORMER);
     if (frame != null) {
       FrameBodyTOPE frameBody = (FrameBodyTOPE) frame.getBody();
       artist = frameBody.getText();
     }
   }
   return artist;
 }
 public String getTrack() {
   String track = null;
   if (id3v2 != null) {
     AbstractID3v2Frame frame = getFrame(FRAME_TRACK);
     if (frame != null) {
       FrameBodyTRCK frameBody = (FrameBodyTRCK) frame.getBody();
       track = frameBody.getText();
     }
   }
   if (StringUtil.isValid(track)) return track;
   if (id3v11 != null) {
     track = getFirstValue(id3v11.getTrack());
   }
   return track;
 }
 public String getTitle() {
   String title = null;
   if (id3v2 != null) {
     AbstractID3v2Frame frame = getFrame(FRAME_TITLE);
     if (frame != null) {
       FrameBodyTIT2 frameBody = (FrameBodyTIT2) frame.getBody();
       title = frameBody.getText();
     }
     if (StringUtil.isValid(title)) return title;
   }
   if (id3v1 != null) {
     title = getFirstValue(id3v1.getTitle());
   }
   return title;
 }
 public String getComments() {
   String comments = null;
   if (id3v2 != null) {
     AbstractID3v2Frame frame = getFrame(FRAME_COMMENTS);
     if (frame != null) {
       FrameBodyCOMM frameBody = (FrameBodyCOMM) frame.getBody();
       comments = frameBody.getText();
     }
     if (StringUtil.isValid(comments)) return comments;
   }
   if (id3v1 != null) {
     comments = getFirstValue(id3v1.getComment());
   }
   return comments;
 }
 public String getAlbum() {
   String album = null;
   if (id3v2 != null) {
     AbstractID3v2Frame frame = getFrame(FRAME_ALBUM);
     if (frame != null) {
       FrameBodyTALB frameBody = (FrameBodyTALB) frame.getBody();
       album = frameBody.getText();
     }
     if (StringUtil.isValid(album)) return album;
   }
   if (id3v1 != null) {
     album = getFirstValue(id3v1.getAlbum());
   }
   return album;
 }
 public String getGenre() {
   String genre = null;
   if (id3v2 != null) {
     AbstractID3v2Frame frame = getFrame(FRAME_GENRE);
     if (frame != null) {
       FrameBodyTCON frame_body = (FrameBodyTCON) frame.getBody();
       if (frame_body != null) {
         genre = frame_body.getText();
       }
     }
     if (StringUtil.isValid(genre)) return genre;
   }
   if (id3v1 != null) {
     genre = getFirstValue(id3v1.getGenre());
   }
   return genre;
 }
 public String getYear() {
   String year = null;
   if (id3v2 != null) {
     AbstractID3v2Frame frame = getFrame(FRAME_YEAR);
     if (frame != null) {
       if (frame.getBody() instanceof FrameBodyTYER) {
         FrameBodyTYER frameBody = (FrameBodyTYER) frame.getBody();
         year = frameBody.getText();
       } else {
         log.trace("getYear(): frame=" + frame + ", class=" + frame.getBody().getClass());
       }
     }
     if (StringUtil.isValid(year)) return year;
   }
   if (id3v1 != null) {
     year = getFirstValue(id3v1.getYear());
   }
   return year;
 }
예제 #10
0
 public Float getReplayGain() {
   Float replayGain = null;
   try {
     FrameBodyTXXX txxx_frame = getTXXXFrame(TXXX_REPLAYGAIN_TRACK_GAIN);
     if (txxx_frame != null) {
       String replayGainStr = txxx_frame.getText();
       replayGain = StringUtil.parseNumericalPrefix(replayGainStr);
       if (log.isTraceEnabled())
         log.trace("getReplaygain(): " + TXXX_REPLAYGAIN_TRACK_GAIN + "=" + replayGain);
     }
   } catch (Exception e) {
     log.debug("getReplayGain(): error", e);
   }
   if (replayGain == null) {
     if (id3v2 != null) {
       AbstractID3v2Frame frame = getFrame(FRAME_REPLAYGAIN);
       if (frame != null) {
         FrameBodyRVA2 frame_body = (FrameBodyRVA2) frame.getBody();
         if (frame_body != null) {
           ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
           frame_body.write(outputStream);
           if (log.isTraceEnabled())
             log.trace(
                 "getReplayGain(): decode_rva2_gain="
                     + decode_rva2_gain(outputStream.toByteArray()));
         }
       }
       if (replayGain == null) {
         frame = getFrame(FRAME_REPLAY_VOLUME_ADJUST);
         if (frame != null) {
           FrameBodyRVAD frame_body = (FrameBodyRVAD) frame.getBody();
           if (frame_body != null) {}
         }
       }
     }
   }
   return replayGain;
 }