jclic 2.2.0 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -7
- package/dist-node/jclic-node.js +14157 -0
- package/dist-node/jclic-node.umd.cjs +530 -0
- package/package.json +38 -26
- package/.vscode/launch.json +0 -33
- package/.vscode/settings.json +0 -13
- package/CHANGELOG.md +0 -664
- package/TRANSLATIONS.md +0 -11
- package/build-locales.mjs +0 -82
- package/dist/jclic-node.js +0 -31678
- package/dist/jclic-node.js.map +0 -1
- package/dist/jclic.components.LICENSE +0 -2254
- package/dist/jclic.min.js +0 -27
- package/dist/jclic.min.js.map +0 -1
- package/eslint.config.mjs +0 -31
- package/jsdoc.config.js +0 -71
- package/locales/ar.po +0 -244
- package/locales/ast.po +0 -246
- package/locales/bs.po +0 -247
- package/locales/ca.po +0 -248
- package/locales/ca_ES@valencia.po +0 -248
- package/locales/cs.po +0 -244
- package/locales/da.po +0 -244
- package/locales/de.po +0 -246
- package/locales/el.po +0 -244
- package/locales/es.po +0 -248
- package/locales/eu.po +0 -244
- package/locales/fr.po +0 -244
- package/locales/gl.po +0 -244
- package/locales/he.po +0 -244
- package/locales/hr.po +0 -245
- package/locales/it.po +0 -246
- package/locales/ja.po +0 -242
- package/locales/jclic.js.pot +0 -241
- package/locales/nb_NO.po +0 -244
- package/locales/nl.po +0 -244
- package/locales/pl.po +0 -244
- package/locales/pt.po +0 -244
- package/locales/pt_BR.po +0 -248
- package/locales/ro.po +0 -248
- package/locales/ru.po +0 -245
- package/locales/ta.po +0 -244
- package/locales/tr.po +0 -246
- package/locales/uk.po +0 -247
- package/locales/vec.po +0 -244
- package/locales/zh_TW.po +0 -246
- package/patches/po2json+1.0.0-beta-3.patch +0 -12
- package/src/AWT.js +0 -2067
- package/src/Activity.js +0 -1311
- package/src/Deps.js +0 -232
- package/src/GlobalData.js +0 -5
- package/src/JClic.js +0 -196
- package/src/JClicPlayer.js +0 -1308
- package/src/PlayerHistory.js +0 -305
- package/src/Utils.js +0 -1355
- package/src/activities/associations/ComplexAssociation.js +0 -321
- package/src/activities/associations/SimpleAssociation.js +0 -519
- package/src/activities/memory/MemoryGame.js +0 -423
- package/src/activities/panels/Explore.js +0 -349
- package/src/activities/panels/Identify.js +0 -356
- package/src/activities/panels/InformationScreen.js +0 -262
- package/src/activities/panels/Menu.js +0 -209
- package/src/activities/panels/icons/ico00.png +0 -0
- package/src/activities/panels/icons/ico01.png +0 -0
- package/src/activities/panels/icons/ico02.png +0 -0
- package/src/activities/panels/icons/ico03.png +0 -0
- package/src/activities/panels/icons/icofolder.png +0 -0
- package/src/activities/puzzles/DoublePuzzle.js +0 -424
- package/src/activities/puzzles/ExchangePuzzle.js +0 -374
- package/src/activities/puzzles/HolePuzzle.js +0 -360
- package/src/activities/text/Complete.js +0 -127
- package/src/activities/text/Evaluator.js +0 -534
- package/src/activities/text/FillInBlanks.js +0 -426
- package/src/activities/text/IdentifyText.js +0 -253
- package/src/activities/text/OrderText.js +0 -421
- package/src/activities/text/TextActivityBase.js +0 -557
- package/src/activities/text/TextActivityDocument.js +0 -658
- package/src/activities/text/WrittenAnswer.js +0 -557
- package/src/activities/textGrid/CrossWord.js +0 -565
- package/src/activities/textGrid/WordSearch.js +0 -458
- package/src/activities/textGrid/icons/hIcon.svg +0 -3
- package/src/activities/textGrid/icons/vIcon.svg +0 -3
- package/src/automation/AutoContentProvider.js +0 -182
- package/src/automation/arith/Arith.js +0 -864
- package/src/bags/ActivitySequence.js +0 -318
- package/src/bags/ActivitySequenceElement.js +0 -161
- package/src/bags/ActivitySequenceJump.js +0 -140
- package/src/bags/ConditionalJumpInfo.js +0 -113
- package/src/bags/JumpInfo.js +0 -136
- package/src/bags/MediaBag.js +0 -215
- package/src/bags/MediaBagElement.js +0 -516
- package/src/boxes/AbstractBox.js +0 -699
- package/src/boxes/ActiveBagContent.js +0 -494
- package/src/boxes/ActiveBox.js +0 -810
- package/src/boxes/ActiveBoxBag.js +0 -357
- package/src/boxes/ActiveBoxContent.js +0 -484
- package/src/boxes/ActiveBoxGrid.js +0 -179
- package/src/boxes/BoxBag.js +0 -500
- package/src/boxes/BoxBase.js +0 -398
- package/src/boxes/BoxConnector.js +0 -325
- package/src/boxes/TextGrid.js +0 -887
- package/src/boxes/TextGridContent.js +0 -215
- package/src/init-jsdom.js +0 -65
- package/src/jclic-node.js +0 -219
- package/src/media/ActiveMediaBag.js +0 -145
- package/src/media/ActiveMediaPlayer.js +0 -297
- package/src/media/AudioBuffer.js +0 -219
- package/src/media/EventSounds.js +0 -169
- package/src/media/EventSoundsElement.js +0 -155
- package/src/media/MediaContent.js +0 -328
- package/src/media/MidiAudioPlayer.js +0 -254
- package/src/media/icons/audio.svg +0 -3
- package/src/media/icons/generic.svg +0 -3
- package/src/media/icons/mic.svg +0 -3
- package/src/media/icons/movie.svg +0 -3
- package/src/media/icons/music.svg +0 -3
- package/src/media/icons/url.svg +0 -3
- package/src/media/sounds/actionError.mp3 +0 -0
- package/src/media/sounds/actionOk.mp3 +0 -0
- package/src/media/sounds/click.mp3 +0 -0
- package/src/media/sounds/finishedError.mp3 +0 -0
- package/src/media/sounds/finishedOk.mp3 +0 -0
- package/src/media/sounds/start.mp3 +0 -0
- package/src/project/JClicProject.js +0 -282
- package/src/project/ProjectSettings.js +0 -273
- package/src/report/ActionReg.js +0 -123
- package/src/report/ActivityReg.js +0 -271
- package/src/report/EncryptMin.js +0 -210
- package/src/report/Reporter.js +0 -727
- package/src/report/SCORM.js +0 -272
- package/src/report/SequenceReg.js +0 -275
- package/src/report/SessionReg.js +0 -340
- package/src/report/SessionStorageReporter.js +0 -131
- package/src/report/TCPReporter.js +0 -628
- package/src/shapers/ClassicJigSaw.js +0 -138
- package/src/shapers/Holes.js +0 -77
- package/src/shapers/JigSaw.js +0 -161
- package/src/shapers/Rectangular.js +0 -78
- package/src/shapers/Shaper.js +0 -386
- package/src/shapers/TriangularJigSaw.js +0 -121
- package/src/skins/BlueSkin.js +0 -80
- package/src/skins/Counter.js +0 -152
- package/src/skins/CustomSkin.js +0 -412
- package/src/skins/DefaultSkin.js +0 -376
- package/src/skins/EmptySkin.js +0 -82
- package/src/skins/GreenSkin.js +0 -94
- package/src/skins/MiniSkin.js +0 -130
- package/src/skins/OrangeSkin.js +0 -78
- package/src/skins/SimpleSkin.js +0 -92
- package/src/skins/Skin.js +0 -1021
- package/src/skins/assets/actionsIcon.svg +0 -3
- package/src/skins/assets/appLogo.svg +0 -8
- package/src/skins/assets/basic.css +0 -41
- package/src/skins/assets/closeDialogIcon.svg +0 -3
- package/src/skins/assets/closeIcon.svg +0 -3
- package/src/skins/assets/copyIcon.svg +0 -3
- package/src/skins/assets/fullScreenExitIcon.svg +0 -3
- package/src/skins/assets/fullScreenIcon.svg +0 -3
- package/src/skins/assets/infoIcon.svg +0 -3
- package/src/skins/assets/main.css +0 -43
- package/src/skins/assets/mainHalf.css +0 -23
- package/src/skins/assets/mainTwoThirds.css +0 -23
- package/src/skins/assets/mini.css +0 -15
- package/src/skins/assets/nextIcon.svg +0 -3
- package/src/skins/assets/okDialogIcon.svg +0 -3
- package/src/skins/assets/prevIcon.svg +0 -3
- package/src/skins/assets/reports.css +0 -156
- package/src/skins/assets/reportsIcon.svg +0 -3
- package/src/skins/assets/scoreIcon.svg +0 -3
- package/src/skins/assets/simple.css +0 -16
- package/src/skins/assets/simpleHalf.css +0 -11
- package/src/skins/assets/simpleTwoThirds.css +0 -11
- package/src/skins/assets/timeIcon.svg +0 -4
- package/src/skins/assets/waitAnim.css +0 -54
- package/src/skins/assets/waitImgBig.svg +0 -3
- package/src/skins/assets/waitImgSmall.svg +0 -3
- package/webpack.config.mjs +0 -169
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* File : media/EventSoundsElement.js
|
|
3
|
-
* Created : 01/04/2015
|
|
4
|
-
* By : Francesc Busquets <francesc@gmail.com>
|
|
5
|
-
*
|
|
6
|
-
* JClic.js
|
|
7
|
-
* An HTML5 player of JClic activities
|
|
8
|
-
* https://projectestac.github.io/jclic.js
|
|
9
|
-
*
|
|
10
|
-
* @source https://github.com/projectestac/jclic.js
|
|
11
|
-
*
|
|
12
|
-
* @license EUPL-1.2
|
|
13
|
-
* @licstart
|
|
14
|
-
* (c) 2000-2020 Educational Telematic Network of Catalonia (XTEC)
|
|
15
|
-
*
|
|
16
|
-
* Licensed under the EUPL, Version 1.1 or -as soon they will be approved by
|
|
17
|
-
* the European Commission- subsequent versions of the EUPL (the "Licence");
|
|
18
|
-
* You may not use this work except in compliance with the Licence.
|
|
19
|
-
*
|
|
20
|
-
* You may obtain a copy of the Licence at:
|
|
21
|
-
* https://joinup.ec.europa.eu/software/page/eupl
|
|
22
|
-
*
|
|
23
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
24
|
-
* distributed under the Licence is distributed on an "AS IS" basis, WITHOUT
|
|
25
|
-
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
26
|
-
* Licence for the specific language governing permissions and limitations
|
|
27
|
-
* under the Licence.
|
|
28
|
-
* @licend
|
|
29
|
-
* @module
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
|
-
/* global Audio */
|
|
33
|
-
|
|
34
|
-
import { startsWith, getTriState, getAttr, setAttr, DEFAULT } from '../Utils.js';
|
|
35
|
-
import ActiveMediaPlayer from './ActiveMediaPlayer.js';
|
|
36
|
-
import MediaContent from './MediaContent.js';
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* The EventSoundsElement object contains the description of a specific sound to be played when
|
|
40
|
-
* one of the JClic events are fired.
|
|
41
|
-
* For a full list of the JClic events see: {@link module:media/EventSounds.EventSounds EventSounds}
|
|
42
|
-
*/
|
|
43
|
-
export class EventSoundsElement {
|
|
44
|
-
/**
|
|
45
|
-
* EventSoundsElement constructor
|
|
46
|
-
* @param {string} id - The identifier of this media sound
|
|
47
|
-
* @param {string} [file] - An optional file name or URL containing the sound data
|
|
48
|
-
*/
|
|
49
|
-
constructor(id, file) {
|
|
50
|
-
this.id = id;
|
|
51
|
-
if (file) {
|
|
52
|
-
if (startsWith(file, 'data:'))
|
|
53
|
-
this.audio = new Audio(file);
|
|
54
|
-
else
|
|
55
|
-
this.file = file;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Reads the properties of this object from an XML element
|
|
61
|
-
* @param {external:jQuery} $xml - The XML element to be parsed
|
|
62
|
-
*/
|
|
63
|
-
setProperties($xml) {
|
|
64
|
-
this.file = $xml.attr('file');
|
|
65
|
-
this.enabled = getTriState($xml.attr('enabled'));
|
|
66
|
-
return this;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Gets a object with the basic attributes needed to rebuild this instance excluding functions,
|
|
71
|
-
* parent references, constants and also attributes retaining the default value.
|
|
72
|
-
* The resulting object is commonly usued to serialize elements in JSON format.
|
|
73
|
-
* @returns {object} - The resulting object, with minimal attrributes
|
|
74
|
-
*/
|
|
75
|
-
getAttributes() {
|
|
76
|
-
return getAttr(this, [
|
|
77
|
-
`enabled|${DEFAULT}`,
|
|
78
|
-
'file',
|
|
79
|
-
]);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Reads the properties of this EventSoundsElement from a data object
|
|
84
|
-
* @param {object} data - The data object to be parsed
|
|
85
|
-
* @returns {module:media/EventSoundsElement.EventSoundsElement}
|
|
86
|
-
*/
|
|
87
|
-
setAttributes(data) {
|
|
88
|
-
return setAttr(this, data, [
|
|
89
|
-
'enabled',
|
|
90
|
-
'file',
|
|
91
|
-
]);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Instantiates this audio object
|
|
96
|
-
* @param {module:JClicPlayer.JClicPlayer} ps
|
|
97
|
-
* @param {module:bags/MediaBag.MediaBag} mediaBag
|
|
98
|
-
*/
|
|
99
|
-
realize(ps, mediaBag) {
|
|
100
|
-
if (!this.audio && this.player === null && this.file !== null) {
|
|
101
|
-
this.player = new ActiveMediaPlayer(new MediaContent('PLAY_AUDIO', this.file), mediaBag, ps);
|
|
102
|
-
this.player.realize();
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Plays the audio associated to this event
|
|
108
|
-
*/
|
|
109
|
-
play() {
|
|
110
|
-
if (this.enabled) {
|
|
111
|
-
if (this.audio) {
|
|
112
|
-
this.audio.currentTime = 0;
|
|
113
|
-
this.audio.play();
|
|
114
|
-
} else if (this.player)
|
|
115
|
-
this.player.play();
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Stops playing the audio associated to this event
|
|
121
|
-
*/
|
|
122
|
-
stop() {
|
|
123
|
-
if (this.enabled) {
|
|
124
|
-
if (this.audio)
|
|
125
|
-
this.audio.pause();
|
|
126
|
-
else if (this.player)
|
|
127
|
-
this.player.stop();
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
Object.assign(EventSoundsElement.prototype, {
|
|
133
|
-
/**
|
|
134
|
-
* The name of the sound file used by this element
|
|
135
|
-
* @name module:media/EventSoundsElement.EventSoundsElement#file
|
|
136
|
-
* @type {string} */
|
|
137
|
-
file: null,
|
|
138
|
-
/**
|
|
139
|
-
* Whether the sound for this event is enabled or not
|
|
140
|
-
* @name module:media/EventSoundsElement.EventSoundsElement#enabled
|
|
141
|
-
* @type {number} */
|
|
142
|
-
enabled: DEFAULT,
|
|
143
|
-
/**
|
|
144
|
-
* Media player used to play this sound
|
|
145
|
-
* @name module:media/EventSoundsElement.EventSoundsElement#player
|
|
146
|
-
* @type {module:media/ActiveMediaPlayer.ActiveMediaPlayer} */
|
|
147
|
-
player: null,
|
|
148
|
-
/**
|
|
149
|
-
* HTMLAudioElement used to play this sound
|
|
150
|
-
* @name module:media/EventSoundsElement.EventSoundsElement#audio
|
|
151
|
-
* @type {external:HTMLAudioElement} */
|
|
152
|
-
audio: null,
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
export default EventSoundsElement;
|
|
@@ -1,328 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* File : media/MediaContent.js
|
|
3
|
-
* Created : 13/04/2015
|
|
4
|
-
* By : Francesc Busquets <francesc@gmail.com>
|
|
5
|
-
*
|
|
6
|
-
* JClic.js
|
|
7
|
-
* An HTML5 player of JClic activities
|
|
8
|
-
* https://projectestac.github.io/jclic.js
|
|
9
|
-
*
|
|
10
|
-
* @source https://github.com/projectestac/jclic.js
|
|
11
|
-
*
|
|
12
|
-
* @license EUPL-1.2
|
|
13
|
-
* @licstart
|
|
14
|
-
* (c) 2000-2020 Educational Telematic Network of Catalonia (XTEC)
|
|
15
|
-
*
|
|
16
|
-
* Licensed under the EUPL, Version 1.1 or -as soon they will be approved by
|
|
17
|
-
* the European Commission- subsequent versions of the EUPL (the "Licence");
|
|
18
|
-
* You may not use this work except in compliance with the Licence.
|
|
19
|
-
*
|
|
20
|
-
* You may obtain a copy of the Licence at:
|
|
21
|
-
* https://joinup.ec.europa.eu/software/page/eupl
|
|
22
|
-
*
|
|
23
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
24
|
-
* distributed under the Licence is distributed on an "AS IS" basis, WITHOUT
|
|
25
|
-
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
26
|
-
* Licence for the specific language governing permissions and limitations
|
|
27
|
-
* under the Licence.
|
|
28
|
-
* @licend
|
|
29
|
-
* @module
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
|
-
/* global Image */
|
|
33
|
-
|
|
34
|
-
import $ from 'jquery';
|
|
35
|
-
import { Point } from '../AWT.js';
|
|
36
|
-
import { nSlash, attrForEach, getBoolean, getAttr, setAttr, svgToURI } from '../Utils.js';
|
|
37
|
-
|
|
38
|
-
import generic from './icons/generic.svg';
|
|
39
|
-
import audio from './icons/audio.svg';
|
|
40
|
-
import mic from './icons/mic.svg';
|
|
41
|
-
import movie from './icons/movie.svg';
|
|
42
|
-
import music from './icons/music.svg';
|
|
43
|
-
import url from './icons/url.svg';
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* This object contains a description of any multimedia content (sound, video, MIDI, voice
|
|
47
|
-
* recording..) or special actions (jump to another point in the sequence, link to an URL, etc.)
|
|
48
|
-
* associated to an {@link module:boxes/ActiveBox.ActiveBox ActiveBox} object.
|
|
49
|
-
*/
|
|
50
|
-
export class MediaContent {
|
|
51
|
-
/**
|
|
52
|
-
* MediaContent constructor
|
|
53
|
-
* @param {string} type - The type of media. Valid values are: `UNKNOWN`, `PLAY_AUDIO`, `PLAY_VIDEO`,
|
|
54
|
-
* `PLAY_MIDI`, `PLAY_CDAUDIO`, `RECORD_AUDIO`, `PLAY_RECORDED_AUDIO`, `RUN_CLIC_ACTIVITY`,
|
|
55
|
-
* `RUN_CLIC_PACKAGE`, `RUN_EXTERNAL`, `URL`, `EXIT` and `RETURN`
|
|
56
|
-
* @param {string} [file] - Optional parameter indicating the media file name
|
|
57
|
-
*/
|
|
58
|
-
constructor(type, file) {
|
|
59
|
-
this.type = type;
|
|
60
|
-
if (file)
|
|
61
|
-
this.file = file;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Loads the MediaContent settings from a specific JQuery XML element
|
|
66
|
-
* @param {external:jQuery} $xml
|
|
67
|
-
*/
|
|
68
|
-
setProperties($xml) {
|
|
69
|
-
attrForEach($xml.get(0).attributes, (name, val) => {
|
|
70
|
-
switch (name) {
|
|
71
|
-
case 'type':
|
|
72
|
-
this.type = val;
|
|
73
|
-
break;
|
|
74
|
-
case 'file':
|
|
75
|
-
this.file = nSlash(val);
|
|
76
|
-
break;
|
|
77
|
-
case 'params':
|
|
78
|
-
this.externalParam = nSlash(val);
|
|
79
|
-
break;
|
|
80
|
-
|
|
81
|
-
case 'pFrom':
|
|
82
|
-
this.absLocationFrom = val;
|
|
83
|
-
break;
|
|
84
|
-
|
|
85
|
-
case 'buffer':
|
|
86
|
-
this.recBuffer = Number(val);
|
|
87
|
-
break;
|
|
88
|
-
case 'level':
|
|
89
|
-
case 'from':
|
|
90
|
-
case 'to':
|
|
91
|
-
case 'length':
|
|
92
|
-
this[name] = Number(val);
|
|
93
|
-
break;
|
|
94
|
-
|
|
95
|
-
case 'px':
|
|
96
|
-
case 'py':
|
|
97
|
-
if (this.absLocation === null)
|
|
98
|
-
this.absLocation = new Point(0, 0);
|
|
99
|
-
if (name === 'px')
|
|
100
|
-
this.absLocation.x = Number(val);
|
|
101
|
-
else
|
|
102
|
-
this.absLocation.y = Number(val);
|
|
103
|
-
break;
|
|
104
|
-
|
|
105
|
-
case 'stretch':
|
|
106
|
-
case 'free':
|
|
107
|
-
case 'catchMouseEvents':
|
|
108
|
-
case 'loop':
|
|
109
|
-
case 'autostart':
|
|
110
|
-
this[name] = getBoolean(val);
|
|
111
|
-
break;
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
return this;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Gets a object with the basic attributes needed to rebuild this instance excluding functions,
|
|
119
|
-
* parent references, constants and also attributes retaining the default value.
|
|
120
|
-
* The resulting object is commonly usued to serialize elements in JSON format.
|
|
121
|
-
* @returns {object} - The resulting object, with minimal attrributes
|
|
122
|
-
*/
|
|
123
|
-
getAttributes() {
|
|
124
|
-
return getAttr(this, [
|
|
125
|
-
'type', 'file', 'externalParam',
|
|
126
|
-
'absLocation', // -> AWT.Point
|
|
127
|
-
'absLocationFrom', 'recBuffer',
|
|
128
|
-
'level|1', 'from', 'to', 'length',
|
|
129
|
-
'stretch', 'free', 'catchMouseEvents', 'loop', 'autostart'
|
|
130
|
-
]);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Reads the properties of this MediaContent from a data object
|
|
135
|
-
* @param {object} data - The data object to be parsed
|
|
136
|
-
* @returns {module:media/MediaContent.MediaContent}
|
|
137
|
-
*/
|
|
138
|
-
setAttributes(data) {
|
|
139
|
-
return setAttr(this, data, [
|
|
140
|
-
'type', 'file', 'externalParam',
|
|
141
|
-
{ key: 'absLocation', fn: Point },
|
|
142
|
-
'absLocationFrom', 'recBuffer',
|
|
143
|
-
'level', 'from', 'to', 'length',
|
|
144
|
-
'stretch', 'free', 'catchMouseEvents', 'loop', 'autostart',
|
|
145
|
-
]);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* Compares this object with another MediaContent.
|
|
150
|
-
* @param {module:media/MediaContent.MediaContent} mc - The Media Content to compare against to.
|
|
151
|
-
* @returns {boolean} - `true` when both objects are equivalent.
|
|
152
|
-
*/
|
|
153
|
-
isEquivalent(mc) {
|
|
154
|
-
return this.type === mc.type &&
|
|
155
|
-
(this.file === mc.file ||
|
|
156
|
-
this.file !== null && mc.file !== null &&
|
|
157
|
-
this.file.toLocaleLowerCase() === mc.file.toLocaleLowerCase()) &&
|
|
158
|
-
this.from === mc.from &&
|
|
159
|
-
this.to === mc.to &&
|
|
160
|
-
this.recBuffer === mc.recBuffer;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
/**
|
|
164
|
-
* Gets a string representing this media content, useful for checking if two different elements
|
|
165
|
-
* are equivalent.
|
|
166
|
-
* @returns {string}
|
|
167
|
-
*/
|
|
168
|
-
getDescription() {
|
|
169
|
-
let result = `${this.type}`;
|
|
170
|
-
if (this.file)
|
|
171
|
-
result = `${result} ${this.file}${this.from >= 0 ? ` from:${this.from}` : ''}${this.to >= 0 ? ` to:${this.to}` : ''}`;
|
|
172
|
-
else if (this.externalParam)
|
|
173
|
-
result = `${result} ${this.externalParam}`;
|
|
174
|
-
return result;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
/**
|
|
178
|
-
* Returns a simplified description of this media content. Useful for accessibility methods.
|
|
179
|
-
* @returns {string}
|
|
180
|
-
*/
|
|
181
|
-
toString() {
|
|
182
|
-
return `${this.type}${this.file ? ` ${this.file}` : ''}`;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
/**
|
|
186
|
-
* Returns an image to be used as icon for representing this media content.
|
|
187
|
-
* @returns {external:HTMLImageElement}
|
|
188
|
-
*/
|
|
189
|
-
getIcon() {
|
|
190
|
-
let icon = null;
|
|
191
|
-
switch (this.type) {
|
|
192
|
-
case 'PLAY_AUDIO':
|
|
193
|
-
case 'PLAY_RECORDED_AUDIO':
|
|
194
|
-
icon = 'audio';
|
|
195
|
-
break;
|
|
196
|
-
case 'RECORD_AUDIO':
|
|
197
|
-
icon = 'mic';
|
|
198
|
-
break;
|
|
199
|
-
case 'PLAY_VIDEO':
|
|
200
|
-
icon = 'movie';
|
|
201
|
-
break;
|
|
202
|
-
case 'PLAY_MIDI':
|
|
203
|
-
icon = 'music';
|
|
204
|
-
break;
|
|
205
|
-
case 'URL':
|
|
206
|
-
icon = 'url';
|
|
207
|
-
break;
|
|
208
|
-
default:
|
|
209
|
-
icon = 'generic';
|
|
210
|
-
break;
|
|
211
|
-
}
|
|
212
|
-
return icon ? MediaContent.ICONS[icon] : null;
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
Object.assign(MediaContent.prototype, {
|
|
217
|
-
/**
|
|
218
|
-
* The type of media. Valid values are: `UNKNOWN`, `PLAY_AUDIO`, `PLAY_VIDEO`,
|
|
219
|
-
* `PLAY_MIDI`, `PLAY_CDAUDIO`, `RECORD_AUDIO`, `PLAY_RECORDED_AUDIO`, `RUN_CLIC_ACTIVITY`,
|
|
220
|
-
* `RUN_CLIC_PACKAGE`, `RUN_EXTERNAL`, `URL`, `EXIT` and `RETURN`
|
|
221
|
-
* @name module:media/MediaContent.MediaContent#type
|
|
222
|
-
* @type {string} */
|
|
223
|
-
type: 'UNKNOWN',
|
|
224
|
-
/**
|
|
225
|
-
* The priority level is important when different medias want to play together. Objects with
|
|
226
|
-
* highest priority level can mute lower ones.
|
|
227
|
-
* @name module:media/MediaContent.MediaContent#level
|
|
228
|
-
* @type {number} */
|
|
229
|
-
level: 1,
|
|
230
|
-
/**
|
|
231
|
-
* Media file name
|
|
232
|
-
* @name module:media/MediaContent.MediaContent#file
|
|
233
|
-
* @type {string} */
|
|
234
|
-
file: null,
|
|
235
|
-
/**
|
|
236
|
-
* Optional parameters passed to external calls
|
|
237
|
-
* @name module:media/MediaContent.MediaContent#externalParams
|
|
238
|
-
* @type {string} */
|
|
239
|
-
externalParam: null,
|
|
240
|
-
/**
|
|
241
|
-
* Special setting used to play only a fragment of media. `-1` means not used (plays full
|
|
242
|
-
* length, from the beginning)
|
|
243
|
-
* @name module:media/MediaContent.MediaContent#from
|
|
244
|
-
* @type {number} */
|
|
245
|
-
from: -1,
|
|
246
|
-
/**
|
|
247
|
-
* Special setting used to play only a fragment of media. `-1` means not used (plays to the end
|
|
248
|
-
* of the media)
|
|
249
|
-
* @name module:media/MediaContent.MediaContent#to
|
|
250
|
-
* @type {number} */
|
|
251
|
-
to: -1,
|
|
252
|
-
/**
|
|
253
|
-
* When `type` is `RECORD_AUDIO`, this member stores the maximum length of the recorded
|
|
254
|
-
* sound, in seconds.
|
|
255
|
-
* @name module:media/MediaContent.MediaContent#length
|
|
256
|
-
* @type {number} */
|
|
257
|
-
length: 3,
|
|
258
|
-
/**
|
|
259
|
-
* When `type` is `RECORD_AUDIO`, this member stores the buffer ID where the recording
|
|
260
|
-
* will be stored.
|
|
261
|
-
* @name module:media/MediaContent.MediaContent#recBuffer
|
|
262
|
-
* @type {number} */
|
|
263
|
-
recBuffer: 0,
|
|
264
|
-
/**
|
|
265
|
-
* Whether to stretch or not the video size to fit the cell space.
|
|
266
|
-
* @name module:media/MediaContent.MediaContent#stretch
|
|
267
|
-
* @type {boolean} */
|
|
268
|
-
stretch: false,
|
|
269
|
-
/**
|
|
270
|
-
* When `true`, the video plays out of the cell, centered on the activity window.
|
|
271
|
-
* @name module:media/MediaContent.MediaContent#free
|
|
272
|
-
* @type {boolean} */
|
|
273
|
-
free: false,
|
|
274
|
-
/**
|
|
275
|
-
* Places the video window at a specific location.
|
|
276
|
-
* @name module:media/MediaContent.MediaContent#absLocation
|
|
277
|
-
* @type {module:AWT.Point} */
|
|
278
|
-
absLocation: null,
|
|
279
|
-
/**
|
|
280
|
-
* When {@link module:media/MediaContent.MediaContent#absLocation} is not `null`, this field indicates from where to
|
|
281
|
-
* measure its coordinates. Valid values are: `BOX`, `WINDOW` or `FRAME`.
|
|
282
|
-
* @name module:media/MediaContent.MediaContent#absLocationFrom
|
|
283
|
-
* @type {string} */
|
|
284
|
-
absLocationFrom: null,
|
|
285
|
-
/**
|
|
286
|
-
* `true` when the video window must catch mouse clicks.
|
|
287
|
-
* @name module:media/MediaContent.MediaContent#catchMouseEvents
|
|
288
|
-
* @type {boolean} */
|
|
289
|
-
catchMouseEvents: false,
|
|
290
|
-
/**
|
|
291
|
-
* Whether to repeat the media in loop, or just one time.
|
|
292
|
-
* @name module:media/MediaContent.MediaContent#loop
|
|
293
|
-
* @type {boolean} */
|
|
294
|
-
loop: false,
|
|
295
|
-
/**
|
|
296
|
-
* When `true`, the media will automatically start playing when the associated {@link module:boxes/ActiveBox.ActiveBox ActiveBox}
|
|
297
|
-
* become active.
|
|
298
|
-
* @name module:media/MediaContent.MediaContent#autoStart
|
|
299
|
-
* @type {boolean} */
|
|
300
|
-
autoStart: false,
|
|
301
|
-
});
|
|
302
|
-
|
|
303
|
-
/**
|
|
304
|
-
* Default icons for media types.
|
|
305
|
-
* @type {object} */
|
|
306
|
-
const ICONS = {
|
|
307
|
-
generic,
|
|
308
|
-
audio,
|
|
309
|
-
movie,
|
|
310
|
-
mic,
|
|
311
|
-
music,
|
|
312
|
-
url,
|
|
313
|
-
};
|
|
314
|
-
|
|
315
|
-
/**
|
|
316
|
-
* Collection of icon {@link external:HTMLImageElement} objects
|
|
317
|
-
* @name module:media/MediaContent.MediaContent.ICONS
|
|
318
|
-
* @type {object} */
|
|
319
|
-
MediaContent.ICONS = {};
|
|
320
|
-
|
|
321
|
-
// Load the icons
|
|
322
|
-
$.each(ICONS, (key, value) => {
|
|
323
|
-
const img = new Image();
|
|
324
|
-
img.src = svgToURI(value);
|
|
325
|
-
MediaContent.ICONS[key] = img;
|
|
326
|
-
});
|
|
327
|
-
|
|
328
|
-
export default MediaContent;
|