jclic 2.1.21 → 2.1.23

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.
Files changed (175) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/jclic-node.js +9 -8
  3. package/dist/jclic-node.js.map +1 -1
  4. package/dist/jclic.min.js +2 -2
  5. package/dist/jclic.min.js.map +1 -1
  6. package/package.json +4 -4
  7. package/src/GlobalData.js +1 -1
  8. package/src/JClicPlayer.js +2 -2
  9. package/src/bags/MediaBag.js +6 -5
  10. package/dist/1078.jclic-node.js +0 -282
  11. package/dist/1078.jclic-node.js.map +0 -1
  12. package/dist/1196.jclic-node.js +0 -808
  13. package/dist/1196.jclic-node.js.map +0 -1
  14. package/dist/1253.jclic-node.js +0 -1432
  15. package/dist/1253.jclic-node.js.map +0 -1
  16. package/dist/13.jclic-node.js +0 -103
  17. package/dist/13.jclic-node.js.map +0 -1
  18. package/dist/1567.jclic-node.js +0 -2313
  19. package/dist/1567.jclic-node.js.map +0 -1
  20. package/dist/1588.jclic-node.js +0 -602
  21. package/dist/1588.jclic-node.js.map +0 -1
  22. package/dist/1725.jclic-node.js +0 -836
  23. package/dist/1725.jclic-node.js.map +0 -1
  24. package/dist/1731.jclic-node.js +0 -438
  25. package/dist/1731.jclic-node.js.map +0 -1
  26. package/dist/1842.jclic-node.js +0 -651
  27. package/dist/1842.jclic-node.js.map +0 -1
  28. package/dist/2160.jclic-node.js +0 -1016
  29. package/dist/2160.jclic-node.js.map +0 -1
  30. package/dist/222.jclic-node.js +0 -129
  31. package/dist/222.jclic-node.js.map +0 -1
  32. package/dist/2316.jclic-node.js +0 -949
  33. package/dist/2316.jclic-node.js.map +0 -1
  34. package/dist/2355.jclic-node.js +0 -371
  35. package/dist/2355.jclic-node.js.map +0 -1
  36. package/dist/2366.jclic-node.js +0 -431
  37. package/dist/2366.jclic-node.js.map +0 -1
  38. package/dist/2379.jclic-node.js +0 -202
  39. package/dist/2379.jclic-node.js.map +0 -1
  40. package/dist/2437.jclic-node.js +0 -450
  41. package/dist/2437.jclic-node.js.map +0 -1
  42. package/dist/2531.jclic-node.js +0 -869
  43. package/dist/2531.jclic-node.js.map +0 -1
  44. package/dist/2608.jclic-node.js +0 -160
  45. package/dist/2608.jclic-node.js.map +0 -1
  46. package/dist/2715.jclic-node.js +0 -554
  47. package/dist/2715.jclic-node.js.map +0 -1
  48. package/dist/277.jclic-node.js +0 -22
  49. package/dist/277.jclic-node.js.map +0 -1
  50. package/dist/2921.jclic-node.js +0 -660
  51. package/dist/2921.jclic-node.js.map +0 -1
  52. package/dist/2952.jclic-node.js +0 -101
  53. package/dist/2952.jclic-node.js.map +0 -1
  54. package/dist/3018.jclic-node.js +0 -421
  55. package/dist/3018.jclic-node.js.map +0 -1
  56. package/dist/3019.jclic-node.js +0 -682
  57. package/dist/3019.jclic-node.js.map +0 -1
  58. package/dist/3231.jclic-node.js +0 -274
  59. package/dist/3231.jclic-node.js.map +0 -1
  60. package/dist/331.jclic-node.js +0 -115
  61. package/dist/331.jclic-node.js.map +0 -1
  62. package/dist/3391.jclic-node.js +0 -276
  63. package/dist/3391.jclic-node.js.map +0 -1
  64. package/dist/3502.jclic-node.js +0 -671
  65. package/dist/3502.jclic-node.js.map +0 -1
  66. package/dist/3653.jclic-node.js +0 -982
  67. package/dist/3653.jclic-node.js.map +0 -1
  68. package/dist/371.jclic.min.js +0 -2
  69. package/dist/371.jclic.min.js.map +0 -1
  70. package/dist/3856.jclic-node.js +0 -575
  71. package/dist/3856.jclic-node.js.map +0 -1
  72. package/dist/4112.jclic-node.js +0 -659
  73. package/dist/4112.jclic-node.js.map +0 -1
  74. package/dist/4123.jclic-node.js +0 -910
  75. package/dist/4123.jclic-node.js.map +0 -1
  76. package/dist/427.jclic-node.js +0 -894
  77. package/dist/427.jclic-node.js.map +0 -1
  78. package/dist/4483.jclic-node.js +0 -327
  79. package/dist/4483.jclic-node.js.map +0 -1
  80. package/dist/4548.jclic-node.js +0 -1078
  81. package/dist/4548.jclic-node.js.map +0 -1
  82. package/dist/466.jclic-node.js +0 -99
  83. package/dist/466.jclic-node.js.map +0 -1
  84. package/dist/485.jclic-node.js +0 -783
  85. package/dist/485.jclic-node.js.map +0 -1
  86. package/dist/4921.jclic-node.js +0 -500
  87. package/dist/4921.jclic-node.js.map +0 -1
  88. package/dist/5091.jclic-node.js +0 -239
  89. package/dist/5091.jclic-node.js.map +0 -1
  90. package/dist/520.jclic-node.js +0 -550
  91. package/dist/520.jclic-node.js.map +0 -1
  92. package/dist/5312.jclic-node.js +0 -1126
  93. package/dist/5312.jclic-node.js.map +0 -1
  94. package/dist/5338.jclic-node.js +0 -212
  95. package/dist/5338.jclic-node.js.map +0 -1
  96. package/dist/5344.jclic-node.js +0 -229
  97. package/dist/5344.jclic-node.js.map +0 -1
  98. package/dist/5550.jclic-node.js +0 -238
  99. package/dist/5550.jclic-node.js.map +0 -1
  100. package/dist/5626.jclic-node.js +0 -614
  101. package/dist/5626.jclic-node.js.map +0 -1
  102. package/dist/5977.jclic-node.js +0 -1081
  103. package/dist/5977.jclic-node.js.map +0 -1
  104. package/dist/6148.jclic-node.js +0 -345
  105. package/dist/6148.jclic-node.js.map +0 -1
  106. package/dist/6176.jclic-node.js +0 -481
  107. package/dist/6176.jclic-node.js.map +0 -1
  108. package/dist/6221.jclic-node.js +0 -1072
  109. package/dist/6221.jclic-node.js.map +0 -1
  110. package/dist/6238.jclic-node.js +0 -718
  111. package/dist/6238.jclic-node.js.map +0 -1
  112. package/dist/6454.jclic-node.js +0 -1413
  113. package/dist/6454.jclic-node.js.map +0 -1
  114. package/dist/6565.jclic-node.js +0 -294
  115. package/dist/6565.jclic-node.js.map +0 -1
  116. package/dist/6579.jclic-node.js +0 -719
  117. package/dist/6579.jclic-node.js.map +0 -1
  118. package/dist/6715.jclic-node.js +0 -148
  119. package/dist/6715.jclic-node.js.map +0 -1
  120. package/dist/6777.jclic-node.js +0 -171
  121. package/dist/6777.jclic-node.js.map +0 -1
  122. package/dist/6782.jclic-node.js +0 -1611
  123. package/dist/6782.jclic-node.js.map +0 -1
  124. package/dist/6847.jclic-node.js +0 -601
  125. package/dist/6847.jclic-node.js.map +0 -1
  126. package/dist/6856.jclic-node.js +0 -252
  127. package/dist/6856.jclic-node.js.map +0 -1
  128. package/dist/696.jclic-node.js +0 -1821
  129. package/dist/696.jclic-node.js.map +0 -1
  130. package/dist/698.jclic-node.js +0 -583
  131. package/dist/698.jclic-node.js.map +0 -1
  132. package/dist/704.jclic-node.js +0 -80
  133. package/dist/704.jclic-node.js.map +0 -1
  134. package/dist/7046.jclic-node.js +0 -735
  135. package/dist/7046.jclic-node.js.map +0 -1
  136. package/dist/7220.jclic-node.js +0 -156
  137. package/dist/7220.jclic-node.js.map +0 -1
  138. package/dist/7257.jclic-node.js +0 -931
  139. package/dist/7257.jclic-node.js.map +0 -1
  140. package/dist/743.jclic-node.js +0 -583
  141. package/dist/743.jclic-node.js.map +0 -1
  142. package/dist/757.jclic-node.js +0 -1072
  143. package/dist/757.jclic-node.js.map +0 -1
  144. package/dist/7781.jclic-node.js +0 -202
  145. package/dist/7781.jclic-node.js.map +0 -1
  146. package/dist/7912.jclic-node.js +0 -2103
  147. package/dist/7912.jclic-node.js.map +0 -1
  148. package/dist/827.jclic-node.js +0 -708
  149. package/dist/827.jclic-node.js.map +0 -1
  150. package/dist/8276.jclic-node.js +0 -409
  151. package/dist/8276.jclic-node.js.map +0 -1
  152. package/dist/8322.jclic-node.js +0 -498
  153. package/dist/8322.jclic-node.js.map +0 -1
  154. package/dist/8641.jclic-node.js +0 -360
  155. package/dist/8641.jclic-node.js.map +0 -1
  156. package/dist/8837.jclic-node.js +0 -651
  157. package/dist/8837.jclic-node.js.map +0 -1
  158. package/dist/8895.jclic-node.js +0 -151
  159. package/dist/8895.jclic-node.js.map +0 -1
  160. package/dist/9072.jclic-node.js +0 -1285
  161. package/dist/9072.jclic-node.js.map +0 -1
  162. package/dist/9078.jclic-node.js +0 -935
  163. package/dist/9078.jclic-node.js.map +0 -1
  164. package/dist/9103.jclic-node.js +0 -718
  165. package/dist/9103.jclic-node.js.map +0 -1
  166. package/dist/9359.jclic-node.js +0 -145
  167. package/dist/9359.jclic-node.js.map +0 -1
  168. package/dist/9409.jclic-node.js +0 -921
  169. package/dist/9409.jclic-node.js.map +0 -1
  170. package/dist/9513.jclic-node.js +0 -720
  171. package/dist/9513.jclic-node.js.map +0 -1
  172. package/dist/9704.jclic-node.js +0 -81
  173. package/dist/9704.jclic-node.js.map +0 -1
  174. package/dist/9950.jclic-node.js +0 -827
  175. package/dist/9950.jclic-node.js.map +0 -1
@@ -1,708 +0,0 @@
1
- "use strict";
2
- exports.id = 827;
3
- exports.ids = [827,520,5091];
4
- exports.modules = {
5
-
6
- /***/ 827:
7
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
8
-
9
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10
- /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
11
- /* harmony export */ });
12
- /* unused harmony export ActiveMediaBag */
13
- /* harmony import */ var _ActiveMediaPlayer_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(520);
14
- /* harmony import */ var _Utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1253);
15
- /**
16
- * File : media/ActiveMediaBag.js
17
- * Created : 28/04/2015
18
- * By : Francesc Busquets <francesc@gmail.com>
19
- *
20
- * JClic.js
21
- * An HTML5 player of JClic activities
22
- * https://projectestac.github.io/jclic.js
23
- *
24
- * @source https://github.com/projectestac/jclic.js
25
- *
26
- * @license EUPL-1.2
27
- * @licstart
28
- * (c) 2000-2020 Educational Telematic Network of Catalonia (XTEC)
29
- *
30
- * Licensed under the EUPL, Version 1.1 or -as soon they will be approved by
31
- * the European Commission- subsequent versions of the EUPL (the "Licence");
32
- * You may not use this work except in compliance with the Licence.
33
- *
34
- * You may obtain a copy of the Licence at:
35
- * https://joinup.ec.europa.eu/software/page/eupl
36
- *
37
- * Unless required by applicable law or agreed to in writing, software
38
- * distributed under the Licence is distributed on an "AS IS" basis, WITHOUT
39
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
40
- * Licence for the specific language governing permissions and limitations
41
- * under the Licence.
42
- * @licend
43
- * @module
44
- */
45
-
46
-
47
-
48
-
49
- /**
50
- * This class stores a collection of realized {@link module:media/ActiveMediaPlayer.ActiveMediaPlayer ActiveMediaPlayer} objects, related to a
51
- * {@link module:project/JClicProject.JClicProject JClicProject} or {@link module:Activity.Activity Activity}.
52
- */
53
- class ActiveMediaBag {
54
- /**
55
- * ActiveMediaBag constructor
56
- */
57
- constructor() {
58
- this.players = [];
59
- }
60
-
61
- /**
62
- * Creates a new {@link module:media/ActiveMediaPlayer.ActiveMediaPlayer ActiveMediaPlayer} linked to this media bag
63
- * @param {module:media/MediaContent.MediaContent} mc - The content used by the new player
64
- * @param {module:bags/MediaBag.MediaBag} mb - The project's MediaBag
65
- * @param {module:JClicPlayer.JClicPlayer} ps - An object implementing the
66
- * [PlayStation](http://projectestac.github.io/jclic/apidoc/edu/xtec/jclic/PlayStation.html) interface,
67
- * usually a {@link module:JClicPlayer.JClicPlayer JClicPlayer}.
68
- * @returns {module:media/ActiveMediaPlayer.ActiveMediaPlayer}
69
- */
70
- createActiveMediaPlayer(mc, mb, ps) {
71
- let amp = null;
72
- switch (mc.type) {
73
- case 'RECORD_AUDIO':
74
- if (mc.length <= 0 || mc.length >= _Utils_js__WEBPACK_IMPORTED_MODULE_1__/* .settings */ .W0.MAX_RECORD_LENGTH)
75
- break;
76
- /* falls through */
77
- case 'PLAY_RECORDED_AUDIO':
78
- if (mc.recBuffer < 0 || mc.recBuffer >= 10)
79
- break;
80
- /* falls through */
81
- case 'PLAY_AUDIO':
82
- case 'PLAY_MIDI':
83
- case 'PLAY_VIDEO':
84
- amp = new _ActiveMediaPlayer_js__WEBPACK_IMPORTED_MODULE_0__["default"](mc, mb, ps);
85
- break;
86
- }
87
- if (amp !== null)
88
- this.players.push(amp);
89
- return amp;
90
- }
91
-
92
- /**
93
- * Looks for an already existing {@link module:media/ActiveMediaPlayer.ActiveMediaPlayer ActiveMediaPlayer} equivalent to the requested.
94
- * When not found, a new one is created and and returned.
95
- * @param {module:media/MediaContent.MediaContent} mc - The content used by the new player
96
- * @param {module:bags/MediaBag.MediaBag} mb - The project's MediaBag
97
- * @param {module:JClicPlayer.JClicPlayer} ps - An object implementing the
98
- * {@link http://projectestac.github.io/jclic/apidoc/edu/xtec/jclic/PlayStation.html|PlayStation} interface,
99
- * usually a {@link module:JClicPlayer.JClicPlayer JClicPlayer}.
100
- * @returns {module:media/ActiveMediaPlayer.ActiveMediaPlayer}
101
- */
102
- getActiveMediaPlayer(mc, mb, ps) {
103
- return this.players.find(p => p.mc === mc || p.mc.isEquivalent(mc))
104
- || this.createActiveMediaPlayer(mc, mb, ps);
105
- }
106
-
107
- /**
108
- * Removes from the list of players the {@link module:media/ActiveMediaPlayer.ActiveMediaPlayer ActiveMediaPlayer} related to the specified {@link module:media/MediaContent.MediaContent}.
109
- * @param {module:media/MediaContent.MediaContent} mc - The media content to look for.
110
- */
111
- removeActiveMediaPlayer(mc) {
112
- const i = this.players.findIndex(p => p.mc === mc);
113
- if (i >= 0) {
114
- this.players[i].clear();
115
- // removes the element pointed by 'i'
116
- this.players.splice(i, 1);
117
- }
118
- }
119
-
120
- /**
121
- * Realizes all the media elements stored in this bag
122
- */
123
- realizeAll() {
124
- this.players.forEach(p => p.realize());
125
- }
126
-
127
- /**
128
- * Stops playing all media elements stored in this bag
129
- * @param {number} level - Level at and below what all media players will be muted.
130
- */
131
- stopAll(level) {
132
- if (typeof level === 'undefined')
133
- level = -1;
134
- this.players.forEach(amp => {
135
- if (level === -1 || amp.mc !== null && amp.mc.level <= level)
136
- amp.stop();
137
- });
138
- }
139
-
140
- /**
141
- * Removes all players from this media bag
142
- */
143
- removeAll() {
144
- this.players.forEach(p => p.clear());
145
- // Empty the `players` array
146
- this.players.length = 0;
147
- _ActiveMediaPlayer_js__WEBPACK_IMPORTED_MODULE_0__["default"].prototype.clearAllAudioBuffers();
148
- }
149
- }
150
-
151
- Object.assign(ActiveMediaBag.prototype, {
152
- /**
153
- * The collection of {@link module:media/ActiveMediaPlayer.ActiveMediaPlayer ActiveMediaPlayer} objects stored in this media bag.
154
- * @name module:media/ActiveMediaBag.ActiveMediaBag#players
155
- * @type {module:media/ActiveMediaPlayer.ActiveMediaPlayer[]} */
156
- players: [],
157
- });
158
-
159
- /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (ActiveMediaBag);
160
-
161
-
162
- /***/ }),
163
-
164
- /***/ 520:
165
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
166
-
167
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
168
- /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
169
- /* harmony export */ });
170
- /* unused harmony export ActiveMediaPlayer */
171
- /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7750);
172
- /* harmony import */ var jquery__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(jquery__WEBPACK_IMPORTED_MODULE_0__);
173
- /* harmony import */ var _AudioBuffer_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(5091);
174
- /**
175
- * File : media/ActiveMediaPlayer.js
176
- * Created : 28/04/2015
177
- * By : Francesc Busquets <francesc@gmail.com>
178
- *
179
- * JClic.js
180
- * An HTML5 player of JClic activities
181
- * https://projectestac.github.io/jclic.js
182
- *
183
- * @source https://github.com/projectestac/jclic.js
184
- *
185
- * @license EUPL-1.2
186
- * @licstart
187
- * (c) 2000-2020 Educational Telematic Network of Catalonia (XTEC)
188
- *
189
- * Licensed under the EUPL, Version 1.1 or -as soon they will be approved by
190
- * the European Commission- subsequent versions of the EUPL (the "Licence");
191
- * You may not use this work except in compliance with the Licence.
192
- *
193
- * You may obtain a copy of the Licence at:
194
- * https://joinup.ec.europa.eu/software/page/eupl
195
- *
196
- * Unless required by applicable law or agreed to in writing, software
197
- * distributed under the Licence is distributed on an "AS IS" basis, WITHOUT
198
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
199
- * Licence for the specific language governing permissions and limitations
200
- * under the Licence.
201
- * @licend
202
- * @module
203
- */
204
-
205
- /* global navigator */
206
-
207
-
208
-
209
-
210
- /**
211
- * This kind of object encapsulates a realized {@link module:media/MediaContent.MediaContent} and provides methods to start,
212
- * stop, pause and record different types of media (audio, video, MIDI, voice recording...)
213
- */
214
- class ActiveMediaPlayer {
215
- /**
216
- * ActiveMediaPlayer constructor
217
- * @param {module:media/MediaContent.MediaContent} mc - - The content used by this player
218
- * @param {module:bags/MediaBag.MediaBag} mb - The project's MediaBag
219
- * @param {module:JClicPlayer.JClicPlayer} ps - An object implementing the
220
- * {@link http://projectestac.github.io/jclic/apidoc/edu/xtec/jclic/PlayStation.html PlayStation} interface,
221
- * usually a {@link module:JClicPlayer.JClicPlayer JClicPlayer}.
222
- */
223
- constructor(mc, mb, ps) {
224
- this.mc = mc;
225
- this.ps = ps;
226
- switch (mc.type) {
227
- case 'RECORD_AUDIO':
228
- if (ActiveMediaPlayer.AUDIO_BUFFERS) {
229
- this.clearAudioBuffer(mc.recBuffer);
230
- ActiveMediaPlayer.AUDIO_BUFFERS[mc.recBuffer] = new _AudioBuffer_js__WEBPACK_IMPORTED_MODULE_1__["default"](mc.length);
231
- }
232
- /* falls through */
233
- case 'PLAY_RECORDED_AUDIO':
234
- this.useAudioBuffer = true;
235
- break;
236
- case 'PLAY_AUDIO':
237
- case 'PLAY_VIDEO':
238
- case 'PLAY_MIDI':
239
- this.mbe = mb.getElement(mc.file, true);
240
- break;
241
- default:
242
- break;
243
- }
244
- }
245
-
246
- /**
247
- * Generates the objects that will play media
248
- */
249
- realize() {
250
- if (this.mbe) {
251
- this.mbe.build(mbe => {
252
- if (mbe.data && mbe.data.pause && !mbe.data.paused && !mbe.data.ended && mbe.data.currentTime)
253
- mbe.data.pause();
254
- if ((mbe.type === 'video' || mbe.type === 'anim') && mbe.data) {
255
- this.$visualComponent = jquery__WEBPACK_IMPORTED_MODULE_0___default()(mbe.data);
256
- this.$visualComponent.css('z-index', 20);
257
- }
258
- }, this.ps, false, this.mc.level);
259
- }
260
- }
261
-
262
- /**
263
- * Plays the media, realizing it if needed.
264
- * @param {module:boxes/ActiveBox.ActiveBox} [_setBx] - The active box where this media will be placed (when video)
265
- */
266
- playNow(_setBx) {
267
- // TODO: Remove unused param "_setBx"
268
- if (this.useAudioBuffer) {
269
- if (ActiveMediaPlayer.AUDIO_BUFFERS) {
270
- const $div = this.ps && this.ps.$div;
271
- const buffer = ActiveMediaPlayer.AUDIO_BUFFERS[this.mc.recBuffer];
272
- if (buffer) {
273
- if (this.mc.type === 'RECORD_AUDIO') {
274
- buffer.record($div);
275
- } else {
276
- buffer.play();
277
- }
278
- }
279
- }
280
- } else if (this.mbe) {
281
- this.mbe.build(() => {
282
- if (this.mbe.data) {
283
- if (this.mbe.type === 'midi') {
284
- this.mbe.data.playTo = this.mc.to || 0;
285
- } else {
286
- let armed = false;
287
- const $player = jquery__WEBPACK_IMPORTED_MODULE_0___default()(this.mbe.data);
288
- // Clear previous event handlers
289
- $player.off();
290
- // If there is a time fragment specified, prepare to stop when the `to` position is reached
291
- if (this.mc.to > 0) {
292
- $player.on('timeupdate', () => {
293
- if (armed && this.mbe.data.currentTime >= this.mc.to / 1000) {
294
- $player.off('timeupdate');
295
- this.mbe.data.pause();
296
- }
297
- });
298
- }
299
- // Launch the media despite of its readyState
300
- armed = true;
301
- }
302
- if (!this.mbe.data.paused && !this.mbe.data.ended && this.mbe.data.currentTime)
303
- this.mbe.data.pause();
304
- // Seek the media position
305
- this.mbe.data.currentTime = this.mc.from > 0 ? this.mc.from / 1000 : 0;
306
- this.mbe.data.play();
307
- }
308
- }, this.ps, true, this.mc.level);
309
- }
310
- }
311
-
312
- /**
313
- * Plays the media when available, without blocking the current thread.
314
- * @param {module:boxes/ActiveBox.ActiveBox} [setBx] - The active box where this media will be placed (when video)
315
- */
316
- play(setBx) {
317
- this.stopAllAudioBuffers();
318
- this.playNow(setBx);
319
- }
320
-
321
- /**
322
- * Stops the media playing
323
- */
324
- stop() {
325
- if (this.useAudioBuffer)
326
- this.stopAudioBuffer(this.mc.recBuffer);
327
- else if (this.mbe && this.mbe.data && this.mbe.data.pause && !this.mbe.data.paused && !this.mbe.data.ended && this.mbe.data.currentTime)
328
- this.mbe.data.pause();
329
- }
330
-
331
- /**
332
- * Frees all resources used by this player
333
- */
334
- clear() {
335
- this.stop();
336
- if (this.useAudioBuffer)
337
- this.clearAudioBuffer(this.mc.recBuffer);
338
- }
339
-
340
- /**
341
- * Clears the specified audio buffer
342
- * @param {number} buffer - Index of the buffer in {@link module:media/ActiveMediaPlayer.ActiveMediaPlayer#AUDIO_BUFFERS AUDIO_BUFFERS}
343
- */
344
- clearAudioBuffer(buffer) {
345
- if (ActiveMediaPlayer.AUDIO_BUFFERS &&
346
- buffer >= 0 && buffer < ActiveMediaPlayer.AUDIO_BUFFERS.length &&
347
- ActiveMediaPlayer.AUDIO_BUFFERS[buffer]) {
348
- ActiveMediaPlayer.AUDIO_BUFFERS[buffer].clear();
349
- ActiveMediaPlayer.AUDIO_BUFFERS[buffer] = null;
350
- }
351
- }
352
-
353
- /**
354
- * Clears all audio buffers
355
- */
356
- clearAllAudioBuffers() {
357
- if (ActiveMediaPlayer.AUDIO_BUFFERS)
358
- ActiveMediaPlayer.AUDIO_BUFFERS.forEach((_buffer, n) => this.clearAudioBuffer(n));
359
- }
360
-
361
- /**
362
- * Counts the number of active audio buffers
363
- * @returns {number}
364
- */
365
- countActiveBuffers() {
366
- return ActiveMediaPlayer.AUDIO_BUFFERS ? ActiveMediaPlayer.AUDIO_BUFFERS.reduce((c, ab) => c + ab ? 1 : 0, 0) : 0;
367
- }
368
-
369
- /**
370
- * Stops the playing or recording actions of all audio buffers
371
- */
372
- stopAllAudioBuffers() {
373
- if (ActiveMediaPlayer.AUDIO_BUFFERS)
374
- ActiveMediaPlayer.AUDIO_BUFFERS.forEach(ab => ab ? ab.stop() : null);
375
- }
376
-
377
- /**
378
- * Stops a specific audio buffer
379
- * @param {number} buffer - Index of the buffer in {@link module:media/ActiveMediaPlayer.ActiveMediaPlayer#AUDIO_BUFFERS AUDIO_BUFFERS}
380
- */
381
- stopAudioBuffer(buffer) {
382
- if (ActiveMediaPlayer.AUDIO_BUFFERS &&
383
- buffer >= 0 && buffer < ActiveMediaPlayer.AUDIO_BUFFERS.length &&
384
- ActiveMediaPlayer.AUDIO_BUFFERS[buffer])
385
- ActiveMediaPlayer.AUDIO_BUFFERS[buffer].stop();
386
- }
387
-
388
- /**
389
- * Checks the position of visual components after a displacement or resizing of its container
390
- * @param {module:boxes/ActiveBox.ActiveBox} _bxi - The container where this player is hosted
391
- */
392
- checkVisualComponentBounds(_bxi) {
393
- // does nothing
394
- }
395
-
396
- /**
397
- * Sets the visual component of this player visible or invisible
398
- * @param {boolean} _state - `true` for visible
399
- */
400
- setVisualComponentVisible(_state) {
401
- // TODO: Implement setVisualComponentVisible
402
- }
403
-
404
- /**
405
- * Sets the ActiveBox associated to this media player
406
- * @param {module:boxes/ActiveBox.ActiveBox} setBx - The new container of this media. Can be `null`.
407
- */
408
- linkTo(setBx) {
409
- this.bx = setBx;
410
- if (this.bx && this.$visualComponent)
411
- this.bx.setHostedComponent(this.$visualComponent);
412
- }
413
- }
414
-
415
- Object.assign(ActiveMediaPlayer.prototype, {
416
- /**
417
- * The MediaContent associated to this player.
418
- * @name module:media/ActiveMediaPlayer.ActiveMediaPlayer#mc
419
- * @type {module:media/MediaContent.MediaContent} */
420
- mc: null,
421
- /**
422
- * The player to which this player belongs.
423
- * @name module:media/ActiveMediaPlayer.ActiveMediaPlayer#ps
424
- * @type {module:JClicPlayer.JClicPlayer} */
425
- ps: null,
426
- /**
427
- * MediaPlayers should be linked to {@link module:boxes/ActiveBox.ActiveBox ActiveBox} objects.
428
- * @name module:media/ActiveMediaPlayer.ActiveMediaPlayer#bx
429
- * @type {module:boxes/ActiveBox.ActiveBox} */
430
- bx: null,
431
- /**
432
- * The visual component for videos, usually a `video` HTML element
433
- * @name module:media/ActiveMediaPlayer.ActiveMediaPlayer#$visualComponent
434
- * @type {external:jQuery} */
435
- $visualComponent: null,
436
- /**
437
- * When `true`, this player makes use of a recording audio buffer
438
- * @name module:media/ActiveMediaPlayer.ActiveMediaPlayer#useAudioBuffer
439
- * @type {boolean} */
440
- useAudioBuffer: false,
441
- /**
442
- * The {@link module:bads/MediaBagElement.MediaBagElement} containing the reference to the media to be played
443
- * @name module:media/ActiveMediaPlayer.ActiveMediaPlayer#mbe
444
- * @type {module:bags/MediaBagElement.MediaBagElement} */
445
- mbe: null,
446
- });
447
-
448
- /**
449
- * Recording of audio is enabled only when `navigator.getUserMedia` and `MediaRecorder` are defined
450
- * In 02-Mar-2016 this is implemented only in Firefox 41 and Chrome 49 or later.
451
- * See: {@link https://addpipe.com/blog/mediarecorder-api}
452
- * @type Boolean
453
- */
454
- ActiveMediaPlayer.REC_ENABLED = typeof MediaRecorder !== 'undefined' && typeof navigator !== 'undefined';
455
-
456
- if (ActiveMediaPlayer.REC_ENABLED) {
457
- navigator.getUserMedia = navigator.getUserMedia ||
458
- navigator.webkitGetUserMedia ||
459
- navigator.mozGetUserMedia ||
460
- navigator.msGetUserMedia;
461
- }
462
-
463
- /**
464
- * Audio buffers used for recording and playing voice are stored in a static array because
465
- * they are common to all instances of {@link module:media/ActiveMediaPlayer.ActiveMediaPlayer ActiveMediaPlayer}
466
- * Only initialized when {@link module:media/ActiveMediaPlayer.ActiveMediaPlayer#REC_ENABLED REC_ENABLED} is `true`.
467
- * @type {external:AudioBuffer[]} */
468
- ActiveMediaPlayer.AUDIO_BUFFERS = ActiveMediaPlayer.REC_ENABLED ? [] : null;
469
-
470
- /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (ActiveMediaPlayer);
471
-
472
-
473
- /***/ }),
474
-
475
- /***/ 5091:
476
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
477
-
478
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
479
- /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
480
- /* harmony export */ });
481
- /* unused harmony export AudioBuffer */
482
- /* harmony import */ var _Utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1253);
483
- /**
484
- * File : media/EventSoundsElement.js
485
- * Created : 01/04/2015
486
- * By : Francesc Busquets <francesc@gmail.com>
487
- *
488
- * JClic.js
489
- * An HTML5 player of JClic activities
490
- * https://projectestac.github.io/jclic.js
491
- *
492
- * @source https://github.com/projectestac/jclic.js
493
- *
494
- * @license EUPL-1.2
495
- * @licstart
496
- * (c) 2000-2020 Educational Telematic Network of Catalonia (XTEC)
497
- *
498
- * Licensed under the EUPL, Version 1.1 or -as soon they will be approved by
499
- * the European Commission- subsequent versions of the EUPL (the "Licence");
500
- * You may not use this work except in compliance with the Licence.
501
- *
502
- * You may obtain a copy of the Licence at:
503
- * https://joinup.ec.europa.eu/software/page/eupl
504
- *
505
- * Unless required by applicable law or agreed to in writing, software
506
- * distributed under the Licence is distributed on an "AS IS" basis, WITHOUT
507
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
508
- * Licence for the specific language governing permissions and limitations
509
- * under the Licence.
510
- * @licend
511
- * @module
512
- */
513
-
514
- /* global navigator, window, document, Blob, URL, MediaRecorder */
515
-
516
-
517
-
518
- /**
519
- * The AudioBuffer object provides sound recording and replaying to activities.
520
- */
521
- class AudioBuffer {
522
- /**
523
- * AudioBuffer constructor
524
- * @param {number} [seconds] - The maximum amount of time allowed to be recorded by this AudioBuffer
525
- */
526
- constructor(seconds) {
527
- if (navigator && navigator.mediaDevices && navigator.mediaDevices.getUserMedia)
528
- this.enabled = true;
529
- if (seconds)
530
- this.seconds = seconds;
531
- this.chunks = [];
532
- }
533
-
534
- /**
535
- * Starts playing the currently recorded audio, if any.
536
- */
537
- play() {
538
- this.stop();
539
- if (this.mediaPlayer) {
540
- this.mediaPlayer.currentTime = 0;
541
- this.mediaPlayer.play();
542
- } else {
543
- this.playWhenFinished = true;
544
- }
545
- }
546
-
547
- /**
548
- * Stops the current operation, either recording or playing audio
549
- */
550
- stop() {
551
- if (this.mediaRecorder && this.mediaRecorder.state === 'recording')
552
- this.mediaRecorder.stop();
553
- else if (this.mediaPlayer && !this.mediaPlayer.paused)
554
- this.mediaPlayer.pause();
555
- }
556
-
557
- /**
558
- * Starts recording audio, or stops the recording if already started.
559
- * @param {external:jQuery} [$div] - Optional `div` element where the recording is performed, as a jQuery ref.
560
- */
561
- record($div) {
562
- if (this.mediaRecorder && this.mediaRecorder.state === 'recording')
563
- this.mediaRecorder.stop();
564
- else if (this.enabled) {
565
- this.stop();
566
- this.mediaPlayer = null;
567
-
568
- navigator.mediaDevices.getUserMedia({ audio: true, video: false })
569
- .then(mediaStream => {
570
-
571
- this.mediaRecorder = new MediaRecorder(mediaStream);
572
-
573
- this.mediaRecorder.ondataavailable = ev => this.chunks.push(ev.data);
574
-
575
- this.mediaRecorder.onerror = err => {
576
- (0,_Utils_js__WEBPACK_IMPORTED_MODULE_0__/* .log */ .Rm)('error', `Error recording audio: ${err}`);
577
- this.mediaRecorder = null;
578
- };
579
-
580
- this.mediaRecorder.onstart = () => {
581
- (0,_Utils_js__WEBPACK_IMPORTED_MODULE_0__/* .log */ .Rm)('debug', 'Recording audio started');
582
- this.visualFeedbak(true, $div);
583
- };
584
-
585
- this.mediaRecorder.onstop = () => {
586
- (0,_Utils_js__WEBPACK_IMPORTED_MODULE_0__/* .log */ .Rm)('debug', 'Recording audio finished');
587
- this.visualFeedbak(false, $div);
588
-
589
- if (this.timeoutID) {
590
- window.clearTimeout(this.timeoutID);
591
- this.timeoutID = null;
592
- }
593
-
594
- const options = {};
595
- if (this.chunks.length > 0 && this.chunks[0].type)
596
- options.type = this.chunks[0].type;
597
- const blob = new Blob(this.chunks, options);
598
- this.chunks = [];
599
- this.mediaPlayer = document.createElement('audio');
600
- this.mediaPlayer.src = URL.createObjectURL(blob);
601
- this.mediaPlayer.pause();
602
- this.mediaRecorder = null;
603
- if (this.playWhenFinished) {
604
- this.playWhenFinished = false;
605
- this.mediaPlayer.play();
606
- }
607
- };
608
-
609
- this.mediaRecorder.onwarning = ev => (0,_Utils_js__WEBPACK_IMPORTED_MODULE_0__/* .log */ .Rm)('warn', `Warning recording audio: ${ev}`);
610
-
611
- this.playWhenFinished = false;
612
-
613
- this.mediaRecorder.start();
614
-
615
- this.timeoutID = window.setTimeout(() => {
616
- if (this.mediaRecorder);
617
- this.mediaRecorder.stop();
618
- }, this.seconds * 1000);
619
- })
620
- .catch(err => {
621
- (0,_Utils_js__WEBPACK_IMPORTED_MODULE_0__/* .log */ .Rm)('error', err.toString());
622
- this.visualFeedbak(false, $div);
623
- });
624
- }
625
- }
626
-
627
- /**
628
- * Set visual feedback to the user while the system is recording audio
629
- * Currently changes the cursor pointer associated to the HTML element
630
- * containing the recorder.
631
- * @param {boolean} enabled - Flag indicating if the visual feedback should be active or inactive
632
- * @param {external:jQuery} [$div] - Optional `div` element where the recording is performed, as a jQuery ref.
633
- */
634
- visualFeedbak(enabled, $div) {
635
- if ($div)
636
- $div.css('cursor', enabled ? 'progress' : 'inherit');
637
- }
638
-
639
- /**
640
- * Clears all data associated to this AudioBuffer
641
- */
642
- clear() {
643
- this.stop();
644
- this.mediaPlayer = null;
645
- }
646
- }
647
-
648
- Object.assign(AudioBuffer.prototype, {
649
- /**
650
- * AudioBuffer is enabled only in browsers with `navigator.MediaDevices.getuserMedia`
651
- * @name module:media/AudioBuffer.AudioBuffer#enabled
652
- * @type {boolean}
653
- */
654
- enabled: false,
655
- /**
656
- * Maximum length of recordings allowed to this AudioBuffer (in seconds)
657
- * @name module:media/AudioBuffer.AudioBuffer#seconds
658
- * @type {number}
659
- */
660
- seconds: 20,
661
- /**
662
- * The object used to record audio data and convert it to a valid stream for the {@link module:media/ActiveMediaPlayer.ActiveMediaPlayer ActiveMediaPlayer}
663
- * @name module:media/AudioBuffer.AudioBuffer#mediaRecorder
664
- * @type {external:MediaRecorder}
665
- */
666
- mediaRecorder: null,
667
- /**
668
- * Array of data chunks collected during the recording
669
- * @name module:media/AudioBuffer.AudioBuffer#chunks
670
- * @type {external:Blob[]}
671
- */
672
- chunks: null,
673
- /**
674
- * The HTML audio element used to play the recorded sound
675
- * @name module:media/AudioBuffer.AudioBuffer#mediaPlayer
676
- * @type {external:HTMLAudioElement}
677
- */
678
- mediaPlayer: null,
679
- /**
680
- * The identifier of the timer launched to stop the recording when the maximum time is exceeded.
681
- * This member is `null` when no timeout function is associated to this AudioBuffer
682
- * @name module:media/AudioBuffer.AudioBuffer#timeoutID
683
- * @type {number}
684
- */
685
- timeoutID: null,
686
- /**
687
- * Instructs this AudioBuffer recorder to start playing the collected audio at the end of the
688
- * current `mediaRecorder` task.
689
- * @name module:media/AudioBuffer.AudioBuffer#playWhenFinished
690
- * @type {boolean}
691
- */
692
- playWhenFinished: false,
693
- });
694
-
695
- /**
696
- * Maximum amount of time allowed for recordings (in seconds)
697
- * @type {number}
698
- */
699
- AudioBuffer.MAX_RECORD_LENGTH = 180;
700
-
701
- /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (AudioBuffer);
702
-
703
-
704
- /***/ })
705
-
706
- };
707
- ;
708
- //# sourceMappingURL=827.jclic-node.js.map