Skip to content
This repository has been archived by the owner on Dec 10, 2022. It is now read-only.

Commit

Permalink
Merge pull request #10 from sanket143/feat/remove-dart-io-dependency
Browse files Browse the repository at this point in the history
[v1.0.0] Remove dart:io dependency to support js
  • Loading branch information
sanket143 authored Jul 17, 2021
2 parents f0e236e + c172779 commit 89e39c4
Show file tree
Hide file tree
Showing 6 changed files with 103 additions and 97 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
## [0.1.8]- 2020-01-08
## [1.0.0] - 2021-07-17
* [API Update](https://github.com/sanket143/id3/pull/10), takes bytes instead of fileName as argument in `MP3Instance`
* [Fix corrupted album art](https://github.com/sanket143/id3/pull/9) [Thanks to [@moffotman](https://github.com/moffatman)]
* [Migration to null safety](https://github.com/sanket143/id3/pull/6) [Thanks to [@4-alok](https://github.com/4-alok)]

## [0.1.8] - 2020-01-08

* Removed redundant "this" and "new" keyword

Expand Down
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ files that uses ``ID3 tag version 2.3.0`` and ``ID3 tag version 1`` to store met
## Usage

```dart
import 'dart:io';
import 'package:id3/id3.dart';
void main(){
MP3Instance mp3instance = new MP3Instance("./file.mp3");
List<int> mp3Bytes = File("./file.mp3").readAsBytesSync();
MP3Instance mp3instance = new MP3Instance(mp3Bytes);
/// parseTags() returns
// 'true' if successfully parsed
Expand All @@ -36,7 +38,12 @@ void main(){
// }
```

# Migrating from v0.1 to v1.0

## Support
- `MP3Instance` used to take filename as string in v0.1, which is updated to take bytes as `List<int>` in v1.0

- [ ] Support ID3v2.2
```diff
- MP3Instance mp3instance = new MP3Instance("./file.mp3");
+ List<int> mp3Bytes = File("./file.mp3").readAsBytesSync();
+ MP3Instance mp3instance = new MP3Instance(mp3Bytes);
```
4 changes: 3 additions & 1 deletion example/main.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import 'dart:io';
import 'package:id3/id3.dart';

void main(){
MP3Instance mp3instance = new MP3Instance("./file.mp3");
List<int> mp3Bytes = File("./file.mp3").readAsBytesSync();
MP3Instance mp3instance = new MP3Instance(mp3Bytes);
if(mp3instance.parseTagsSync()){
print(mp3instance.getMetaTags());
}
Expand Down
5 changes: 2 additions & 3 deletions lib/id3.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
library id3;

import 'dart:io';
import 'dart:convert';

import 'src/const.dart';
Expand Down Expand Up @@ -157,8 +156,8 @@ class MP3Instance {
final Map<String, dynamic> metaTags = {};

/// Member Functions
MP3Instance(String mp3File) {
mp3Bytes = File(mp3File).readAsBytesSync();
MP3Instance(List<int> mp3Bytes) {
this.mp3Bytes = mp3Bytes;
}

bool parseTagsSync() {
Expand Down
Loading

0 comments on commit 89e39c4

Please sign in to comment.