本文整理汇总了Java中org.jaudiotagger.tag.images.Artwork类的典型用法代码示例。如果您正苦于以下问题:Java Artwork类的具体用法?Java Artwork怎么用?Java Artwork使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Artwork类属于org.jaudiotagger.tag.images包,在下文中一共展示了Artwork类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getImageInputStreamWithType
import org.jaudiotagger.tag.images.Artwork; //导入依赖的package包/类
/**
* Returns an input stream to the image in the given file. If the file is an audio file,
* the embedded album art is returned. In addition returns the mime type
*/
private Pair<InputStream, String> getImageInputStreamWithType(File file) throws IOException {
InputStream is;
String mimeType;
if (jaudiotaggerParser.isApplicable(file)) {
LOG.trace("Using Jaudio Tagger for reading artwork from {}", file);
MediaFile mediaFile = mediaFileService.getMediaFile(file);
Artwork artwork;
try {
LOG.trace("Reading artwork from file {}", mediaFile);
artwork = jaudiotaggerParser.getArtwork(mediaFile);
} catch (Exception e) {
LOG.debug("Could not read artwork from file {}", mediaFile);
throw new RuntimeException(e);
}
is = new ByteArrayInputStream(artwork.getBinaryData());
mimeType = artwork.getMimeType();
} else {
is = new FileInputStream(file);
mimeType = StringUtil.getMimeType(FilenameUtils.getExtension(file.getName()));
}
return Pair.of(is, mimeType);
}
示例2: from
import org.jaudiotagger.tag.images.Artwork; //导入依赖的package包/类
public static Song from(final URI uri) {
try {
AudioFile f = AudioFileIO.read(new File(uri));
Tag tag = f.getTag();
String trackStr = tag.getFirst(FieldKey.TRACK);
if (trackStr.isEmpty()) { return null; }
Artist artist = new Artist(tag.getFirst(FieldKey.ARTIST));
Artwork artwork = tag.getFirstArtwork();
Album album = new Album(tag.getFirst(FieldKey.ALBUM), artwork);
String title = tag.getFirst(FieldKey.TITLE);
int track = Integer.parseInt(trackStr);
Integer seconds = f.getAudioHeader().getTrackLength() + 1;
return new Song(title, artist, album, track, seconds, uri);
} catch (CannotReadException | IOException | TagException | InvalidAudioFrameException
| ReadOnlyFileException e) {
e.printStackTrace();
return null;
}
}
示例3: getArtworkList
import org.jaudiotagger.tag.images.Artwork; //导入依赖的package包/类
/**
* @return
*/
public List<Artwork> getArtworkList()
{
final List<TagField> coverartList = getFields(FieldKey.COVER_ART);
final List<Artwork> artworkList = new ArrayList<Artwork>(coverartList.size());
for (final TagField next : coverartList)
{
final AsfTagCoverField coverArt = (AsfTagCoverField) next;
final Artwork artwork = ArtworkFactory.getNew();
artwork.setBinaryData(coverArt.getRawImageData());
artwork.setMimeType(coverArt.getMimeType());
artwork.setDescription(coverArt.getDescription());
artwork.setPictureType(coverArt.getPictureType());
artworkList.add(artwork);
}
return artworkList;
}
示例4: getArtworkList
import org.jaudiotagger.tag.images.Artwork; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public List<Artwork> getArtworkList()
{
List<TagField> coverartList = getFields(FieldKey.COVER_ART);
List<Artwork> artworkList = new ArrayList<Artwork>(coverartList.size());
for (TagField next : coverartList)
{
FrameBodyPIC coverArt = (FrameBodyPIC) ((AbstractID3v2Frame) next).getBody();
Artwork artwork = ArtworkFactory.getNew();
artwork.setMimeType(ImageFormats.getMimeTypeForFormat(coverArt.getFormatType()));
artwork.setPictureType(coverArt.getPictureType());
if (coverArt.isImageUrl())
{
artwork.setLinked(true);
artwork.setImageUrl(coverArt.getImageUrl());
}
else
{
artwork.setBinaryData(coverArt.getImageData());
}
artworkList.add(artwork);
}
return artworkList;
}
示例5: getArtworkList
import org.jaudiotagger.tag.images.Artwork; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public List<Artwork> getArtworkList()
{
List<TagField> coverartList = getFields(FieldKey.COVER_ART);
List<Artwork> artworkList = new ArrayList<Artwork>(coverartList.size());
for (TagField next : coverartList)
{
FrameBodyAPIC coverArt = (FrameBodyAPIC) ((AbstractID3v2Frame) next).getBody();
Artwork artwork = ArtworkFactory.getNew();
artwork.setMimeType(coverArt.getMimeType());
artwork.setPictureType(coverArt.getPictureType());
if (coverArt.isImageUrl())
{
artwork.setLinked(true);
artwork.setImageUrl(coverArt.getImageUrl());
}
else
{
artwork.setBinaryData(coverArt.getImageData());
}
artworkList.add(artwork);
}
return artworkList;
}
示例6: getArtworkList
import org.jaudiotagger.tag.images.Artwork; //导入依赖的package包/类
public List<Artwork> getArtworkList()
{
List<TagField> coverartList = getFields(FieldKey.COVER_ART);
List<Artwork> artworkList = new ArrayList<Artwork>(coverartList.size());
for (TagField next : coverartList)
{
FrameBodyAPIC coverArt = (FrameBodyAPIC) ((AbstractID3v2Frame) next).getBody();
Artwork artwork = ArtworkFactory.getNew();
artwork.setMimeType(coverArt.getMimeType());
artwork.setPictureType(coverArt.getPictureType());
if (coverArt.isImageUrl())
{
artwork.setLinked(true);
artwork.setImageUrl(coverArt.getImageUrl());
}
else
{
artwork.setBinaryData(coverArt.getImageData());
}
artworkList.add(artwork);
}
return artworkList;
}
示例7: getArtworkList
import org.jaudiotagger.tag.images.Artwork; //导入依赖的package包/类
/**
* @return
*/
public List<Artwork> getArtworkList() {
final List<TagField> coverartList = getFields(FieldKey.COVER_ART);
final List<Artwork> artworkList = new ArrayList<Artwork>(coverartList.size());
for (final TagField next : coverartList) {
final AsfTagCoverField coverArt = (AsfTagCoverField) next;
final Artwork artwork = ArtworkFactory.getNew();
artwork.setBinaryData(coverArt.getRawImageData());
artwork.setMimeType(coverArt.getMimeType());
artwork.setDescription(coverArt.getDescription());
artwork.setPictureType(coverArt.getPictureType());
artworkList.add(artwork);
}
return artworkList;
}
示例8: createMetadataBlockDataPicture
import org.jaudiotagger.tag.images.Artwork; //导入依赖的package包/类
/**
* Create MetadataBlockPicture field, this is the preferred way of storing artwork in VorbisComment tag now but
* has to be base encoded to be stored in VorbisComment
*
* @return MetadataBlockDataPicture
*/
private MetadataBlockDataPicture createMetadataBlockDataPicture(Artwork artwork) throws FieldDataInvalidException {
if (artwork.isLinked()) {
return new MetadataBlockDataPicture(
Utils.getDefaultBytes(artwork.getImageUrl(), TextEncoding.CHARSET_ISO_8859_1),
artwork.getPictureType(),
MetadataBlockDataPicture.IMAGE_IS_URL,
"",
0,
0,
0,
0);
} else {
if (!artwork.setImageFromData()) {
throw new FieldDataInvalidException("Unable to create MetadataBlockDataPicture from buffered");
}
return new MetadataBlockDataPicture(artwork.getBinaryData(),
artwork.getPictureType(),
artwork.getMimeType(),
artwork.getDescription(),
artwork.getWidth(),
artwork.getHeight(),
0,
0);
}
}
示例9: getArtworkList
import org.jaudiotagger.tag.images.Artwork; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public List<Artwork> getArtworkList() {
List<TagField> coverartList = getFields(FieldKey.COVER_ART);
List<Artwork> artworkList = new ArrayList<Artwork>(coverartList.size());
for (TagField next : coverartList) {
FrameBodyPIC coverArt = (FrameBodyPIC) ((AbstractID3v2Frame) next).getBody();
Artwork artwork = ArtworkFactory.getNew();
artwork.setMimeType(ImageFormats.getMimeTypeForFormat(coverArt.getFormatType()));
artwork.setPictureType(coverArt.getPictureType());
if (coverArt.isImageUrl()) {
artwork.setLinked(true);
artwork.setImageUrl(coverArt.getImageUrl());
} else {
artwork.setBinaryData(coverArt.getImageData());
}
artworkList.add(artwork);
}
return artworkList;
}
示例10: createField
import org.jaudiotagger.tag.images.Artwork; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public TagField createField(Artwork artwork) throws FieldDataInvalidException {
AbstractID3v2Frame frame = createFrame(getFrameAndSubIdFromGenericKey(FieldKey.COVER_ART).getFrameId());
FrameBodyPIC body = (FrameBodyPIC) frame.getBody();
if (!artwork.isLinked()) {
body.setObjectValue(DataTypes.OBJ_PICTURE_DATA, artwork.getBinaryData());
body.setObjectValue(DataTypes.OBJ_PICTURE_TYPE, artwork.getPictureType());
body.setObjectValue(DataTypes.OBJ_IMAGE_FORMAT, ImageFormats.getFormatForMimeType(artwork.getMimeType()));
body.setObjectValue(DataTypes.OBJ_DESCRIPTION, "");
return frame;
} else {
try {
body.setObjectValue(DataTypes.OBJ_PICTURE_DATA, artwork.getImageUrl().getBytes("ISO-8859-1"));
} catch (UnsupportedEncodingException uoe) {
throw new RuntimeException(uoe.getMessage());
}
body.setObjectValue(DataTypes.OBJ_PICTURE_TYPE, artwork.getPictureType());
body.setObjectValue(DataTypes.OBJ_IMAGE_FORMAT, FrameBodyAPIC.IMAGE_IS_URL);
body.setObjectValue(DataTypes.OBJ_DESCRIPTION, "");
return frame;
}
}
示例11: getArtworkList
import org.jaudiotagger.tag.images.Artwork; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public List<Artwork> getArtworkList() {
List<TagField> coverartList = getFields(FieldKey.COVER_ART);
List<Artwork> artworkList = new ArrayList<Artwork>(coverartList.size());
for (TagField next : coverartList) {
FrameBodyAPIC coverArt = (FrameBodyAPIC) ((AbstractID3v2Frame) next).getBody();
Artwork artwork = ArtworkFactory.getNew();
artwork.setMimeType(coverArt.getMimeType());
artwork.setPictureType(coverArt.getPictureType());
if (coverArt.isImageUrl()) {
artwork.setLinked(true);
artwork.setImageUrl(coverArt.getImageUrl());
} else {
artwork.setBinaryData(coverArt.getImageData());
}
artworkList.add(artwork);
}
return artworkList;
}
示例12: createField
import org.jaudiotagger.tag.images.Artwork; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public TagField createField(Artwork artwork) throws FieldDataInvalidException {
AbstractID3v2Frame frame = createFrame(getFrameAndSubIdFromGenericKey(FieldKey.COVER_ART).getFrameId());
FrameBodyAPIC body = (FrameBodyAPIC) frame.getBody();
if (!artwork.isLinked()) {
body.setObjectValue(DataTypes.OBJ_PICTURE_DATA, artwork.getBinaryData());
body.setObjectValue(DataTypes.OBJ_PICTURE_TYPE, artwork.getPictureType());
body.setObjectValue(DataTypes.OBJ_MIME_TYPE, artwork.getMimeType());
body.setObjectValue(DataTypes.OBJ_DESCRIPTION, "");
return frame;
} else {
try {
body.setObjectValue(DataTypes.OBJ_PICTURE_DATA, artwork.getImageUrl().getBytes("ISO-8859-1"));
} catch (UnsupportedEncodingException uoe) {
throw new RuntimeException(uoe.getMessage());
}
body.setObjectValue(DataTypes.OBJ_PICTURE_TYPE, artwork.getPictureType());
body.setObjectValue(DataTypes.OBJ_MIME_TYPE, FrameBodyAPIC.IMAGE_IS_URL);
body.setObjectValue(DataTypes.OBJ_DESCRIPTION, "");
return frame;
}
}
示例13: getArtworkList
import org.jaudiotagger.tag.images.Artwork; //导入依赖的package包/类
public List<Artwork> getArtworkList() {
List<TagField> coverartList = getFields(FieldKey.COVER_ART);
List<Artwork> artworkList = new ArrayList<Artwork>(coverartList.size());
for (TagField next : coverartList) {
FrameBodyAPIC coverArt = (FrameBodyAPIC) ((AbstractID3v2Frame) next).getBody();
Artwork artwork = ArtworkFactory.getNew();
artwork.setMimeType(coverArt.getMimeType());
artwork.setPictureType(coverArt.getPictureType());
if (coverArt.isImageUrl()) {
artwork.setLinked(true);
artwork.setImageUrl(coverArt.getImageUrl());
} else {
artwork.setBinaryData(coverArt.getImageData());
}
artworkList.add(artwork);
}
return artworkList;
}
示例14: createField
import org.jaudiotagger.tag.images.Artwork; //导入依赖的package包/类
public TagField createField(Artwork artwork) throws FieldDataInvalidException {
AbstractID3v2Frame frame = createFrame(getFrameAndSubIdFromGenericKey(FieldKey.COVER_ART).getFrameId());
FrameBodyAPIC body = (FrameBodyAPIC) frame.getBody();
if (!artwork.isLinked()) {
body.setObjectValue(DataTypes.OBJ_PICTURE_DATA, artwork.getBinaryData());
body.setObjectValue(DataTypes.OBJ_PICTURE_TYPE, artwork.getPictureType());
body.setObjectValue(DataTypes.OBJ_MIME_TYPE, artwork.getMimeType());
body.setObjectValue(DataTypes.OBJ_DESCRIPTION, "");
return frame;
} else {
try {
body.setObjectValue(DataTypes.OBJ_PICTURE_DATA, artwork.getImageUrl().getBytes("ISO-8859-1"));
} catch (UnsupportedEncodingException uoe) {
throw new RuntimeException(uoe.getMessage());
}
body.setObjectValue(DataTypes.OBJ_PICTURE_TYPE, artwork.getPictureType());
body.setObjectValue(DataTypes.OBJ_MIME_TYPE, FrameBodyAPIC.IMAGE_IS_URL);
body.setObjectValue(DataTypes.OBJ_DESCRIPTION, "");
return frame;
}
}
示例15: setAlbumArtView
import org.jaudiotagger.tag.images.Artwork; //导入依赖的package包/类
/**
* Function name: setAlbumArtView
* Usage: this function is called when a song is played, to set up the corresponding album art.
* The loading job would be done in background instead.
*
* @param audioFile the song file of the playing song (since the song data doesn't contain the audio file).
*/
private void setAlbumArtView(AudioFile audioFile) {
new Thread(new Task<Void>() {
@Override
protected Void call() throws Exception {
try {
Artwork artwork = audioFile.getTag().getFirstArtwork();
byte[] rawAlbumArt = artwork != null ? artwork.getBinaryData() : Constants.getDefaultArtworkRaw();
Platform.runLater(() -> {
Image albumArtImage = new Image(
new ByteArrayInputStream(rawAlbumArt),
sizeCalculator.getPlayerBarHeight() * 1.5,
sizeCalculator.getPlayerBarHeight() * 1.5,
true, true
);
albumArtHolder.setVisible(true);
albumArtView.setImage(albumArtImage);
});
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
}).start();
}