本文整理汇总了Java中org.jaudiotagger.tag.datatype.Artwork类的典型用法代码示例。如果您正苦于以下问题:Java Artwork类的具体用法?Java Artwork怎么用?Java Artwork使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Artwork类属于org.jaudiotagger.tag.datatype包,在下文中一共展示了Artwork类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: decode
import org.jaudiotagger.tag.datatype.Artwork; //导入依赖的package包/类
@Override
public Bitmap decode(int targetedWidth, int targetedHeight) {
Bitmap bitmap = null;
Artwork artwork = audioFile.getTag().getFirstArtwork();
if (null != artwork) {
byte[] artworkData = artwork.getBinaryData();
// First decode with inJustDecodeBounds=true to check dimensions
final BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeByteArray(artworkData, 0, artworkData.length, options);
// Calculate inSampleSize
options.inSampleSize = calculateInSampleSize(options, targetedWidth, targetedHeight);
// Decode bitmap with inSampleSize set
options.inJustDecodeBounds = false;
bitmap = BitmapFactory.decodeByteArray(artworkData, 0, artworkData.length, options);
}
return bitmap;
}
开发者ID:pierre-binauld,项目名称:music-tag,代码行数:23,代码来源:AudioFileBitmapDecoder.java
示例2: writeCoverArt
import org.jaudiotagger.tag.datatype.Artwork; //导入依赖的package包/类
public boolean writeCoverArt(Image lastfmCoverArt) throws MetadataException {
try {
File coverArtFile = imageUtils.saveCoverArtToFile(lastfmCoverArt, StringUtils.EMPTY);
Artwork artwork = artworkHelper.createArtwork();
artwork.setFromFile(coverArtFile);
tag.setField(artwork);
audioFile.commit();
return true;
} catch (KeyNotFoundException kne) {
throw new MetadataException(kne.getMessage());
} catch (FieldDataInvalidException fie) {
throw new MetadataException(fie.getMessage());
} catch (CannotWriteException nwe) {
throw new MetadataException(nwe.getMessage());
} catch (IOException ioe) {
throw new MetadataException(ioe.getMessage());
} catch (NullPointerException nue) {
throw new MetadataException(nue.getMessage());
}
}
开发者ID:josdem,项目名称:jmetadata,代码行数:21,代码来源:MetadataWriter.java
示例3: setAlbumArt
import org.jaudiotagger.tag.datatype.Artwork; //导入依赖的package包/类
public void setAlbumArt(File file, Bitmap artworkBitmap, Song song) throws IOException, TagException, ReadOnlyFileException, CannotReadException, InvalidAudioFrameException {
artworkBitmap = Bitmap.createScaledBitmap(artworkBitmap, 500, 500, false);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
artworkBitmap.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] byteArray = stream.toByteArray();
File artworkFile = new File(Environment.getExternalStorageDirectory() + "/artwork.jpg");
if (!artworkFile.exists())
artworkFile.createNewFile();
FileOutputStream out = new FileOutputStream(artworkFile);
artworkBitmap.compress(Bitmap.CompressFormat.JPEG, 90, out);
Artwork artwork = Artwork.createArtworkFromFile(artworkFile);
artwork.setBinaryData(byteArray);
AudioFile audioFile = AudioFileIO.read(file);
Tag tag = audioFile.getTagOrCreateAndSetDefault();
if (tag.getFirstArtwork() != null) {
tag.deleteArtworkField();
tag.setField(artwork);
} else {
tag.addField(artwork);
}
Uri uri = MusicUtils.getAlbumArtUri(song._albumId);
DiskCacheUtils.removeFromCache(uri.toString(), ImageLoader.getInstance().getDiskCache());
String path = FileUtils.getRealPathFromURI(uri);
new File(path).delete();
artworkFile.delete();
}
开发者ID:reyanshmishra,项目名称:Rey-MusicPlayer,代码行数:38,代码来源:AlbumsArtDownloadService.java
示例4: getCoverArt
import org.jaudiotagger.tag.datatype.Artwork; //导入依赖的package包/类
/**
* Bug in JAudioTagger null pointer exception when artwork.getImage()
*/
private Image getCoverArt(Metadata metadata) throws MetadataException {
try{
if(tag == null) return null;
Artwork artwork = tag.getFirstArtwork();
log.info(getTitle() + " has cover art?: " + (artwork != null));
return artwork==null ? null: artwork.getImage();
} catch(IllegalArgumentException iae){
return handleCoverArtException(metadata, iae);
} catch (IOException ioe){
return handleCoverArtException(metadata, ioe);
} catch (NullPointerException nue){
return handleCoverArtException(metadata, nue);
}
}
开发者ID:josdem,项目名称:jmetadata,代码行数:18,代码来源:MetadataReader.java
示例5: shouldWriteCoverArt
import org.jaudiotagger.tag.datatype.Artwork; //导入依赖的package包/类
@Test
public void shouldWriteCoverArt() throws Exception {
when(imageUtils.saveCoverArtToFile(image, StringUtils.EMPTY)).thenReturn(file);
when(artworkHelper.createArtwork()).thenReturn(artwork);
metadataWriter.writeCoverArt(image);
verify(imageUtils).saveCoverArtToFile(image, StringUtils.EMPTY);
verify(artwork).setFromFile(file);
verify(tag).setField(isA(Artwork.class));
verify(audioFile).commit();
}
开发者ID:josdem,项目名称:jmetadata,代码行数:13,代码来源:TestMetadataWriter.java
示例6: fetchDetails
import org.jaudiotagger.tag.datatype.Artwork; //导入依赖的package包/类
private void fetchDetails() {
File file = new File(SONG_PATH);
try {
AudioFile audioFile = AudioFileIO.read(file);
Tag tag = audioFile.getTagOrCreateAndSetDefault();
title = tag.getFirst(FieldKey.TITLE);
mTitleEditText.setText(title);
mTitleEditText.setSelection(title.length());
artist = tag.getFirst(FieldKey.ARTIST);
mArtistEditText.setText(artist);
mArtistEditText.setSelection(artist.length());
album = tag.getFirst(FieldKey.ALBUM);
mAlbumEditText.setText(album);
mAlbumEditText.setSelection(album.length());
albumArtist = tag.getFirst(FieldKey.ALBUM_ARTIST);
mAlbumArtistEditText.setText(albumArtist);
mAlbumArtistEditText.setSelection(albumArtist.length());
genre = tag.getFirst(FieldKey.GENRE);
mGenreEditText.setText(genre);
mGenreEditText.setSelection(genre.length());
producer = tag.getFirst(FieldKey.PRODUCER);
mProducerEditText.setText(producer);
mProducerEditText.setSelection(mProducerEditText.length());
year = tag.getFirst(FieldKey.YEAR);
mYearEditText.setText(year);
mYearEditText.setSelection(year.length());
track = tag.getFirst(FieldKey.TRACK);
mTrackEditText.setText(track);
mTrackEditText.setSelection(track.length());
totalTrack = tag.getFirst(FieldKey.TRACK_TOTAL);
mTotalTrackEditText.setText(totalTrack);
mTotalTrackEditText.setSelection(totalTrack.length());
comment = tag.getFirst(FieldKey.COMMENT);
mCommentsEditText.setText(comment);
mCommentsEditText.setSelection(comment.length());
List<Artwork> artwork = tag.getArtworkList();
if (artwork.size() > 0) {
byte[] image = artwork.get(0).getBinaryData();
Bitmap bitmap = BitmapFactory.decodeByteArray(image, 0, image.length);
// mCardView.setCardBackgroundColor(Palette.from(bitmap).generate().getC(R.color.deep_purple));
mAlbumArtImage.setImageBitmap(bitmap);
}
} catch (CannotReadException | IOException | TagException | ReadOnlyFileException | InvalidAudioFrameException e) {
e.printStackTrace();
Toast.makeText(this, R.string.track_is_malformed, Toast.LENGTH_SHORT).show();
finish();
}
}
开发者ID:reyanshmishra,项目名称:Rey-MusicPlayer,代码行数:67,代码来源:Id3TagEditorActivity.java
示例7: getArtwork
import org.jaudiotagger.tag.datatype.Artwork; //导入依赖的package包/类
private Artwork getArtwork(MediaFile file) throws Exception {
AudioFile audioFile = AudioFileIO.read(file.getFile());
Tag tag = audioFile.getTag();
return tag == null ? null : tag.getFirstArtwork();
}
开发者ID:sindremehus,项目名称:subsonic,代码行数:6,代码来源:JaudiotaggerParser.java
示例8: createArtwork
import org.jaudiotagger.tag.datatype.Artwork; //导入依赖的package包/类
public Artwork createArtwork() {
return new Artwork();
}
开发者ID:josdem,项目名称:jmetadata,代码行数:4,代码来源:ArtworkHelper.java
示例9: shouldCreateAnArtWork
import org.jaudiotagger.tag.datatype.Artwork; //导入依赖的package包/类
@Test
public void shouldCreateAnArtWork() throws Exception {
Artwork artwork = artworkHelper.createArtwork();
assertNotNull(artwork);
}
开发者ID:josdem,项目名称:jmetadata,代码行数:6,代码来源:TestArtworkHelper.java
注:本文中的org.jaudiotagger.tag.datatype.Artwork类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论