org.jaudiotagger.audio.exceptions.CannotWriteException Java Examples

The following examples show how to use org.jaudiotagger.audio.exceptions.CannotWriteException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Id3Writer.java    From QuickLyric with GNU General Public License v3.0 6 votes vote down vote up
@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;
}
 
Example #2
Source File: SAFUtil.java    From VinylMusicPlayer with GNU General Public License v3.0 5 votes vote down vote up
public static void write(Context context, AudioFile audio, Uri safUri) {
    if (isSAFRequired(audio)) {
        writeSAF(context, audio, safUri);
    } else {
        try {
            writeFile(audio);
        } catch (CannotWriteException e) {
            e.printStackTrace();
        }
    }
}
 
Example #3
Source File: MediaStoreUtil.java    From APlayer with GNU General Public License v3.0 5 votes vote down vote up
@WorkerThread
public static void saveArtwork(Context context, int albumId, File artFile)
    throws TagException, ReadOnlyFileException, CannotReadException, InvalidAudioFrameException, IOException, CannotWriteException {
  Song song = MediaStoreUtil.getSongByAlbumId(albumId);
  if (song == null) {
    return;
  }
  AudioFile audioFile = AudioFileIO.read(new File(song.getUrl()));
  Tag tag = audioFile.getTagOrCreateAndSetDefault();
  Artwork artwork = ArtworkFactory.createArtworkFromFile(artFile);
  tag.deleteArtworkField();
  tag.setField(artwork);
  audioFile.commit();
  insertAlbumArt(context, albumId, artFile.getAbsolutePath());
}
 
Example #4
Source File: SAFUtil.java    From VinylMusicPlayer with GNU General Public License v3.0 4 votes vote down vote up
public static void writeFile(AudioFile audio) throws CannotWriteException {
    audio.commit();
}