Skip to content

Commit b32ee46

Browse files
committed
Add a MatroskaJS choice API
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.
1 parent b6a8d29 commit b32ee46

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

cellar-chapter-codecs/chapter_codecs.md

+52
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,58 @@ The command is called with `LogMsg( "A String" );`.
9696
The `Matroska Player` **SHOULD** send the provided message to the user debugging console, if there is one.
9797
In this example it would send "A String", without the double quotes, to the debugging console.
9898

99+
### AddChoice
100+
101+
The command is called with `AddChoice( "<ChoiceUID>", group = Null );`.
102+
103+
The `Matroska Player` **MUST** keep the choice with the given UID in memory until the Chapter it belongs to
104+
has ended. The string may be any length and should be a valid ECMAScript string literal.
105+
106+
If a group string is supplied, the choice **MUST** only be evaluated within the group of the given string.
107+
Otherwise the choice **MUST** be evaluated with the other choices with no group, called the Default Group.
108+
109+
It is possible to add a single choice for a group to let the user select it or not, for example with a checkbox.
110+
111+
### SetChoiceText
112+
113+
The command is called with `SetChoiceText( "<ChoiceUID>", "Some text", "<lang>" );`.
114+
115+
Set the string to use for the choice with the given UID if the given language is selected.
116+
The language string is the same form defined in [@!RFC5646] as for the `ChapLanguageBCP47` element.
117+
118+
When the `Matroska Player` collects the strings to use for all available choices, the same language
119+
rules apply as of [@!Matroska, section 19] for track selection. In addition if a string is missing for a language
120+
the whole language is considered to be not available, unless there is no other language option available.
121+
122+
<!-- TODO: allow attaching a choice to a tag, we will need a special tag target for that -->
123+
124+
### SetChoiceDefault
125+
126+
The command is called with `SetChoiceDefault( "<ChoiceUID>", group = Null );`.
127+
128+
Tell the `Matroska Player` that the choice with the given UID is the default one to use.
129+
If this function is not called, no choice is considered the default one.
130+
131+
If a group string is supplied, the default state only applies within the group of the given string.
132+
Otherwise the default state only applies among the choices of the Default Group.
133+
134+
### CommitChoices
135+
136+
The command is called with `CommitChoices( );`.
137+
138+
Tell the `Matroska Player` that all previously added choices with AddChoice ((#addchoice)) should be used.
139+
This **SHOULD** generate some visually visible choice, with the default choice selected, if there is one.
140+
141+
### GetChoice
142+
143+
The command is called with `GetChoice( group = Null );`.
144+
145+
The function returns the UID string corresponding to the choice selected by the user.
146+
If the user did not make a selection and there is no default one, this function returns the ECMAScript `Undefined`.
147+
148+
If a group string is supplied, the selected UID string returned is the selection within the choices of the given group string.
149+
Otherwise selected UID string returned is the selection within the choices of the Default Group.
150+
99151

100152

101153
## DVD Menu

0 commit comments

Comments
 (0)