本文整理汇总了Java中com.mpatric.mp3agic.UnsupportedTagException类的典型用法代码示例。如果您正苦于以下问题:Java UnsupportedTagException类的具体用法?Java UnsupportedTagException怎么用?Java UnsupportedTagException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
UnsupportedTagException类属于com.mpatric.mp3agic包,在下文中一共展示了UnsupportedTagException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: valid
import com.mpatric.mp3agic.UnsupportedTagException; //导入依赖的package包/类
@Test
public void valid()
throws InvalidDataException, IOException, UnsupportedTagException {
final Path path = Paths.get(
"src/test/resources/testTempAlbumCover.jpg"
);
Files.write(
path,
new AdvancedTagFromMp3File(
new Mp3File(
new File("src/test/resources/album/test.mp3")
)
).construct().getAlbumImage()
);
final File actual = path.toFile();
actual.deleteOnExit();
MatcherAssert.assertThat(
"Album cover image from tag did not match the original one",
FileUtils.contentEquals(
actual,
new File("src/test/resources/album/albumCover.jpg")
),
Matchers.equalTo(true)
);
}
示例2: valid
import com.mpatric.mp3agic.UnsupportedTagException; //导入依赖的package包/类
@Test
public void valid()
throws InvalidDataException, IOException, UnsupportedTagException {
final Path path = Paths.get("src/test/resources/album/test.mp3");
MatcherAssert.assertThat(
new AdvancedTagVerifiedAlbumImage(
new AdvancedTagFromMp3File(
new Mp3File(
path.toFile()
)
)
).construct().getAlbumImage(),
Matchers.equalTo(
Files.readAllBytes(this.image)
)
);
}
示例3: invalid
import com.mpatric.mp3agic.UnsupportedTagException; //导入依赖的package包/类
@Test(expected = IOException.class)
public void invalid()
throws IOException, InvalidDataException, UnsupportedTagException {
MatcherAssert.assertThat(
new AdvancedTagVerifiedAlbumImage(
new AdvancedTagFromMp3File(
new Mp3File(
"src/test/resources/album/testMissingTags.mp3"
)
)
).construct().getAlbumImage(),
Matchers.equalTo(
Files.readAllBytes(this.image)
)
);
}
示例4: advancedTag
import com.mpatric.mp3agic.UnsupportedTagException; //导入依赖的package包/类
@Test
public void advancedTag()
throws InvalidDataException, IOException, UnsupportedTagException {
MatcherAssert.assertThat(
new FallbackByteArray(
new ByteArrayImageFromAdvancedTag(
new AdvancedTagFromMp3File(
new Mp3File(this.audio)
)
),
new ByteArrayImageFromFile(this.audio)
).firstValid(),
Matchers.equalTo(
Files.readAllBytes(this.path)
)
);
}
示例5: allTags
import com.mpatric.mp3agic.UnsupportedTagException; //导入依赖的package包/类
@Test
public void allTags()
throws InvalidDataException, IOException, UnsupportedTagException {
final ID3v1 tag = new ID3v1AnnotatedSafe(
new BasicTagFromMp3File(
new Mp3File(
new File("src/test/resources/album/test.mp3")
)
).construct()
);
MatcherAssert.assertThat(
"Cannot construct a message with tags",
new MessageBasic(
tag.getAlbum(),
tag.getArtist()
).construct(),
Matchers.equalTo(
String.format("Album: Elegant Testing%nArtist: Test Man")
)
);
}
示例6: init
import com.mpatric.mp3agic.UnsupportedTagException; //导入依赖的package包/类
private void init(int bufferLength, boolean scanFile)
throws IOException, UnsupportedTagException, InvalidDataException {
if (bufferLength < MINIMUM_BUFFER_LENGTH + 1)
throw new IllegalArgumentException("Buffer too small");
this.bufferLength = bufferLength;
this.scanFile = scanFile;
RandomAccessFile randomAccessFile = new RandomAccessFile(file.getPath(), "r");
try {
initId3v1Tag(randomAccessFile);
scanFile(randomAccessFile);
if (startOffset < 0) {
throw new InvalidDataException("No mpegs frames found");
}
initId3v2Tag(randomAccessFile);
if (scanFile) {
initCustomTag(randomAccessFile);
}
} finally {
randomAccessFile.close();
}
}
示例7: initId3v2Tag
import com.mpatric.mp3agic.UnsupportedTagException; //导入依赖的package包/类
private void initId3v2Tag(RandomAccessFile file) throws IOException, UnsupportedTagException, InvalidDataException {
if (xingOffset == 0 || startOffset == 0) {
id3v2Tag = null;
} else {
int bufferLength;
if (hasXingFrame())
bufferLength = xingOffset;
else
bufferLength = startOffset;
byte[] bytes = new byte[bufferLength];
file.seek(0);
int bytesRead = file.read(bytes, 0, bufferLength);
if (bytesRead < bufferLength)
throw new IOException("Not enough bytes read");
try {
id3v2Tag = ID3v2TagFactory.createTag(bytes);
} catch (NoSuchTagException e) {
id3v2Tag = null;
}
}
}
示例8: importFile
import com.mpatric.mp3agic.UnsupportedTagException; //导入依赖的package包/类
@Test
public void importFile() throws SQLException, UnsupportedTagException, InvalidDataException, IOException {
LibraryDatabase db = new LibraryDatabase(new File("test2.db"));
db.importFile(new File("testResources/noise.mp3"));
db.reloadFiles();
assertEquals(1, db.getFiles().size());
assertEquals(1, db.getTags(ID3Helper.ID3Tag.ARTIST).size());
assertEquals(1, db.getTags(ID3Helper.ID3Tag.GENRE).size());
assertEquals("Brown Noise", db.getFiles().get(0).getTag(ID3Helper.ID3Tag.TITLE));
assertEquals("Brown Noise", db.getFiles().get(0).getTitle());
List<String> artists = db.getTags(ID3Helper.ID3Tag.ARTIST);
assertEquals(artists.size(), 1);
assertEquals(1, db.getLibraryFilesByPredicate(QLibraryFile.LibraryFile.title.contains("Noise")).size());
assertEquals(1, db.getLibraryFilesByPredicate(QLibraryFile.LibraryFile.artist.eq(artists.get(0))).size());
db.importFile(new File("testResources/noise.mp3"));
new File("test2.db").delete();
}
示例9: getId3ByFile
import com.mpatric.mp3agic.UnsupportedTagException; //导入依赖的package包/类
public static AbstractID3v2Tag getId3ByFile(String path) throws IOException, UnsupportedTagException, InvalidDataException, NoSuchTagException {
InputStream in = FileSystemStorage.getInstance().openInputStream(path);
// Get the size of the ID3 header and load only that into memory
TagHeader tagHeader = TagHeaderFactory.makeHeader(in);
int dataSize = (int) tagHeader.getDataSize();
byte[] data = new byte[dataSize];
in = FileSystemStorage.getInstance().openInputStream(path);
int read = in.read(data);
if (read != dataSize)
throw new IOException("Expected " + dataSize + " bytes.");
// Use the 2nd library to parse the ID3 tag.
return ID3v2TagFactory.createTag(data);
}
示例10: openMp3
import com.mpatric.mp3agic.UnsupportedTagException; //导入依赖的package包/类
public static void openMp3(final List<File> openedFiles, final Model model) {
ObservableList<PlaylistElement> addedNewPLEs = FXCollections.observableArrayList();
for (File file : openedFiles) {
try {
addedNewPLEs.add(new PlaylistElement(new Mp3File(file), file));
} catch (UnsupportedTagException | InvalidDataException
| IOException e1) {
log.error("File i/o error");
log.error("at " + file.getAbsolutePath());
log.error("", e1);
}
}
model.getPlaylist().addAll(addedNewPLEs);
}
示例11: playlistElementTest
import com.mpatric.mp3agic.UnsupportedTagException; //导入依赖的package包/类
@Test
public void playlistElementTest() throws UnsupportedTagException, InvalidDataException, IOException {
File id3v1only = FileUtils.getFile("src", "test", "resources", "id3v1test.mp3");
File id3v2only = FileUtils.getFile("src", "test", "resources", "id3v2test.mp3");
File both = FileUtils.getFile("src", "test", "resources", "id3v1+v2test.mp3");
File none = FileUtils.getFile("src", "test", "resources", "notagtest.mp3");
PlaylistElement ple = new PlaylistElement(new Mp3File(id3v1only), new File(id3v1only.getAbsolutePath()));
assertEquals("ccMixter", ple.getAlbum());
assertFalse(ple.getTitle().isEmpty());
PlaylistElement ple2 = new PlaylistElement(new Mp3File(id3v2only), new File(id3v2only.getAbsolutePath()));
assertEquals("ccMixter", ple2.getAlbum());
assertFalse(ple2.getTitle().isEmpty());
PlaylistElement ple3 = new PlaylistElement(new Mp3File(both), new File(both.getAbsolutePath()));
assertEquals("ccMixter", ple3.getAlbum());
assertFalse(ple3.getTitle().isEmpty());
PlaylistElement ple4 = new PlaylistElement(new Mp3File(none), new File(none.getAbsolutePath()));
assertEquals("", ple4.getAlbum());
assertFalse(ple4.getTitle().isEmpty());
}
示例12: init
import com.mpatric.mp3agic.UnsupportedTagException; //导入依赖的package包/类
@Override
public void init(String path, boolean removeID3v1, boolean addId3v1) throws AudioFileException {
try {
if (path.contains("\\"))
path = path.replace("/", "\\");
this.mp3 = new Mp3File(path);
this.path = path;
this.changed = false;
this.addId3v1Tag = true;
if (removeID3v1 && this.mp3.hasId3v1Tag())
this.mp3.removeId3v1Tag();
if (this.addId3v1Tag && !this.mp3.hasId3v1Tag())
this.mp3.setId3v1Tag(new ID3v1Tag());
if (!this.mp3.hasId3v2Tag()) {
this.mp3.setId3v2Tag(new ID3v24Tag());
this.hasID3Tag = false;
logger.log(Level.FINER, "mp3 has not ID3v2 tag, generate one. successful: " + this.mp3.hasId3v2Tag());
}
} catch (UnsupportedTagException | InvalidDataException | IOException e) {
logger.log(Level.SEVERE, "Error while init Audio file:\n" + LogUtil.getStackTrace(e), e);
throw new AudioFileException("Error while init Audio file.");
}
}
示例13: composeNewFilename
import com.mpatric.mp3agic.UnsupportedTagException; //导入依赖的package包/类
protected String composeNewFilename(String filename, String rename) throws UnsupportedTagException, InvalidDataException, IOException {
ID3Wrapper id3Wrapper = createId3Wrapper(filename);
String newFilename = rename;
newFilename = BufferTools.substitute(newFilename, "@N", formatTrack(id3Wrapper.getTrack()));
newFilename = BufferTools.substitute(newFilename, "@A", id3Wrapper.getArtist());
newFilename = BufferTools.substitute(newFilename, "@T", id3Wrapper.getTitle());
newFilename = BufferTools.substitute(newFilename, "@L", id3Wrapper.getAlbum());
newFilename = BufferTools.substitute(newFilename, "@Y", id3Wrapper.getYear());
newFilename = BufferTools.substitute(newFilename, "@G", id3Wrapper.getGenreDescription());
newFilename = BufferTools.substitute(newFilename, "?", null);
newFilename = BufferTools.substitute(newFilename, "*", null);
newFilename = BufferTools.substitute(newFilename, "/", null);
newFilename = BufferTools.substitute(newFilename, "\\", null);
newFilename = BufferTools.substitute(newFilename, " ", " ");
return newFilename;
}
示例14: makeDirectory
import com.mpatric.mp3agic.UnsupportedTagException; //导入依赖的package包/类
private String makeDirectory(String filename, String destination) throws UnsupportedTagException, InvalidDataException, IOException {
ID3Wrapper id3Wrapper = createId3Wrapper(filename);
String artist = stripString(id3Wrapper.getArtist());
String album = stripString(id3Wrapper.getAlbum());
String dest = destination;
if (dest.charAt(dest.length() - 1) != '/') dest += "/";
if (artist != null && artist.length() > 0) {
dest += artist;
dest += '/';
mkdir(dest);
if (album != null && album.length() > 0) {
dest += album;
mkdir(dest);
}
}
return dest;
}
示例15: writePlaylist
import com.mpatric.mp3agic.UnsupportedTagException; //导入依赖的package包/类
/**
* Writes a playlist file for the specified items.
*
* <p>Playlist generation events do not include information about which playlist is being
* generated: progress is reported in terms of the total number of items in all playlists. This
* method therefore takes two parameters - {@code startIndex} and {@code totalItems} that are
* used to indicate the position of this sub-task relative to the larger process.</p>
*/
private void writePlaylist(File playlistFile,
List<SyncPlan.Item> items,
int startIndex,
int totalItems) throws IOException, UnsupportedTagException, InvalidDataException {
StringBuilder sb = new StringBuilder();
sb.append("#EXTM3U\n\n");
int i = startIndex;
for (SyncPlan.Item item : items) {
writeItemToPlaylistBuffer(sb, item);
bus.post(new GeneratePlaylistsProgressChangedEvent(this, ++i, totalItems));
}
Files.write(sb.toString(), playlistFile, Charsets.UTF_8);
}