本文整理汇总了Java中org.jaudiotagger.tag.TagOptionSingleton类的典型用法代码示例。如果您正苦于以下问题:Java TagOptionSingleton类的具体用法?Java TagOptionSingleton怎么用?Java TagOptionSingleton使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TagOptionSingleton类属于org.jaudiotagger.tag包,在下文中一共展示了TagOptionSingleton类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getTotalAsText
import org.jaudiotagger.tag.TagOptionSingleton; //导入依赖的package包/类
/**
* Get Total padded
*
* @return
*/
public String getTotalAsText()
{
//Don't Pad
StringBuffer sb = new StringBuffer();
if (!TagOptionSingleton.getInstance().isPadNumbers())
{
return rawTotal;
}
else
{
padNumber(sb, total, TagOptionSingleton.getInstance().getPadNumberTotalLength());
}
return sb.toString();
}
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:21,代码来源:PartOfSet.java
示例2: read
import org.jaudiotagger.tag.TagOptionSingleton; //导入依赖的package包/类
/**
*
*
*
*/
public void read(ByteBuffer byteBuffer) throws InvalidTagException
{
String lineString;
byte[] buffer = new byte[5];
// read the 5 character size
byteBuffer.get(buffer, 0, 5);
int size = Integer.parseInt(new String(buffer, 0, 5));
if ((size == 0) && (!TagOptionSingleton.getInstance().isLyrics3KeepEmptyFieldIfRead()))
{
throw new InvalidTagException("Lyircs3v2 Field has size of zero.");
}
buffer = new byte[size];
// read the SIZE length description
byteBuffer.get(buffer);
lineString = new String(buffer);
readString(lineString);
}
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:29,代码来源:FieldFrameBodyLYR.java
示例3: readHeader
import org.jaudiotagger.tag.TagOptionSingleton; //导入依赖的package包/类
/**
* This is called by superclass when attempt to read data from file.
*
* @param file
* @return
* @throws InvalidTagException
* @throws IOException
*/
protected int readHeader(RandomAccessFile file) throws InvalidTagException, IOException
{
int size;
byte[] buffer = new byte[5];
// read the 5 character size
file.read(buffer, 0, 5);
size = Integer.parseInt(new String(buffer, 0, 5));
if ((size == 0) && (!TagOptionSingleton.getInstance().isLyrics3KeepEmptyFieldIfRead()))
{
throw new InvalidTagException("Lyircs3v2 Field has size of zero.");
}
return size;
}
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:25,代码来源:AbstractLyrics3v2FieldFrameBody.java
示例4: read
import org.jaudiotagger.tag.TagOptionSingleton; //导入依赖的package包/类
public void read(ByteBuffer byteBuffer) throws InvalidTagException
{
String imageString;
byte[] buffer = new byte[5];
// read the 5 character size
byteBuffer.get(buffer, 0, 5);
int size = Integer.parseInt(new String(buffer, 0, 5));
if ((size == 0) && (!TagOptionSingleton.getInstance().isLyrics3KeepEmptyFieldIfRead()))
{
throw new InvalidTagException("Lyircs3v2 Field has size of zero.");
}
buffer = new byte[size];
// read the SIZE length description
byteBuffer.get(buffer);
imageString = new String(buffer);
readString(imageString);
}
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:24,代码来源:FieldFrameBodyIMG.java
示例5: getUnicodeTextEncoding
import org.jaudiotagger.tag.TagOptionSingleton; //导入依赖的package包/类
/**
* Sets the text encoding to best Unicode type for the version
*
* @param header
* @return
*/
public static byte getUnicodeTextEncoding(AbstractTagFrame header)
{
if (header == null)
{
logger.warning("Header has not yet been set for this framebody");
return TextEncoding.UTF_16;
}
else if (header instanceof ID3v24Frame)
{
return TagOptionSingleton.getInstance().getId3v24UnicodeTextEncoding();
}
else
{
return TextEncoding.UTF_16;
}
}
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:23,代码来源:ID3TextEncodingConversion.java
示例6: write
import org.jaudiotagger.tag.TagOptionSingleton; //导入依赖的package包/类
/**
* If the description cannot be encoded using current encoder, change the encoder
*/
public void write(ByteArrayOutputStream tagBuffer)
{
if(TagOptionSingleton.getInstance().isAPICDescriptionITunesCompatible())
{
this.setTextEncoding(TextEncoding.ISO_8859_1);
if (!((AbstractString) getObject(DataTypes.OBJ_DESCRIPTION)).canBeEncoded())
{
setDescription("");
}
}
else
{
if (!((AbstractString) getObject(DataTypes.OBJ_DESCRIPTION)).canBeEncoded())
{
this.setTextEncoding(TextEncoding.UTF_16);
}
}
super.write(tagBuffer);
}
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:23,代码来源:FrameBodyAPIC.java
示例7: deleteTagChunk
import org.jaudiotagger.tag.TagOptionSingleton; //导入依赖的package包/类
/**
* Delete Tag Chunk
* <p/>
* Can be used when chunk is not the last chunk
* <p/>
* Continually copy a 4mb chunk, write the chunk and repeat until the rest of the file after the tag
* is rewritten
*
* @param fc
* @param endOfExistingChunk
* @param lengthTagChunk
* @throws IOException
*/
private void deleteTagChunk(final FileChannel fc, int endOfExistingChunk, final int lengthTagChunk) throws IOException {
//Position for reading after the tag
fc.position(endOfExistingChunk);
final ByteBuffer buffer = ByteBuffer.allocate((int) TagOptionSingleton.getInstance().getWriteChunkSize());
while (fc.read(buffer) >= 0 || buffer.position() != 0) {
buffer.flip();
final long readPosition = fc.position();
fc.position(readPosition - lengthTagChunk - buffer.limit());
fc.write(buffer);
fc.position(readPosition);
buffer.compact();
}
//Truncate the file after the last chunk
final long newLength = fc.size() - lengthTagChunk;
logger.config(loggingName + " Setting new length to:" + newLength);
fc.truncate(newLength);
}
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:32,代码来源:WavTagWriter.java
示例8: read
import org.jaudiotagger.tag.TagOptionSingleton; //导入依赖的package包/类
/**
* Read file and return tag metadata
*
* @param file
* @return
* @throws CannotReadException
* @throws IOException
*/
public WavTag read(File file) throws CannotReadException, IOException {
logger.config(loggingName + " Read Tag:start");
WavTag tag = new WavTag(TagOptionSingleton.getInstance().getWavOptions());
FileChannel fc = new FileOutputStream(file.getAbsolutePath(), false).getChannel();
if (WavRIFFHeader.isValidHeader(fc)) {
while (fc.position() < fc.size()) {
if (!readChunk(fc, tag)) {
break;
}
}
} else {
throw new CannotReadException(loggingName + " Wav RIFF Header not valid");
}
createDefaultMetadataTagsIfMissing(tag);
logger.config(loggingName + " Read Tag:end");
return tag;
}
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:26,代码来源:WavTagReader.java
示例9: writeDataInChunks
import org.jaudiotagger.tag.TagOptionSingleton; //导入依赖的package包/类
/**
* Write the remainder of data in read channel to write channel data in {@link TagOptionSingleton#getWriteChunkSize()}
* chunks, needed if writing large amounts of data.
*
* @param fileReadChannel
* @param fileWriteChannel
* @throws IOException
* @throws CannotWriteException
*/
private void writeDataInChunks(FileChannel fileReadChannel, FileChannel fileWriteChannel) throws IOException, CannotWriteException
{
long amountToBeWritten = fileReadChannel.size() - fileReadChannel.position();
long written = 0;
long chunksize = TagOptionSingleton.getInstance().getWriteChunkSize();
long count = amountToBeWritten / chunksize;
long mod = amountToBeWritten % chunksize;
for (int i = 0; i < count; i++)
{
written += fileWriteChannel.transferFrom(fileReadChannel, fileWriteChannel.position(), chunksize);
fileWriteChannel.position(fileWriteChannel.position() + chunksize);
}
if(mod > 0)
{
written += fileWriteChannel.transferFrom(fileReadChannel, fileWriteChannel.position(), mod);
if (written != amountToBeWritten)
{
throw new CannotWriteException("Was meant to write " + amountToBeWritten + " bytes but only written " + written + " bytes");
}
}
}
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:33,代码来源:Mp4TagWriter.java
示例10: delete
import org.jaudiotagger.tag.TagOptionSingleton; //导入依赖的package包/类
/**
* Delete the tag (if any) present in the given file
*
* @param af The file to process
*
* @throws CannotWriteException if anything went wrong
* @throws org.jaudiotagger.audio.exceptions.CannotReadException
*/
@Override
public void delete(AudioFile af) throws CannotReadException, CannotWriteException
{
File file = af.getFile();
if (TagOptionSingleton.getInstance().isCheckIsWritable() && !file.canWrite())
{
throw new CannotWriteException(ErrorMessage.GENERAL_DELETE_FAILED
.getMsg(file.getAbsolutePath()));
}
if (af.getFile().length() <= MINIMUM_FILESIZE)
{
throw new CannotWriteException(ErrorMessage.GENERAL_DELETE_FAILED_BECAUSE_FILE_IS_TOO_SMALL
.getMsg(file));
}
deleteTag(af.getTag(), file);
}
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:27,代码来源:AudioFileWriter2.java
示例11: write
import org.jaudiotagger.tag.TagOptionSingleton; //导入依赖的package包/类
/**
* Replace with new tag
*
* @param af The file we want to process
* @throws CannotWriteException
*/
@Override
public void write(AudioFile af) throws CannotWriteException
{
File file = af.getFile();
if (TagOptionSingleton.getInstance().isCheckIsWritable() && !file.canWrite())
{
logger.severe(ErrorMessage.GENERAL_WRITE_FAILED.getMsg(af.getFile()
.getPath()));
throw new CannotWriteException(ErrorMessage.GENERAL_WRITE_FAILED_TO_OPEN_FILE_FOR_EDITING
.getMsg(file.getAbsolutePath()));
}
if (af.getFile().length() <= MINIMUM_FILESIZE)
{
throw new CannotWriteException(ErrorMessage.GENERAL_WRITE_FAILED_BECAUSE_FILE_IS_TOO_SMALL
.getMsg(file));
}
writeTag(af.getTag(), file);
}
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:27,代码来源:AudioFileWriter2.java
示例12: precheckWrite
import org.jaudiotagger.tag.TagOptionSingleton; //导入依赖的package包/类
/**
* Prechecks before normal write
* <p/>
* <ul>
* <li>If the tag is actually empty, remove the tag</li>
* <li>if the file is not writable, throw exception
* <li>
* <li>If the file is too small to be a valid file, throw exception
* <li>
* </ul>
*
* @param af
* @throws CannotWriteException
*/
private void precheckWrite(AudioFile af) throws CannotWriteException {
// Preliminary checks
try {
if (af.getTag().isEmpty()) {
delete(af);
return;
}
} catch (CannotReadException re) {
throw new CannotWriteException(ErrorMessage.GENERAL_WRITE_FAILED.getMsg(af.getFile().getPath()));
}
File file = af.getFile();
if (TagOptionSingleton.getInstance().isCheckIsWritable() && !file.canWrite()) {
logger.severe(ErrorMessage.GENERAL_WRITE_FAILED.getMsg(af.getFile().getPath()));
throw new CannotWriteException(ErrorMessage.GENERAL_WRITE_FAILED_TO_OPEN_FILE_FOR_EDITING.getMsg(file.getAbsolutePath()));
}
if (af.getFile().length() <= MINIMUM_FILESIZE) {
logger.severe(ErrorMessage.GENERAL_WRITE_FAILED_BECAUSE_FILE_IS_TOO_SMALL.getMsg(file.getAbsolutePath()));
throw new CannotWriteException(ErrorMessage.GENERAL_WRITE_FAILED_BECAUSE_FILE_IS_TOO_SMALL.getMsg(file.getAbsolutePath()));
}
}
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:37,代码来源:AudioFileWriter.java
示例13: createDefaultTag
import org.jaudiotagger.tag.TagOptionSingleton; //导入依赖的package包/类
public static Tag createDefaultTag()
{
if(TagOptionSingleton.getInstance().getID3V2Version()== ID3V2Version.ID3_V24)
{
return new ID3v24Tag();
}
else if(TagOptionSingleton.getInstance().getID3V2Version()==ID3V2Version.ID3_V23)
{
return new ID3v23Tag();
}
else if(TagOptionSingleton.getInstance().getID3V2Version()==ID3V2Version.ID3_V22)
{
return new ID3v22Tag();
}
//Default in case not set somehow
return new ID3v24Tag();
}
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:18,代码来源:Dsf.java
示例14: getTagAndConvertOrCreateAndSetDefault
import org.jaudiotagger.tag.TagOptionSingleton; //导入依赖的package包/类
/**
* Get the tag and convert to the default tag version or if the file doesn't have one at all, create a default tag
* set as tag for this file
*
* Conversions are currently only necessary/available for formats that support ID3
*
* @return
*/
public Tag getTagAndConvertOrCreateAndSetDefault()
{
Tag tag = getTagOrCreateDefault();
/* TODO Currently only works for Dsf We need additional check here for Wav and Aif because they wrap the ID3 tag so never return
* null for getTag() and the wrapper stores the location of the existing tag, would that be broken if tag set to something else
*/
if(tag instanceof AbstractID3v2Tag)
{
Tag convertedTag = convertID3Tag((AbstractID3v2Tag)tag, TagOptionSingleton.getInstance().getID3V2Version());
if(convertedTag!=null)
{
setTag(convertedTag);
}
else
{
setTag(tag);
}
}
else
{
setTag(tag);
}
return getTag();
}
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:34,代码来源:AudioFile.java
示例15: precheck
import org.jaudiotagger.tag.TagOptionSingleton; //导入依赖的package包/类
/**
* Check can write to file
*
* @param file
* @throws IOException
*/
public void precheck(File file) throws IOException {
if (!file.exists()) {
logger.severe(ErrorMessage.GENERAL_WRITE_FAILED_BECAUSE_FILE_NOT_FOUND.getMsg(file.getName()));
throw new IOException(ErrorMessage.GENERAL_WRITE_FAILED_BECAUSE_FILE_NOT_FOUND.getMsg(file.getName()));
}
if (TagOptionSingleton.getInstance().isCheckIsWritable() && !file.canWrite()) {
logger.severe(ErrorMessage.GENERAL_WRITE_FAILED.getMsg(file.getName()));
throw new IOException(ErrorMessage.GENERAL_WRITE_FAILED.getMsg(file.getName()));
}
if (file.length() <= MINIMUM_FILESIZE) {
logger.severe(ErrorMessage.GENERAL_WRITE_FAILED_BECAUSE_FILE_IS_TOO_SMALL.getMsg(file.getName()));
throw new IOException(ErrorMessage.GENERAL_WRITE_FAILED_BECAUSE_FILE_IS_TOO_SMALL.getMsg(file.getName()));
}
}
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:23,代码来源:MP3File.java
示例16: insertLyrics
import org.jaudiotagger.tag.TagOptionSingleton; //导入依赖的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
示例17: toString
import org.jaudiotagger.tag.TagOptionSingleton; //导入依赖的package包/类
public String toString() {
//Don't Pad
StringBuffer sb = new StringBuffer();
if (!TagOptionSingleton.getInstance().isPadNumbers()) {
return rawText;
} else {
if (count != null) {
padNumber(sb, count, TagOptionSingleton.getInstance().getPadNumberTotalLength());
} else if (total != null) {
padNumber(sb, 0, TagOptionSingleton.getInstance().getPadNumberTotalLength());
}
if (total != null) {
sb.append(SEPARATOR);
padNumber(sb, total, TagOptionSingleton.getInstance().getPadNumberTotalLength());
}
if (extra != null) {
sb.append(extra);
}
}
return sb.toString();
}
开发者ID:openaudible,项目名称:openaudible,代码行数:23,代码来源:PartOfSet.java
示例18: read
import org.jaudiotagger.tag.TagOptionSingleton; //导入依赖的package包/类
/**
*
*
*
*/
public void read(ByteBuffer byteBuffer) throws InvalidTagException {
String lineString;
byte[] buffer = new byte[5];
// read the 5 character size
byteBuffer.get(buffer, 0, 5);
int size = Integer.parseInt(new String(buffer, 0, 5));
if ((size == 0) && (!TagOptionSingleton.getInstance().isLyrics3KeepEmptyFieldIfRead())) {
throw new InvalidTagException("Lyircs3v2 Field has size of zero.");
}
buffer = new byte[size];
// read the SIZE length description
byteBuffer.get(buffer);
lineString = new String(buffer);
readString(lineString);
}
开发者ID:openaudible,项目名称:openaudible,代码行数:27,代码来源:FieldFrameBodyLYR.java
示例19: read
import org.jaudiotagger.tag.TagOptionSingleton; //导入依赖的package包/类
public void read(ByteBuffer byteBuffer) throws InvalidTagException {
String imageString;
byte[] buffer = new byte[5];
// read the 5 character size
byteBuffer.get(buffer, 0, 5);
int size = Integer.parseInt(new String(buffer, 0, 5));
if ((size == 0) && (!TagOptionSingleton.getInstance().isLyrics3KeepEmptyFieldIfRead())) {
throw new InvalidTagException("Lyircs3v2 Field has size of zero.");
}
buffer = new byte[size];
// read the SIZE length description
byteBuffer.get(buffer);
imageString = new String(buffer);
readString(imageString);
}
开发者ID:openaudible,项目名称:openaudible,代码行数:22,代码来源:FieldFrameBodyIMG.java
示例20: getInstance
import org.jaudiotagger.tag.TagOptionSingleton; //导入依赖的package包/类
public static ImageHandler getInstance() {
//Normal
if (!TagOptionSingleton.getInstance().isAndroid()) {
if (standardImageHandler == null) {
standardImageHandler = StandardImageHandler.getInstanceOf();
}
return standardImageHandler;
}
//Android
else {
if (androidImageHandler == null) {
androidImageHandler = AndroidImageHandler.getInstanceOf();
}
return androidImageHandler;
}
}
开发者ID:openaudible,项目名称:openaudible,代码行数:17,代码来源:ImageHandlingFactory.java
注:本文中的org.jaudiotagger.tag.TagOptionSingleton类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论