-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
重构 taglib 使其与文件系统解耦 & 增加了对 Web 平台的兼容 & 添加 vercel 配置文件
- Loading branch information
Showing
13 changed files
with
364 additions
and
377 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import 'package:cross_file/cross_file.dart'; | ||
import 'package:flutter/foundation.dart'; | ||
import 'package:music_tools_flutter/taglib/taglib.dart'; | ||
// ignore: avoid_web_libraries_in_flutter | ||
import 'dart:html' as html; | ||
|
||
void saveAudioFile(Map<String, dynamic> params) { | ||
final audioFile = params['audioFile'] as AudioFile; | ||
final xFile = params['xFile'] as XFile; | ||
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']); | ||
final data = audioFile.save(); | ||
final blob = html.Blob([Uint8List.fromList(data)]); | ||
final url = html.Url.createObjectUrlFromBlob(blob); | ||
html.AnchorElement(href: url) | ||
..target = 'blank' | ||
..download = xFile.name | ||
..click(); | ||
html.Url.revokeObjectUrl(url); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import 'dart:io'; | ||
import 'package:cross_file/cross_file.dart'; | ||
import 'package:music_tools_flutter/taglib/taglib.dart'; | ||
|
||
void saveAudioFile(Map<String, dynamic> params) { | ||
final audioFile = params['audioFile'] as AudioFile; | ||
final xFile = params['xFile'] as XFile; | ||
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']); | ||
final data = audioFile.save(); | ||
final file = File(xFile.path); | ||
final modifiedTime = file.statSync().modified; | ||
final accessedTime = file.statSync().accessed; | ||
file.writeAsBytesSync(data); | ||
file.setLastModifiedSync(modifiedTime); | ||
file.setLastAccessedSync(accessedTime); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.