-
Notifications
You must be signed in to change notification settings - Fork 51
Add MatroskaJS Chapter Codec #835
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
c914ada to
86cfb04
Compare
|
Not sure it should go in the "historical" Chapter Codec document, ie make the specification for what existed so far. Or if it should be a document on its own. Maybe each command will need its own IANA registry. |
| ## MatroskaJS | ||
|
|
||
| This is the case when `ChapProcessCodecID` = 2. This is a script language build for | ||
| Matroska purposes. It uses the [@!ECMAScript] 6th Edition (ES6) syntax. The commands are stored as text commands, in UTF-8. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may want to use ES5 instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would be better (less constraint) but we don't have a working solution with that.
Also there are things that could make the JS usage cleaner like let and const or static arrays and typed arrays. For example you could have a global function that gets the list of choices in an array and call the MatroskaJS engine. Then each (enter) chapter would just had the array and that call.
Rather than reinventing the wheel with a custom language, we can reuse and well-known one. The goal of Matroska Script was to be similar to JavaScript/ECMAStrip/ActionScript. But, in JS, integers can only use 56 bits. So not all ChapterUID (64-bit unsigned integer) can be addressed with the current Matroska Script stable API. Rather than adding a different GotoAndPlay that is compatible with JavaScript (using a string), we start from scratch with ECMAScript 6th Edition (ES6).
This API is meant for interactive movies. The author adds choices in a chapter and retrieves the user choice at the end of this chapter. Depending on the choice, different actions can be performed. The choice rendering and user interaction is the responsibility of the player.
| Matroska purposes. It uses the [@!ECMAScript] 6th Edition (ES6) syntax. The commands are stored as text commands, in UTF-8. | ||
| The syntax is C like, with commands spanned on many lines, each terminating with a semicolon ";". You can also include comments | ||
| at the end of lines with "//" or comment many lines using "/* \*/". The scripts are stored | ||
| in `ChapProcessData`. For the moment `ChapProcessPrivate` is not used. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should change these to ChapterProcessData, ChapterProcessPrivate, ChapterProcessCodecID to avoid later confusion with things like https://github.com/ietf-wg-cellar/matroska-specification/blob/master/ebml_matroska.xml#L1596
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also I believe we should add an optional first parameter, to create dynamic choices. This will allow creators to create/change choices in other chapters based on user's decision.
In that case the new command would look something like:
AddChoice("<ChapterUID>"= ThisChapter, "", group = Null );
We call also allow the creator to delete choices with something like:
DeleteChoice("<ChapterUID>"= ThisChapter, "", group = Null );
Another thing is, in this document we should clarify whether ChoiceUID is unique across the whole MatroskaJS document or just the "ChapterProcessData" the chapter is located in.
|
|
||
| If a group string is supplied, the default state only applies within the group of the given string. | ||
| Otherwise the default state only applies among the choices of the Default Group. | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should add a SetChoicePrompt that gives the user context about the choice. Something like
SetChoicePrompt("<PromptText>")
Rather than reinventing the wheel with a custom language, we can reuse and well-known one.
The goal of Matroska Script was to be similar to JavaScript/ECMAStrip/ActionScript.
But, in JavaScript, integers can only use 56 bits. So not all
ChapterUID(64-bit unsigned integer) can be addressedwith the current Matroska Script stable API, if an ECMAScript interpreter was used.
Rather than adding a different
GotoAndPlay()that is compatible with JavaScript (using a string), we start fromscratch with ECMAScript 6th Edition (ES6). We cannot handle the original
GotoAndPlay()with that engine anyway.The implementation of the Choice handling is almost complete in VLC by a Google Summer of Code student.
Fixes #658
Draft on top of #833