jclic 2.1.21 → 2.1.22

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