当前位置: 首页>>代码示例>>Java>>正文


Java InvalidDataException类代码示例

本文整理汇总了Java中com.mpatric.mp3agic.InvalidDataException的典型用法代码示例。如果您正苦于以下问题:Java InvalidDataException类的具体用法?Java InvalidDataException怎么用?Java InvalidDataException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


InvalidDataException类属于com.mpatric.mp3agic包,在下文中一共展示了InvalidDataException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: valid

import com.mpatric.mp3agic.InvalidDataException; //导入依赖的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)
    );
}
 
开发者ID:driver733,项目名称:VKMusicUploader,代码行数:26,代码来源:AdvancedTagFromMp3FileTest.java

示例2: valid

import com.mpatric.mp3agic.InvalidDataException; //导入依赖的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)
        )
    );
}
 
开发者ID:driver733,项目名称:VKMusicUploader,代码行数:18,代码来源:AdvancedTagVerifiedAlbumImageTest.java

示例3: invalid

import com.mpatric.mp3agic.InvalidDataException; //导入依赖的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)
        )
    );
}
 
开发者ID:driver733,项目名称:VKMusicUploader,代码行数:17,代码来源:AdvancedTagVerifiedAlbumImageTest.java

示例4: advancedTag

import com.mpatric.mp3agic.InvalidDataException; //导入依赖的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)
        )
    );
}
 
开发者ID:driver733,项目名称:VKMusicUploader,代码行数:18,代码来源:FallbackByteArrayTest.java

示例5: allTags

import com.mpatric.mp3agic.InvalidDataException; //导入依赖的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")
        )
    );
}
 
开发者ID:driver733,项目名称:VKMusicUploader,代码行数:22,代码来源:MessageTest.java

示例6: init

import com.mpatric.mp3agic.InvalidDataException; //导入依赖的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();
	}
}
 
开发者ID:dimattiami,项目名称:ytdl,代码行数:25,代码来源:MyMp3FileOverride.java

示例7: scanBlock

import com.mpatric.mp3agic.InvalidDataException; //导入依赖的package包/类
private int scanBlock(byte[] bytes, int bytesRead, int absoluteOffset, int offset) throws InvalidDataException {
	while (offset < bytesRead - MINIMUM_BUFFER_LENGTH) {
		MpegFrame frame = new MpegFrame(bytes[offset], bytes[offset + 1], bytes[offset + 2], bytes[offset + 3]);
		sanityCheckFrame(frame, absoluteOffset + offset);
		int newEndOffset = absoluteOffset + offset + frame.getLengthInBytes() - 1;
		if (newEndOffset < maxEndOffset()) {
			endOffset = absoluteOffset + offset + frame.getLengthInBytes() - 1;
			frameCount++;
			addBitrate(frame.getBitrate());
			offset += frame.getLengthInBytes();
		} else {
			break;
		}
	}
	return offset;
}
 
开发者ID:dimattiami,项目名称:ytdl,代码行数:17,代码来源:MyMp3FileOverride.java

示例8: initId3v2Tag

import com.mpatric.mp3agic.InvalidDataException; //导入依赖的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;
		}
	}
}
 
开发者ID:dimattiami,项目名称:ytdl,代码行数:22,代码来源:MyMp3FileOverride.java

示例9: importFile

import com.mpatric.mp3agic.InvalidDataException; //导入依赖的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();
}
 
开发者ID:MolaynoxX,项目名称:amperfi,代码行数:24,代码来源:DatabaseTest.java

示例10: getId3ByFile

import com.mpatric.mp3agic.InvalidDataException; //导入依赖的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);
}
 
开发者ID:martijn00,项目名称:MusicPlayerCodenameOne,代码行数:18,代码来源:MediaHelper.java

示例11: openMp3

import com.mpatric.mp3agic.InvalidDataException; //导入依赖的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);
}
 
开发者ID:djazz90,项目名称:LightningPlayer,代码行数:17,代码来源:PlayListMethods.java

示例12: playlistElementTest

import com.mpatric.mp3agic.InvalidDataException; //导入依赖的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());

}
 
开发者ID:djazz90,项目名称:LightningPlayer,代码行数:23,代码来源:ApplicationTestBase.java

示例13: init

import com.mpatric.mp3agic.InvalidDataException; //导入依赖的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.");
	}
}
 
开发者ID:cf86,项目名称:MP3ToolKit,代码行数:27,代码来源:MP3.java

示例14: composeNewFilename

import com.mpatric.mp3agic.InvalidDataException; //导入依赖的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;
}
 
开发者ID:mpatric,项目名称:mp3agic-examples,代码行数:17,代码来源:Mp3Rename.java

示例15: makeDirectory

import com.mpatric.mp3agic.InvalidDataException; //导入依赖的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;
}
 
开发者ID:mpatric,项目名称:mp3agic-examples,代码行数:18,代码来源:Mp3Move.java


注:本文中的com.mpatric.mp3agic.InvalidDataException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。