本文整理汇总了Java中com.mpatric.mp3agic.Mp3File.hasId3v2Tag方法的典型用法代码示例。如果您正苦于以下问题:Java Mp3File.hasId3v2Tag方法的具体用法?Java Mp3File.hasId3v2Tag怎么用?Java Mp3File.hasId3v2Tag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.mpatric.mp3agic.Mp3File
的用法示例。
在下文中一共展示了Mp3File.hasId3v2Tag方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: stripMp3ID3v2
import com.mpatric.mp3agic.Mp3File; //导入方法依赖的package包/类
/**
* Private helper method that strips ID3v2 tags from an mp3 file.
*
* @param mp3File - Target Mp3File with ID3v2 tags to strip.
* @return A Song object containing all the tags from the mp3File.
*/
private LocalSong stripMp3ID3v2(Mp3File mp3File) {
if(!mp3File.hasId3v2Tag()) {
throw new IllegalArgumentException("No such file exists!");
}
ID3v2 id3v2Tags = mp3File.getId3v2Tag();
LocalSong mp3Song = new LocalSong();
mp3Song.setTitle(id3v2Tags.getTitle());
mp3Song.setArtist(id3v2Tags.getArtist());
mp3Song.setAlbum(id3v2Tags.getAlbum());
mp3Song.setLength("" + mp3File.getLengthInSeconds());
return mp3Song;
}
示例2: getAlbumCover
import com.mpatric.mp3agic.Mp3File; //导入方法依赖的package包/类
public static InputStream getAlbumCover(File file) {
try {
final Mp3File song = new Mp3File(file.getAbsolutePath());
if (song.hasId3v2Tag()) {
return new ByteArrayInputStream(song.getId3v2Tag().getAlbumImage());
}
} catch (Exception e) {
return null;
}
return null;
}
示例3: getAlbumCoverMimeType
import com.mpatric.mp3agic.Mp3File; //导入方法依赖的package包/类
public static String getAlbumCoverMimeType(File file) {
try {
final Mp3File song = new Mp3File(file.getAbsolutePath());
if (song.hasId3v2Tag()) {
return song.getId3v2Tag().getAlbumImageMimeType();
}
} catch (Exception e) {
return null;
}
return null;
}
示例4: parse
import com.mpatric.mp3agic.Mp3File; //导入方法依赖的package包/类
@Override
public MetaData parse(Object object) {
Assert.isTrue(object instanceof Mp3File, "Support Mp3File class only.");
Mp3File mp3 = (Mp3File)object;
MetaData metaData = new MetaData();
if (mp3.hasId3v2Tag()) {
ID3v2 id3v2Tag = mp3.getId3v2Tag();
metaData.put(Audio.MetaName.Album, id3v2Tag.getAlbum());
metaData.put(Audio.MetaName.Artist, id3v2Tag.getArtist());
metaData.put(Audio.MetaName.Genre, id3v2Tag.getGenreDescription());
metaData.put(Audio.MetaName.Title, id3v2Tag.getTitle());
metaData.put(Audio.MetaName.Track, id3v2Tag.getTrack());
}else if(mp3.hasId3v1Tag()) {
ID3v1 id3v1Tag = mp3.getId3v1Tag();
metaData.put(Audio.MetaName.Album, id3v1Tag.getAlbum());
metaData.put(Audio.MetaName.Artist, id3v1Tag.getArtist());
metaData.put(Audio.MetaName.Genre, id3v1Tag.getGenreDescription());
metaData.put(Audio.MetaName.Title, id3v1Tag.getTitle());
metaData.put(Audio.MetaName.Track, id3v1Tag.getTrack());
}
return metaData;
}