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


Java Mp3File类代码示例

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


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

示例1: valid

import com.mpatric.mp3agic.Mp3File; //导入依赖的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.Mp3File; //导入依赖的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.Mp3File; //导入依赖的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.Mp3File; //导入依赖的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.Mp3File; //导入依赖的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: stripMp3ID3v1

import com.mpatric.mp3agic.Mp3File; //导入依赖的package包/类
/**
 * Private helper method that strips ID3v1 tags from an mp3 file.
 * 
 * @param mp3File - Target Mp3File with ID3v1 tags to strip.
 * @return A Song object containing all the tags from the mp3File.
 */
private LocalSong stripMp3ID3v1(Mp3File mp3File) {
	if(!mp3File.hasId3v1Tag()) {
		throw new IllegalArgumentException("No such file exists!");
	}
	
	ID3v1 id3v1Tags = mp3File.getId3v1Tag();
	LocalSong mp3Song = new LocalSong();
	
	mp3Song.setTitle(id3v1Tags.getTitle());
	mp3Song.setArtist(id3v1Tags.getArtist());
	mp3Song.setAlbum(id3v1Tags.getAlbum());
	mp3Song.setLength("" + mp3File.getLengthInSeconds());
	
	return mp3Song;
}
 
开发者ID:brokenprogrammer,项目名称:RapidTunes,代码行数:22,代码来源:FileStripper.java

示例7: 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;
}
 
开发者ID:brokenprogrammer,项目名称:RapidTunes,代码行数:22,代码来源:FileStripper.java

示例8: openMp3

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

示例9: playlistElementTest

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

示例10: init

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

示例11: valid

import com.mpatric.mp3agic.Mp3File; //导入依赖的package包/类
@Test
public void valid()
    throws InvalidDataException, IOException, UnsupportedTagException {
    MatcherAssert.assertThat(
        "Failed to get the tag from Mp3 file",
        new BasicTagFromMp3File(
            new Mp3File(
                new File("src/test/resources/album/test.mp3")
            )
        ).construct().getAlbum(),
        Matchers.equalTo("Elegant Testing")
    );
}
 
开发者ID:driver733,项目名称:VKMusicUploader,代码行数:14,代码来源:BasicTagTest.java

示例12: missingTags

import com.mpatric.mp3agic.Mp3File; //导入依赖的package包/类
@Test
public void missingTags()
    throws InvalidDataException, IOException, UnsupportedTagException {
    MatcherAssert.assertThat(
        "Failed to process missing tags",
        new MessageBasic(
            new ID3v1AnnotatedSafe(
                new BasicTagFromMp3File(
                    new Mp3File(
                        new File(
                            "src/test/resources/album/testMissingTags.mp3"
                        )
                    )
                ).construct()
            ).getAlbum(),
            new ID3v1AnnotatedSafe(
                new BasicTagFromMp3File(
                    new Mp3File(
                        new File(
                            "src/test/resources/album/testMissingTags.mp3"
                        )
                    )
                ).construct()
            ).getArtist()
        ).construct(),
        Matchers.equalTo("")
    );
}
 
开发者ID:driver733,项目名称:VKMusicUploader,代码行数:29,代码来源:MessageTest.java

示例13: ID3v1AnnotatedSafeTest

import com.mpatric.mp3agic.Mp3File; //导入依赖的package包/类
public ID3v1AnnotatedSafeTest()
    throws InvalidDataException, IOException, UnsupportedTagException {
    this.tag = new ID3v1AnnotatedSafe(
        new BasicTagFromMp3File(
            new Mp3File("src/test/resources/album/test.mp3")
        ).construct()
    );
}
 
开发者ID:driver733,项目名称:VKMusicUploader,代码行数:9,代码来源:ID3v1AnnotatedSafeTest.java

示例14: removeTags

import com.mpatric.mp3agic.Mp3File; //导入依赖的package包/类
public void removeTags() {
	final Mp3File mp3 = path.getMp3();
	mp3.removeId3v1Tag();
	mp3.removeId3v2Tag();
	mp3.removeCustomTag();
	path.updateMP3(mp3);
}
 
开发者ID:JPDSousa,项目名称:rookit-core,代码行数:8,代码来源:TrackPathNormalizer.java

示例15: testRemoveTags

import com.mpatric.mp3agic.Mp3File; //导入依赖的package包/类
@Test
public final void testRemoveTags() {
	labRat.removeTags();
	assertNotEquals(originalTrack, testTrack);
	final Mp3File mp3 = testTrack.getMp3();
	assertFalse(mp3.hasCustomTag());
	assertFalse(mp3.hasId3v1Tag());
	assertFalse(mp3.hasId3v2Tag());
}
 
开发者ID:JPDSousa,项目名称:rookit-core,代码行数:10,代码来源:TrackPathNormalizerTest.java


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