Skip to content

Commit

Permalink
修复标签保存错误
Browse files Browse the repository at this point in the history
  • Loading branch information
MCredbear committed Dec 20, 2024
1 parent e3ad5e1 commit 87dbfcd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 23 deletions.
32 changes: 12 additions & 20 deletions lib/editor_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,17 @@ import 'package:flutter_styled_toast/flutter_styled_toast.dart';
import 'taglib/taglib.dart';

void saveAudioFile(Map<String, dynamic> params) {
final audioFile = params['audioFile'];
final title = params['title'];
final album = params['album'];
final artist = params['artist'];
final albumArtist = params['albumArtist'];
final cd = params['cd'];
final track = params['track'];
final lyric = params['lyric'];
final comment = params['comment'];
final cover = params['cover'];

audioFile.setTitle(title);
audioFile.setAlbum(album);
audioFile.setArtist(artist);
audioFile.setAlbumArtist(albumArtist);
audioFile.setCD(cd);
audioFile.setTrack(track);
audioFile.setLyric(lyric);
audioFile.setComment(comment);
audioFile.setCover(cover);
final audioFile = params['audioFile'] as AudioFile;
audioFile.setTitle(params['title']);
audioFile.setAlbum(params['album']);
audioFile.setArtist(params['artist']);
audioFile.setAlbumArtist(params['albumArtist']);
audioFile.setCD(params['cd']);
audioFile.setTrack(params['track']);
audioFile.setYear(params['year']);
audioFile.setLyric(params['lyric']);
audioFile.setComment(params['comment']);
audioFile.setCover(params['cover']);
audioFile.save();
}

Expand Down Expand Up @@ -364,6 +355,7 @@ class EditorPageState extends State<EditorPage> {
: null,
'cd': _cdController.text.isNotEmpty ? _cdController.text : null,
'track': _trackController.text.isNotEmpty ? _trackController.text : null,
'year': _yearController.text.isNotEmpty ? _yearController.text : null,
'lyric': _lyricController.text.isNotEmpty ? _lyricController.text : null,
'comment':
_commentController.text.isNotEmpty ? _commentController.text : null,
Expand Down
6 changes: 3 additions & 3 deletions lib/taglib/flac.dart
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ class VorbisCommentBlock {
}
if (comment != null) {
_comments
.add(VorbisComment('ALBUMARTIST'.codeUnits, utf8.encode(comment)));
.add(VorbisComment('DESCRIPTION'.codeUnits, utf8.encode(comment)));
}
}

Expand All @@ -297,7 +297,7 @@ class VorbisCommentBlock {
}
}
if (track != null) {
_comments.add(VorbisComment('ALBUMARTIST'.codeUnits, utf8.encode(track)));
_comments.add(VorbisComment('TRACKNUMBER'.codeUnits, utf8.encode(track)));
}
}

Expand Down Expand Up @@ -331,7 +331,7 @@ class VorbisCommentBlock {
}
}
if (year != null) {
_comments.add(VorbisComment('ALBUMARTIST'.codeUnits, utf8.encode(year)));
_comments.add(VorbisComment('DATE'.codeUnits, utf8.encode(year)));
}
}

Expand Down

0 comments on commit 87dbfcd

Please sign in to comment.