當前位置: 首頁>>代碼示例>>Java>>正文


Java FieldKey類代碼示例

本文整理匯總了Java中org.jaudiotagger.tag.FieldKey的典型用法代碼示例。如果您正苦於以下問題:Java FieldKey類的具體用法?Java FieldKey怎麽用?Java FieldKey使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


FieldKey類屬於org.jaudiotagger.tag包,在下文中一共展示了FieldKey類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: from

import org.jaudiotagger.tag.FieldKey; //導入依賴的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;
	}
}
 
開發者ID:jakemanning,項目名稱:boomer-tuner,代碼行數:23,代碼來源:Song.java

示例2: getTag

import org.jaudiotagger.tag.FieldKey; //導入依賴的package包/類
@Override
protected Tag getTag(RandomAccessFile raf) throws CannotReadException, IOException
{
    final RealChunk cont = findContChunk(raf);
    final DataInputStream dis = cont.getDataInputStream();
    final String title = Utils.readString(dis, Utils.readUint16(dis));
    final String author = Utils.readString(dis, Utils.readUint16(dis));
    final String copyright = Utils.readString(dis, Utils.readUint16(dis));
    final String comment = Utils.readString(dis, Utils.readUint16(dis));
    final RealTag rv = new RealTag();
    // NOTE: frequently these fields are off-by-one, thus the crazy
    // logic below...
    try
    {
        rv.addField(FieldKey.TITLE,(title.length() == 0 ? author : title));
        rv.addField(FieldKey.ARTIST, title.length() == 0 ? copyright : author);
        rv.addField(FieldKey.COMMENT,comment);
    }
    catch(FieldDataInvalidException fdie)
    {
        throw new RuntimeException(fdie);
    }
    return rv;
}
 
開發者ID:GlennioTech,項目名稱:MetadataEditor,代碼行數:25,代碼來源:RealFileReader.java

示例3: insertLyrics

import org.jaudiotagger.tag.FieldKey; //導入依賴的package包/類
/**
 * Insert Lyrics
 *
 * @param path
 * @param lyrics
 * @return
 */
public static boolean insertLyrics(String path, String lyrics) {
    File f = new File(path);
    if (f.exists()) {
        try {
            AudioFile audioFile = AudioFileIO.read(f);
            if (audioFile == null) {
                return false;
            }
            TagOptionSingleton.getInstance().setAndroid(true);
            Tag tag = audioFile.getTag();
            if (tag == null) {
                return false;
            }
            tag.deleteField(FieldKey.LYRICS);
            tag.setField(FieldKey.LYRICS, lyrics);
            audioFile.setTag(tag);
            AudioFileIO.write(audioFile);
            return true;
        } catch (CannotReadException | CannotWriteException | InvalidAudioFrameException | TagException | IOException | ReadOnlyFileException e) {
            e.printStackTrace();
        }
    }
    return false;
}
 
開發者ID:RajneeshSingh007,項目名稱:MusicX-music-player,代碼行數:32,代碼來源:LyricsHelper.java

示例4: getTag

import org.jaudiotagger.tag.FieldKey; //導入依賴的package包/類
@Override
protected Tag getTag(RandomAccessFile raf) throws CannotReadException, IOException {
    final RealChunk cont = findContChunk(raf);
    final DataInputStream dis = cont.getDataInputStream();
    final String title = Utils.readString(dis, Utils.readUint16(dis));
    final String author = Utils.readString(dis, Utils.readUint16(dis));
    final String copyright = Utils.readString(dis, Utils.readUint16(dis));
    final String comment = Utils.readString(dis, Utils.readUint16(dis));
    final RealTag rv = new RealTag();
    // NOTE: frequently these fields are off-by-one, thus the crazy
    // logic below...
    try {
        rv.addField(FieldKey.TITLE, (title.length() == 0 ? author : title));
        rv.addField(FieldKey.ARTIST, title.length() == 0 ? copyright : author);
        rv.addField(FieldKey.COMMENT, comment);
    } catch (FieldDataInvalidException fdie) {
        throw new RuntimeException(fdie);
    }
    return rv;
}
 
開發者ID:openaudible,項目名稱:openaudible,代碼行數:21,代碼來源:RealFileReader.java

示例5: tryTags

import org.jaudiotagger.tag.FieldKey; //導入依賴的package包/類
/**
 * Try reading tags in given order. Start with first and continue with next
 * as long as previous ones are not found.
 * 
 * @return Content of the first existing tag as string, or empty string if
 *         none was found (to be consistent with JAudioTagger)
 */
private String tryTags(FieldKey... fieldKeys) {
	for (FieldKey fieldKey : fieldKeys) {
		String value;
		try {
			value = tag.getFirst(fieldKey);
		} catch (UnsupportedOperationException e) {
			continue;
		}

		if (StringUtils.isNotBlank(value))
			return StringUtils.trim(value);
	}

	return "";
}
 
開發者ID:CedricReichenbach,項目名稱:audiomerge,代碼行數:23,代碼來源:FileSong.java

示例6: getMp3Info

import org.jaudiotagger.tag.FieldKey; //導入依賴的package包/類
/**
 * 獲取mp3信息
 *
 * @return
 */
public Mp3Info getMp3Info() {
    if (this.mp3Info == null) {
        try {
            MP3File mp3 = new MP3File(this.mSourceMp3File);
            ID3v1Tag v1 = mp3.getID3v1Tag();
            String encoding = v1.getEncoding();
            MP3AudioHeader header = (MP3AudioHeader) mp3.getAudioHeader();
            this.mp3Info = new Mp3Info();
            this.mp3Info.setTitle(StringUtil.convertEncode(v1.getFirst(FieldKey.TITLE), encoding));
            this.mp3Info.setArtist(StringUtil.convertEncode(v1.getFirst(FieldKey.ARTIST), encoding));
            this.mp3Info.setAlbum(StringUtil.convertEncode(v1.getFirst(FieldKey.ALBUM), encoding));
            this.mp3Info.setTrackLength(header.getTrackLength());
            this.mp3Info.setBiteRate(header.getBitRate());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    return this.mp3Info;
}
 
開發者ID:zyl409214686,項目名稱:Mp3Cutter,代碼行數:25,代碼來源:Mp3CutLogic.java

示例7: runCommit

import org.jaudiotagger.tag.FieldKey; //導入依賴的package包/類
@Override
protected void runCommit(TableEntry entry)
{
	Tag tag = Utils.getTagFromAudioFile(entry.FilePath);
	FieldKey field = Utils.getFieldKeyFromString(entry.Status);
	
	try
	{
		tag.setField(field, entry.NewTitle);
		Utils.saveTagToFile(entry.FilePath, tag);
		LOG.log(Level.FINER, "Successfully replaced text: " + tag.toString());
	}
	catch (KeyNotFoundException | FieldDataInvalidException e)
	{
		LOG.log(Level.WARNING, "Failed to replace text in tag: " + entry.FilePath);
	}
}
 
開發者ID:Apophenic,項目名稱:iD3,代碼行數:18,代碼來源:FindAndReplacePanel.java

示例8: runFunction

import org.jaudiotagger.tag.FieldKey; //導入依賴的package包/類
@Override
public void runFunction(Entry<String, Map> entry)
{
	if(chckDelArt.isSelected())
	{
		Functions.deleteField(entry, FieldKey.MEDIA); // Flag to delete artwork NOT media
	}
	if(chckDelLyrics.isSelected())
	{
		Functions.deleteField(entry, FieldKey.LYRICS);
	}
	if(chckDelRatings.isSelected())
	{
		Functions.deleteField(entry, FieldKey.RATING);
	}
}
 
開發者ID:Apophenic,項目名稱:iD3,代碼行數:17,代碼來源:DeleteFieldsPanel.java

示例9: runCommit

import org.jaudiotagger.tag.FieldKey; //導入依賴的package包/類
@Override
protected void runCommit(TableEntry entry)
{
	try
	{
		Tag tag = Utils.getTagFromAudioFile(entry.FilePath);
		tag.setField(FieldKey.TITLE, entry.NewTitle);
		
		Utils.saveTagToFile(entry.FilePath, tag);
		LOG.log(Level.FINE, "Successfully removed artist name from: " + tag.toString());
	}
	catch (TagException e) 
	{
		LOG.log(Level.WARNING, "Failed to remove artist name from title: " + entry.FilePath);
	}
}
 
開發者ID:Apophenic,項目名稱:iD3,代碼行數:17,代碼來源:ArtistInNamePanel.java

示例10: runCommit

import org.jaudiotagger.tag.FieldKey; //導入依賴的package包/類
@Override
protected void runCommit(TableEntry entry)
{
	try
	{
		Tag tag = AudioFileIO.read(new File(entry.FilePath)).getTag();
		tag.setField(FieldKey.TITLE, entry.NewTitle);
		tag.setField(FieldKey.TRACK, entry.TrackNumber);
		
		Utils.saveTagToFile(entry.FilePath, tag);
		LOG.log(Level.FINE, "Track number removed from name: " + tag.toString());
	}
	catch (CannotReadException | IOException | TagException
			| ReadOnlyFileException| InvalidAudioFrameException e)
	{
		LOG.log(Level.WARNING, "Failed to write title w/o track num to tag: " + entry.FilePath);
	}
}
 
開發者ID:Apophenic,項目名稱:iD3,代碼行數:19,代碼來源:NumberInNamePanel.java

示例11: saveMetaData

import org.jaudiotagger.tag.FieldKey; //導入依賴的package包/類
private void saveMetaData(final InfoFrame fr) {
	final Map<FieldKey, String> data = new HashMap<FieldKey, String>();
	data.put(FieldKey.ARTIST, fr.getArtist());
	data.put(FieldKey.ALBUM_ARTIST, fr.getAlbumArtist());
	data.put(FieldKey.CONDUCTOR, fr.getArtist());
	data.put(FieldKey.ALBUM, fr.getAlbum());
	data.put(FieldKey.TITLE, fr.getSongtitle());
	data.put(FieldKey.TRACK, fr.getTrack());
	data.put(FieldKey.TRACK_TOTAL, fr.getTrackCount());
	data.put(FieldKey.YEAR, fr.getYear());
	data.put(FieldKey.MOOD, fr.getMood());

	data.put(FieldKey.GENRE, fr.getGenre());
	data.put(FieldKey.TEMPO, fr.getTempo());
	data.put(FieldKey.COMMENT, entry.getDownloadTempFile().getAbsolutePath());

	entry.getStepInfo().put("meta.data", data);

	fr.getTagEditor().writeAllFields(data);
	fr.getTagEditor().writeArtwork(fr.getArtworkImage());
	fr.getTagEditor().commit();
	nextStep();
}
 
開發者ID:Zahlii,項目名稱:Advanced-Youtube-Downloader,代碼行數:24,代碼來源:StepMetaSearch.java

示例12: doInBackground

import org.jaudiotagger.tag.FieldKey; //導入依賴的package包/類
@Override
protected Boolean doInBackground(Object... params) {
    Lyrics editedLyrics = (Lyrics) params[0];
    File musicFile = (File) params[1];
    boolean failed = false;

    if (musicFile != null)
        try {
            AudioFile af = AudioFileIO.read(musicFile);
            TagOptionSingleton.getInstance().setAndroid(true);
            Tag tags = af.getTag();
            tags.setField(FieldKey.ARTIST, editedLyrics.getArtist());
            tags.setField(FieldKey.TITLE, editedLyrics.getTitle());
            tags.setField(FieldKey.LYRICS, Html.fromHtml(editedLyrics.getText()).toString());
            af.setTag(tags);
            AudioFileIO.write(af);
        } catch (CannotReadException | IOException | ReadOnlyFileException | TagException
                | InvalidAudioFrameException | NullPointerException | CannotWriteException e) {
            e.printStackTrace();
            failed = true;
        }
    return failed;
}
 
開發者ID:QuickLyric,項目名稱:QuickLyric,代碼行數:24,代碼來源:Id3Writer.java

示例13: getLyrics

import org.jaudiotagger.tag.FieldKey; //導入依賴的package包/類
public static Lyrics getLyrics(Context context, String artist, String title, boolean requestPermission) {
    String text = null;
    try {
        for (File file : getFiles(context, artist, title, requestPermission)) {
            AudioFile af = AudioFileIO.read(file);
            TagOptionSingleton.getInstance().setAndroid(true);
            Tag tag = af.getTag();
            text = tag.getFirst(FieldKey.LYRICS);
            if (!text.isEmpty()) {
                text = text.replaceAll("\n", "<br/>");
                break;
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
    if (TextUtils.isEmpty(text))
        return null;
    Lyrics lyrics = new Lyrics(POSITIVE_RESULT);
    lyrics.setArtist(artist);
    lyrics.setTitle(title);
    lyrics.setText(text);
    lyrics.setSource("Storage");
    return lyrics;
}
 
開發者ID:QuickLyric,項目名稱:QuickLyric,代碼行數:27,代碼來源:Id3Reader.java

示例14: addFields

import org.jaudiotagger.tag.FieldKey; //導入依賴的package包/類
private void addFields(ParserResultItem result, Tag tag, FieldKey fieldKey,
		ParserFieldEnum parserField) {
	List<TagField> list = tag.getFields(fieldKey);
	if (list != null && list.size() > 0) {
		for (TagField field : list)
			result.addField(parserField, field);
		return;
	}
	String f = tag.getFirst(fieldKey);
	if (f == null)
		return;
	f = f.trim();
	if (f.length() == 0)
		return;
	result.addField(parserField, f);
}
 
開發者ID:jaeksoft,項目名稱:opensearchserver,代碼行數:17,代碼來源:AudioParser.java

示例15: writeTrackNumber

import org.jaudiotagger.tag.FieldKey; //導入依賴的package包/類
public boolean writeTrackNumber(String trackNumber) throws MetadataException {
	try {
		if(StringUtils.isEmpty(trackNumber)){
			return false;
		}
		tag.setField(FieldKey.TRACK, trackNumber);
		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());
	}
}
 
開發者ID:josdem,項目名稱:jmetadata,代碼行數:17,代碼來源:MetadataWriter.java


注:本文中的org.jaudiotagger.tag.FieldKey類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。