我一直在尝试使用带有Angular 4的jsmediatags库,但无法使其工作。我已经关注了使用Angular 2+的外部脚本的教程 - 仍然没有运气。我收到以下错误:{type: "fileReader", info: "Offset 0 hasn't been loaded yet."}
是否有任何想法让这项工作?
我使用角度4.3.6
以下是代码:
的package.json
"dependencies": {
"jsmediatags": "^3.8.0",
...
},
...
test.component.ts
import {Component} from "@angular/core";
declare var jsmediatags: any;
import * as jsmediatags from "jsmediatags";
@Component({
selector: 'app-tests',
templateUrl: './tests.component.html',
})
export class TestsComponent implements{
getMeta(event) {
const file = event.target.files[0];
console.log(file);
jsmediatags.read(file, {
onSuccess: tag => {
alert('success');
console.log(tag);
},
onError: error => {
alert('error');
console.log(error);
}
});
}
}
tests.component.html
<input (change)="getMeta($event)" type="file">