Skip to content

Conversation

@robUx4
Copy link
Collaborator

@robUx4 robUx4 commented Aug 21, 2024

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 addressed
with 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 from
scratch 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

@robUx4 robUx4 added format addition spec_chapter_codec Chapter Codec Matroska spec document target labels Aug 21, 2024
@robUx4 robUx4 force-pushed the matroskajs branch 2 times, most recently from c914ada to 86cfb04 Compare August 28, 2024 06:13
@robUx4
Copy link
Collaborator Author

robUx4 commented Aug 28, 2024

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.
Copy link

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.

Copy link
Collaborator Author

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.

robUx4 added 2 commits March 9, 2025 11:01
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.
Copy link

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

Copy link

@Labnann Labnann left a 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.

Copy link

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>")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

format addition spec_chapter_codec Chapter Codec Matroska spec document target

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Interactive Movie MatroskaScript commands

3 participants