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

Possible to render ASS before ASS.fromURL promise is fully resolved? #43

Closed
bsuh opened this issue Jul 11, 2015 · 3 comments
Closed

Possible to render ASS before ASS.fromURL promise is fully resolved? #43

bsuh opened this issue Jul 11, 2015 · 3 comments

Comments

@bsuh
Copy link

bsuh commented Jul 11, 2015

My use case is I use torrent-stream, which creates readable streams of torrent files. You can start watching video files, before they are fully transferred. I can also feed a mkv video file stream into ffmpeg to create a ASS file stream. It would be neat if libjass could support rendering the currently parsed dialogue.

I looked around and it seems like I could create my own versions of ASS.fromURL & ASS.fromStream to return the minimalAss promise instead. I didn't see if using that would work yet and the renderer was too complex to figure out for me for now.

Anyways, if libjass could support this use case that would be super. If modified ASS.fromURL & ASS.fromStream is all that's needed for it to work, I'll send a pull request.

@bsuh
Copy link
Author

bsuh commented Jul 11, 2015

I got it to work with some hacking. I'll clean up my work and send a pull request :)

@Arnavion
Copy link
Owner

ASS.from* are simple wrappers around the corresponding Stream implementation that is then parsed to StreamParser. If you want to use StreamParser.minimalASS, you can create this construct yourself:

var stream = new libjass.parser.XhrStream(...);
var streamParser = new libjass.parser.StreamParser(stream);
streamParser.minimalASS.then(function (ass) {
   ...
});

Eg: https://github.com/Arnavion/libjass/blob/53f96a2/tests/unit/miscellaneous.js#L247-L264

I haven't given convenience wrappers similar to ASS.from* for minimalASS mostly because I don't want to bake this API in yet. Basically I'm not sure I like its API design - something like a single ASS object with events "scriptInfoLoaded", "stylesLoaded", "eventsLoaded" may be better.

@bsuh
Copy link
Author

bsuh commented Jul 11, 2015

I see. I'll close this then.

@bsuh bsuh closed this as completed Jul 11, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants