added api to release url from memory

This commit is contained in:
Shariar Shaikot
2018-01-19 21:42:50 +06:00
parent f85666ceff
commit ae9c5e9d01
2 changed files with 17 additions and 7 deletions
+8 -2
View File
@@ -62,7 +62,8 @@ class WebVTTConverter {
const vttString = 'WEBVTT FILE\r\n\r\n';
const text = vttString.concat(WebVTTConverter.toVTT(decoded));
const blob = new Blob([text], { type: 'text/vtt' });
return resolve(URL.createObjectURL(blob));
this.objectURL = URL.createObjectURL(blob);
return resolve(this.objectURL);
},
() => {
this.blobToBuffer()
@@ -71,12 +72,17 @@ class WebVTTConverter {
const vttString = 'WEBVTT FILE\r\n\r\n';
const text = vttString.concat(WebVTTConverter.toVTT(utf8str));
const blob = new Blob([text], { type: 'text/vtt' });
return resolve(URL.createObjectURL(blob));
this.objectURL = URL.createObjectURL(blob);
return resolve(this.objectURL);
});
},
);
});
}
release() {
URL.createObjectURL(this.objectURL);
}
}
window.WebVTTConverter = WebVTTConverter;
+9 -5
View File
@@ -1,11 +1,15 @@
{
"name": "srt-webvtt",
"version": "0.0.0",
"description": "Convert SRT format subtitle to WebVTT on the fly over HTML5 environmentø",
"main": "index.js",
"description": "Convert SRT format subtitle to WebVTT on the fly over HTML5 environment",
"main": "lib/index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "webpack-dev-server"
"test": "./node_modules/.bin/eslint ./index.js",
"start": "webpack-dev-server",
"build": "babel ./index.js --stage 2 -d ./lib/index.js && webpack -p ./index.js ./umd/index.js",
"minor": "npm version minor && npm publish",
"major": "npm version major && npm publish",
"patch": "npm version patch && npm publish"
},
"repository": {
"type": "git",
@@ -18,7 +22,7 @@
"track",
"element",
"srt-to-vtt",
"str-to-webvtt",
"srt-to-webvtt",
"converter",
"html5",
"video",