解析mp3,获取歌曲名,歌手过程中,英文可以正常显示,但中文显示问号。
mp3file = new MP3File(filepath);
MP3AudioHeader header = mp3file.getMP3AudioHeader();
System.out.println("时长: " + header.getTrackLength());
// ID3v2Tag
AbstractID3v2Tag tag = mp3file.getID3v2Tag();
//时长转化为 分:秒格式
String music_length=secToTime(header.getTrackLength());
System.out.println(music_length);
String songName = new String(tag.frameMap.get("TIT2").toString().getBytes("ISO-8859-1"), "GB2312");
String singer = new String(tag.frameMap.get("TPE1").toString().getBytes("ISO-8859-1"), "GB2312");
String album = new String(tag.frameMap.get("TALB").toString().getBytes("ISO-8859-1"), "GB2312");
System.out.println(songName+singer+album);以上为解析过程代码
控制台输出为:Text="??"; Text="???"; Text="?????demo??";
mp3file = new MP3File(filepath);
MP3AudioHeader header = mp3file.getMP3AudioHeader();
System.out.println("时长: " + header.getTrackLength());
// ID3v2Tag
AbstractID3v2Tag tag = mp3file.getID3v2Tag();
//时长转化为 分:秒格式
String music_length=secToTime(header.getTrackLength());
System.out.println(music_length);
String songName = new String(tag.frameMap.get("TIT2").toString().getBytes("ISO-8859-1"), "GB2312");
String singer = new String(tag.frameMap.get("TPE1").toString().getBytes("ISO-8859-1"), "GB2312");
String album = new String(tag.frameMap.get("TALB").toString().getBytes("ISO-8859-1"), "GB2312");
System.out.println(songName+singer+album);以上为解析过程代码
控制台输出为:Text="??"; Text="???"; Text="?????demo??";
@RequestMapping(value = "/url", method = RequestMethod.POST, produces = "text/html;charset=UTF-8")