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 +0,0 @@
1
- {"version":3,"file":"1196.jclic-node.js","mappings":";;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEuB;AACmC;AAC6D;AACtF;;AAEjC;AACA,+CAA+C,6CAA6C;AAC5F;AACA;AACA;AACA,qCAAqC,6DAA6D;AAClG;AACA;AACO;AACP;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,QAAQ;AACrB,aAAa,gBAAgB;AAC7B;AACA;AACA;AACA;AACA;AACA,kBAAkB,2DAAM;AACxB,kBAAkB,2DAAM;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,gCAAgC,yDAAQ;AACxC;;;AAGA;AACA,8BAA8B,0FAA0F;AACxH;AACA;AACA,YAAY;AACZ;AACA;;AAEA;AACA,sBAAsB;AACtB;AACA,aAAa,QAAQ;AACrB,eAAe;AACf;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,8BAA8B,4CAA4C;AAC1E;AACA;AACA,YAAY;AACZ;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,iBAAiB;AAC9B;AACA;AACA,gBAAgB,2DAAM;AACtB,gBAAgB,2DAAM;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,eAAe,QAAQ;AACvB;AACA;AACA,WAAW,4DAAO;AAClB;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA,WAAW,4DAAO;AAClB;AACA,KAAK;;AAEL;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,gBAAgB;AAChB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oDAAoD,uBAAuB;AAC3E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc,wDAAG,oCAAoC,UAAU;AAC/D;AACA;AACA;AACA;AACA;AACA,KAAK;;AAEL;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;;AAEA;AACA;AACA,eAAe;AACf;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB,eAAe;AACf;AACA;AACA;AACA,qBAAqB,yDAAQ;AAC7B,UAAU,yDAAQ;AAClB;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,UAAU;AACvB,aAAa,gCAAgC,kDAAkD,iDAAiD;AAChJ,aAAa,SAAS,yEAAyE,yDAAyD;AACxJ,aAAa,QAAQ;AACrB;AACA;AACA;AACA,QAAQ,yDAAQ;AAChB;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kCAAkC,eAAe,cAAc,EAAE,UAAU,SAAS,YAAY,OAAO,IAAI;;AAE3G,cAAc,sEAAiB;AAC/B,8BAA8B,mDAAI;AAClC;AACA;;AAEA;AACA;AACA,yDAAyD,2BAA2B,IAAI,YAAY;AACpG;AACA;;AAEA;AACA;AACA,4DAA4D,2BAA2B,IAAI,YAAY;AACvG;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkB,wDAAG,oCAAoC,OAAO,kBAAkB,SAAS;AAC3F;AACA;AACA,kEAAkE,2BAA2B,IAAI,YAAY;AAC7G;AACA;AACA;AACA;AACA;AACA,kBAAkB,wDAAG,+CAA+C,MAAM,IAAI,SAAS;AACvF;AACA;AACA;AACA;;AAEA;AACA;AACA,0BAA0B,6CAAC,+EAA+E,SAAS;AACnH;AACA;AACA;;AAEA;AACA,cAAc,iDAAK;AACnB;AACA,8DAA8D,iEAAY;AAC1E;AACA,eAAe;AACf,gBAAgB,wDAAG,2BAA2B,UAAU,IAAI,IAAI;AAChE;AACA,eAAe;AACf;;AAEA;AACA;AACA;AACA;AACA;AACA,oCAAoC,iEAAe;AACnD;AACA,oBAAoB,wDAAG,2BAA2B,UAAU,IAAI,mBAAmB;AACnF;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,cAAc,wDAAG,4CAA4C,UAAU;AACvE;AACA;;AAEA;AACA;AACA,SAAS;AACT;AACA;;AAEA;AACA;;AAEA;AACA;AACA,eAAe,SAAS;AACxB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,eAAe,SAAS;AACxB;AACA;AACA;AACA;AACA,MAAM,wDAAG,mCAAmC,UAAU;AACtD;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,eAAe;AACf;AACA;AACA;AACA;;AAEA;AACA;AACA,eAAe;AACf;AACA;AACA,WAAW,mEAAc;AACzB;AACA;AACA,yBAAyB,yDAAQ;AACjC;AACA;AACA;AACA,OAAO;AACP;AACA;;AAEA;AACA;AACA;AACA;AACA,YAAY,QAAQ;AACpB;AACA;AACA;AACA;AACA,YAAY,QAAQ;AACpB;AACA;AACA;AACA;AACA,YAAY,QAAQ;AACpB;AACA;AACA;AACA;AACA,YAAY,QAAQ;AACpB;AACA;AACA;AACA;AACA,YAAY,gBAAgB;AAC5B;AACA;AACA;AACA;AACA,YAAY,QAAQ;AACpB;AACA;AACA;AACA;AACA,YAAY,SAAS;AACrB;AACA;AACA;AACA;AACA;AACA,YAAY,YAAY;AACxB;AACA;AACA;AACA;AACA,YAAY,QAAQ;AACpB;AACA;AACA;AACA;AACA,YAAY,QAAQ;AACpB;AACA;AACA;AACA;AACA,YAAY,QAAQ;AACpB;AACA;AACA;AACA;AACA;AACA,YAAY,SAAS;AACrB;AACA;AACA;AACA;AACA;AACA,YAAY;AACZ;AACA;AACA,CAAC;;AAED,iEAAe,eAAe,EAAC;;;;;;;;;;;;;;;ACngB/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEwD;AACtB;;AAElC;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACO;AACP;AACA;AACA,aAAa,sBAAsB;AACnC,aAAa,QAAQ,WAAW;AAChC;AACA;AACA;AACA;AACA;AACA,gCAAgC;AAChC;AACA;AACA;AACA;AACA;AACA,wBAAwB,8EAAiB;AACzC;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,uBAAuB;AACpC;AACA,uCAAuC;AACvC;AACA;AACA;AACA,MAAM,+EAAoB;AAC1B;AACA;AACA,WAAW,+DAA+D,GAAG,+DAA+D,EAAE,yEAAyE;AACvN;AACA,UAAU,wDAAG;AACb;AACA,SAAS;AACT;AACA,UAAU,wDAAG,sDAAsD,IAAI;AACvE,SAAS;AACT;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oIAAoI,iDAAiD;AACrL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,YAAY,sBAAsB;AAClC;AACA;AACA;AACA;AACA,YAAY,uBAAuB;AACnC;AACA;AACA;AACA;AACA,YAAY,QAAQ;AACpB;AACA;AACA;AACA;AACA,YAAY,QAAQ;AACpB;AACA;AACA;AACA;AACA;AACA,YAAY,YAAY;AACxB;AACA,CAAC;;AAED;AACA,QAAQ,6BAA6B;AACrC,UAAU;AACV;AACA;;AAEA;AACA;AACA;AACA,UAAU;AACV;AACA;;AAEA;AACA,6CAA6C;AAC7C,UAAU;AACV;AACA;;AAEA;AACA,yDAAyD;AACzD;AACA;AACA,UAAU;AACV;AACA;;AAEA;AACA;AACA;AACA,UAAU;AACV;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;;AAEA;AACA;AACA;AACA;AACA,UAAU;AACV;AACA;;AAEA,iEAAe,eAAe,EAAC","sources":["webpack://jclic/./src/bags/MediaBagElement.js","webpack://jclic/./src/media/MidiAudioPlayer.js"],"sourcesContent":["/**\n * File : bags/MediaBagElement.js\n * Created : 07/04/2015\n * By : Francesc Busquets <francesc@gmail.com>\n *\n * JClic.js\n * An HTML5 player of JClic activities\n * https://projectestac.github.io/jclic.js\n *\n * @source https://github.com/projectestac/jclic.js\n *\n * @license EUPL-1.2\n * @licstart\n * (c) 2000-2020 Educational Telematic Network of Catalonia (XTEC)\n *\n * Licensed under the EUPL, Version 1.1 or -as soon they will be approved by\n * the European Commission- subsequent versions of the EUPL (the \"Licence\");\n * You may not use this work except in compliance with the Licence.\n *\n * You may obtain a copy of the Licence at:\n * https://joinup.ec.europa.eu/software/page/eupl\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the Licence is distributed on an \"AS IS\" basis, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n * Licence for the specific language governing permissions and limitations\n * under the Licence.\n * @licend\n * @module\n */\n\n/* global URL, Uint8Array, XMLHttpRequest, Image, document */\n\nimport $ from 'jquery';\nimport MidiAudioPlayer from '../media/MidiAudioPlayer.js';\nimport { log, settings, nSlash, getAttr, isEmpty, getPathPromise, parseXmlNode, appendStyleAtHead } from '../Utils.js';\nimport { Font } from '../AWT.js';\n\n/**\n * This kind of objects are the components of {@link module:bags/MediaBag.MediaBag MediaBag}.\n *\n * Media elements have a name, a reference to a file (the `file` field) and, when initialized,\n * a `data` field pointing to a object containing the real media. They have also a flag indicating\n * if the data must be saved on the {@link module:project/JClicProject.JClicProject JClicProject} zip file or just maintained as a reference\n * to an external file.\n */\nexport class MediaBagElement {\n /**\n * MediaBagElement constructor\n * @param {string} basePath - Path to be used as a prefix of the file name\n * @param {string} file - The media file name\n * @param {external:JSZip} [zip] - An optional JSZip object from which the file must be extracted.\n */\n constructor(basePath, file, zip) {\n if (basePath)\n this.basePath = basePath;\n if (file) {\n this.file = nSlash(file);\n this.name = nSlash(file);\n this.ext = this.file.toLowerCase().split('.').pop();\n this.type = this.getFileType(this.ext);\n if (this.ext === 'gif')\n this.checkAnimatedGif();\n }\n if (zip)\n this.zip = zip;\n this.timeout = Date.now() + settings.LOAD_TIMEOUT;\n }\n\n\n /**\n * Private static array of {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLAudioElement HTMLAudioElements},\n * to be reused between all media elements of type 'audio'. One for each priority level\n * @name module:bags/MediaBagElement#_audioPlayers\n * @type {external:HTMLAudioElement[]}\n */\n static _audioPlayers = [];\n\n /**\n * Gets the static {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLAudioElement HTMLAudioElement}\n * associated to the requested priority level.\n * @param {number} level=1 - The priority level\n * @returns {external:HTMLAudioElement}\n */\n static getAudioPlayer(level = 1) {\n if (!MediaBagElement._audioPlayers[level])\n MediaBagElement._audioPlayers[level] = document.createElement('audio');\n return MediaBagElement._audioPlayers[level];\n }\n\n /**\n * Private static array of {@link bags/MediaBagElement MediaBagElements},\n * used to store a reference to the element using each `audioPlayer`\n * @name module:bags/MediaBagElement#_currentAudioElements\n * @type {bags/MediaBagElement[]}\n */\n static _currentAudioElements = [];\n\n /**\n * Clear all references to audio players and audio elements\n * To be called when a new activity starts\n */\n static resetAudioElements() {\n MediaBagElement._audioPlayers.fill(null);\n MediaBagElement._currentAudioElements.fill(null);\n }\n\n /**\n * Loads this object settings from a specific JQuery XML element\n * @param {external:jQuery} $xml - The XML element to parse\n */\n setProperties($xml) {\n this.name = nSlash($xml.attr('name'));\n this.file = nSlash($xml.attr('file'));\n this.ext = this.file.toLowerCase().split('.').pop();\n this.type = this.getFileType(this.ext);\n // Check if it's an animated GIF\n if (this.ext === 'gif') {\n const anim = $xml.attr('animated');\n if (typeof anim === 'undefined')\n this.checkAnimatedGif();\n else\n this.animated = anim === 'true';\n }\n if (this.type === 'font') {\n this.fontName = this.name === this.file && this.name.lastIndexOf('.') > 0 ?\n this.name.substring(0, this.name.lastIndexOf('.')) :\n this.name;\n }\n return this;\n }\n\n /**\n * Gets a object with the basic attributes needed to rebuild this instance excluding functions,\n * parent references, constants and also attributes retaining the default value.\n * The resulting object is commonly usued to serialize elements in JSON format.\n * @returns {object} - The resulting object, with minimal attrributes\n */\n getAttributes() {\n return getAttr(this, ['name', 'file', 'animated']);\n }\n\n /**\n * Loads the element properties from a data object\n * @param {object} data - The data object to parse\n */\n setAttributes(data) {\n ['name', 'file', 'animated'].forEach(attr => {\n if (!isEmpty(data[attr]))\n this[attr] = data[attr];\n });\n\n this.ext = this.file.toLowerCase().split('.').pop();\n this.type = this.getFileType(this.ext);\n\n // Check if it's an animated GIF\n if (this.ext === 'gif' && this.animated === 'undefined')\n this.checkAnimatedGif();\n\n if (this.type === 'font') {\n this.fontName = this.name === this.file && this.name.lastIndexOf('.') > 0 ?\n this.name.substring(0, this.name.lastIndexOf('.')) :\n this.name;\n }\n return this;\n }\n\n /**\n * Checks if the image associated with this MediaBagElement is an animated GIF\n *\n * Based on: {@link https://gist.github.com/marckubischta/261ad8427a214022890b}\n * Thanks to `@lakenen` and `@marckubischta`\n */\n checkAnimatedGif() {\n const request = new XMLHttpRequest();\n // Set `responseType` moved after calling `open`\n // see: https://stackoverflow.com/questions/20760635/why-does-setting-xmlhttprequest-responsetype-before-calling-open-throw\n // request.responseType = 'arraybuffer'\n request.addEventListener('load', () => {\n const\n arr = new Uint8Array(request.response),\n length = arr.length;\n\n // make sure it's a gif (GIF8)\n if (arr[0] !== 0x47 || arr[1] !== 0x49 ||\n arr[2] !== 0x46 || arr[3] !== 0x38) {\n this.animated = false;\n return;\n }\n\n // Ported from PHP [http://www.php.net/manual/en/function.imagecreatefromgif.php#104473]\n // an animated gif contains multiple \"frames\", with each frame having a\n // header made up of:\n // * a static 3-byte sequence (\\x00\\x21\\xF9\n // * one byte indicating the length of the header (usually \\x04)\n // * variable length header (usually 4 bytes)\n // * a static 2-byte sequence (\\x00\\x2C) (some variants may use \\x00\\x21 ?)\n // We read through the file as long as we haven't reached the end of the file\n // and we haven't yet found at least 2 frame headers\n for (let i = 0, len = length - 3, frames = 0; i < len && frames < 2; ++i) {\n if (arr[i] === 0x00 && arr[i + 1] === 0x21 && arr[i + 2] === 0xF9) {\n const\n blocklength = arr[i + 3],\n afterblock = i + 4 + blocklength;\n if (afterblock + 1 < length &&\n arr[afterblock] === 0x00 &&\n (arr[afterblock + 1] === 0x2C || arr[afterblock + 1] === 0x21)) {\n if (++frames > 1) {\n this.animated = true;\n log('debug', `Animated GIF detected: ${this.file}`);\n break;\n }\n }\n }\n }\n });\n\n this.getFullPathPromise()\n .then(fullPath => {\n request.open('GET', fullPath, true);\n request.responseType = 'arraybuffer';\n request.send();\n });\n }\n\n /**\n * Checks if the MediaBagElement has been initiated\n * @returns {boolean}\n */\n isEmpty() {\n return this.data === null;\n }\n\n /**\n * Determines the type of a file from its extension\n * @param {string} ext - The file name extension\n * @returns {string}\n */\n getFileType(ext) {\n let result = null;\n for (let type in settings.FILE_TYPES) {\n if (settings.FILE_TYPES[type].indexOf(ext) >= 0) {\n result = type;\n break;\n }\n }\n return result;\n }\n\n /**\n * Instantiates the media content\n * @param {function} callback - Callback method called when the referred resource is ready\n * @param {module:JClicPlayer.JClicPlayer} ps=null - An optional `PlayStation` (currently a {@link module:JClicPlayer.JClicPlayer JClicPlayer}) used to dynamically load fonts\n * @param {boolean} force=false - Used only in media of type 'audio'. When `true`, a static {@link MediaBagElement._audioPlayers audioPlayer element} will be loaded with this media source\n * @param {number} level=1 - Priority level of the media content to be built. Used only n audio elements.\n */\n build(callback, ps = null, force = false, level = 1) {\n // Mock data when running in NodeJS\n if (settings.NODEJS) {\n this.data = [];\n this.ready = true;\n }\n\n if (callback) {\n if (!this._whenReady)\n this._whenReady = [];\n this._whenReady.push(callback);\n }\n\n if (!this.data)\n this.getFullPathPromise()\n .then(fullPath => {\n switch (this.type) {\n case 'font':\n const\n format = this.ext === 'ttf' ? 'truetype' : this.ext === 'otf' ? 'embedded-opentype' : this.ext,\n css = `@font-face{font-family:\"${this.fontName}\";src:url(${fullPath}) format(\"${format}\");}`;\n\n appendStyleAtHead(css, ps);\n this.data = new Font(this.name);\n this.ready = true;\n break;\n\n case 'image':\n this.data = new Image();\n this.data.addEventListener('load', () => { this._onReady.call(this); }, { once: true });\n this.data.src = fullPath;\n break;\n\n case 'video':\n this.data = document.createElement(this.type);\n this.data.addEventListener('canplay', () => { this._onReady.call(this); }, { once: true });\n this.data.src = fullPath;\n this.data.load();\n this.data.pause();\n break;\n\n case 'audio':\n // HTML Audio objects will be created on demand, when the param 'force' is set to true\n if (force) {\n // Clean up state in current audio element, if any\n const currentAudioElement = MediaBagElement._currentAudioElements[level];\n if (currentAudioElement && currentAudioElement !== this) {\n currentAudioElement.data = null;\n currentAudioElement.ready = false;\n }\n // Register as a current audio element\n MediaBagElement._currentAudioElements[level] = this;\n // Configure the audio player\n const audioPlayer = MediaBagElement.getAudioPlayer(level);\n if (audioPlayer.src !== fullPath) {\n log('trace', `Loading static player #${level} with new audio: ${fullPath}`);\n this.data = audioPlayer;\n this.ready = false;\n audioPlayer.addEventListener('canplay', () => { this._onReady.call(this); }, { once: true });\n audioPlayer.src = fullPath;\n audioPlayer.load();\n audioPlayer.pause();\n }\n else\n log('trace', `Reusing existing audio in player #${level}: ${fullPath}`);\n }\n else\n this.ready = true;\n break;\n\n case 'anim':\n // TODO: Use [Ruffle](https://ruffle.rs/) to play Flash movies\n this.data = $(`<object type\"application/x-shockwave-flash\" width=\"300\" height=\"200\" data=\"${fullPath}\"/>`).get(-1);\n // Unable to check the loading progress in elements of type `object`. so we mark it always as `ready`:\n this.ready = true;\n break;\n\n case 'xml':\n $.get(fullPath, null, null, 'xml').done(xmlData => {\n const children = xmlData ? xmlData.children || xmlData.childNodes : null;\n this.data = children && children.length > 0 ? parseXmlNode(children[0]) : null;\n this._onReady();\n }).fail(err => {\n log('error', `Error loading ${this.name}: ${err}`);\n this._onReady();\n });\n break;\n\n case 'midi':\n const request = new XMLHttpRequest();\n request.onreadystatechange = () => {\n if (request.readyState === 4) {\n if (request.status === 200)\n this.data = new MidiAudioPlayer(request.response, ps && ps.options);\n else\n log('error', `Error loading ${this.name}: ${request.statusText}`);\n this._onReady();\n }\n };\n request.open('GET', fullPath, true);\n request.responseType = 'arraybuffer';\n request.send();\n break;\n\n default:\n log('trace', `Media currently not supported: ${this.name}`);\n this.ready = true;\n }\n\n if (this.ready)\n this._onReady();\n });\n else if (this.ready)\n this._onReady();\n\n return this;\n }\n\n /**\n * Checks if this media element is ready to start\n * @returns {boolean} - `true` if ready, `false` otherwise\n */\n checkReady() {\n if (this.data && !this.ready) {\n switch (this.type) {\n case 'image':\n this.ready = this.data.complete === true;\n break;\n case 'audio':\n case 'video':\n case 'anim':\n this.ready = this.data.readyState >= 1;\n break;\n default:\n this.ready = true;\n }\n }\n return this.ready;\n }\n\n /**\n * Checks if this resource has timed out.\n * @returns {boolean} - `true` if the resource has exhausted the allowed time to load, `false` otherwise\n */\n checkTimeout() {\n const result = Date.now() > this.timeout;\n if (result)\n log('warn', `Timeout while loading: ${this.name}`);\n return result;\n }\n\n /**\n * Notify listeners that the resource is ready\n */\n _onReady() {\n this.ready = true;\n if (this._whenReady) {\n this._whenReady.forEach(fn => fn.call(this, this));\n this._whenReady = null;\n }\n }\n\n /**\n * Gets the full path of the file associated to this element.\n * WARNING: This function should be called only after a successful call to `getFullPathPromise`\n * @returns {string}\n */\n getFullPath() {\n return this._fullPath;\n }\n\n /**\n * Gets a promise with the full path of the file associated to this element.\n * @returns {external:Promise}\n */\n getFullPathPromise() {\n return getPathPromise(this.basePath, this.file, this.zip)\n .then(fullPath => {\n // Process full URL only when running in a browser\n this._fullPath = settings.NODEJS\n ? fullPath\n : (new URL(fullPath, document.location.href)).toString();\n return this._fullPath;\n });\n }\n}\n\nObject.assign(MediaBagElement.prototype, {\n /**\n * The name of this element. Usually is the same as `file`\n * @name module:bags/MediaBagElement.MediaBagElement#name\n * @type {string} */\n name: '',\n /**\n * The name of the file where this element is stored\n * @name module:bags/MediaBagElement.MediaBagElement#file\n * @type {string} */\n file: '',\n /**\n * The font family name, used only in elements of type 'font'\n * @name module:bags/MediaBagElement.MediaBagElement#fontName\n * @type {string} */\n fontName: '',\n /**\n * The path to be used as base to access this media element\n * @name module:bags/MediaBagElement.MediaBagElement#basePath\n * @type {string} */\n basePath: '',\n /**\n * An optional JSZip object that can act as a container of this media\n * @name module:bags/MediaBagElement.MediaBagElement#zip\n * @type {external:JSZip} */\n zip: null,\n /**\n * When loaded, this field will store the realized media object\n * @name module:bags/MediaBagElement.MediaBagElement#data\n * @type {object} */\n data: null,\n /**\n * Flag indicating that `data` is ready to be used\n * @name module:bags/MediaBagElement.MediaBagElement#ready\n * @type {boolean} */\n ready: false,\n /**\n * Array of callback methods to be called when the resource becomes ready\n * @name module:bags/MediaBagElement.MediaBagElement#_whenReady\n * @private\n * @type {function[]} */\n _whenReady: null,\n /**\n * Normalized extension of `file`, useful to guess the media type\n * @name module:bags/MediaBagElement.MediaBagElement#ext\n * @type {string} */\n ext: '',\n /**\n * The resource type ('audio', 'image', 'midi', 'video', 'font')\n * @name module:bags/MediaBagElement.MediaBagElement#type\n * @type {string} */\n type: null,\n /**\n * Time set to load the resource before leaving\n * @name module:bags/MediaBagElement.MediaBagElement#timeout\n * @type {number} */\n timeout: 0,\n //\n /**\n * Flag used for animated GIFs\n * @name module:bags/MediaBagElement.MediaBagElement#animated\n * @type {boolean} */\n animated: false,\n /**\n * Full path obtained after a successful call to getFullPathPromise\n * @name module:bags/MediaBagElement.MediaBagElement#_fullPath\n * @private\n * @type {string}\n */\n _fullPath: null,\n});\n\nexport default MediaBagElement;\n","/**\n * File : media/MidiAudioPlayer.js\n * Created : 11/10/2018\n * By : Francesc Busquets <francesc@gmail.com>\n *\n * JClic.js\n * An HTML5 player of JClic activities\n * https://projectestac.github.io/jclic.js\n *\n * @source https://github.com/projectestac/jclic.js\n *\n * @license EUPL-1.2\n * @licstart\n * (c) 2000-2020 Educational Telematic Network of Catalonia (XTEC)\n *\n * Licensed under the EUPL, Version 1.1 or -as soon they will be approved by\n * the European Commission- subsequent versions of the EUPL (the \"Licence\");\n * You may not use this work except in compliance with the Licence.\n *\n * You may obtain a copy of the Licence at:\n * https://joinup.ec.europa.eu/software/page/eupl\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the Licence is distributed on an \"AS IS\" basis, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n * Licence for the specific language governing permissions and limitations\n * under the Licence.\n * @licend\n * @module\n */\n\n/* global window */\n\nimport MidiPlayer from '@francesc/basic-midi-player-js';\nimport { log } from '../Utils.js';\n\n// TODO: Use multiple instruments, at least one for each track\n// TODO: Use multiple midi channels (currently flattened to a single channel)\n// TODO: Use of channel 10 for percussion instruments\n// TODO: ... build a real MIDI player!!\n\n/**\n * A simple MIDI player based on MidiPlayerJS\n * https://github.com/grimmdude/MidiPlayerJS\n * See also: http://www.midijs.net (https://github.com/babelsberg/babelsberg-js/tree/master/midijs)\n */\nexport class MidiAudioPlayer {\n /**\n * MidiAudioPlayer constructor\n * @param {external:ArrayBuffer} data - The MIDI file content, in ArrayBuffer format\n * @param {object} [options={}] - Optional params related to the type of soundfont used. Valid options inside this object are:<br>\n * - `MIDISoundFontObject`: An object containing the full soundfont data. When this param is provided, no other one will be used.\n * - `MIDISoundFontBase`: The URL used as base for the current collection of MIDI soundfonts. Defaults to `https://clic.xtec.cat/dist/jclic.js/soundfonts/MusyngKite`\n * - `MIDISoundFontName`: The MIDI instrument name. Defaults to `acoustic_grand_piano`. See [MIDI.js Soundfonts](https://github.com/gleitz/midi-js-soundfonts) for full lists of MIDI instrument names.\n * - `MIDISoundFontExtension`: An extension to be added to `MIDISoundFontName` in order to build the full file name of the soundfont JS file. Defaults to `-mp3.js`\n */\n constructor(data, options = {}) {\n const AudioContext = window && (window.AudioContext || window.webkitAudioContext);\n if (AudioContext) {\n // Build instrument on first call to constructor\n MidiAudioPlayer.prepareInstrument(options, new AudioContext());\n this.data = data;\n this.player = new MidiPlayer.Player(ev => this.playEvent(ev));\n if (this.player)\n this.player.loadArrayBuffer(data);\n }\n }\n\n /**\n * Initializes the soundfont instrument, loading data from GitHub\n * NOTE: This will not work when off-line!\n * TODO: Provided a basic, simple, static soundfont\n * @param {object} options - Optional param with options related to the MIDI soundfont. See details in `constructor` description.\n * @param {external:AudioContext} audioContext - The AudioContext object (see: https://developer.mozilla.org/en-US/docs/Web/API/AudioContext)\n */\n static prepareInstrument(options = {}, audioContext) {\n if (MidiAudioPlayer.loadingInstrument === false) {\n MidiAudioPlayer.loadingInstrument = true;\n MidiAudioPlayer.audioContext = audioContext;\n MidiPlayer.Soundfont.instrument(\n MidiAudioPlayer.audioContext,\n options.MIDISoundFontObject || MidiAudioPlayer.MIDISoundFontObject ||\n `${options.MIDISoundFontBase || MidiAudioPlayer.MIDISoundFontBase}/${options.MIDISoundFontName || MidiAudioPlayer.MIDISoundFontName}${options.MIDISoundFontExtension || MidiAudioPlayer.MIDISoundFontExtension}`)\n .then(instrument => {\n log('info', 'MIDI soundfont instrument loaded');\n MidiAudioPlayer.instrument = instrument;\n })\n .catch(err => {\n log('error', `Error loading soundfont base instrument: ${err}`);\n });\n }\n }\n\n /**\n * Pauses the player\n */\n pause() {\n if (this.player) {\n this.player.pause();\n this.startedNotes = [];\n }\n }\n\n /**\n * Starts or resumes playing\n */\n play() {\n if (this.player) {\n this.startedNotes = [];\n this.player.play();\n }\n }\n\n /**\n * Gets the ' paused' state of the current player\n * @returns boolean\n */\n get paused() {\n return this.player && !this.player.isPlaying();\n }\n\n /**\n * Checks if the current player has ended or is already playing\n * @returns boolean\n */\n get ended() {\n return this.player && this.player.getSongTimeRemaining() <= 0;\n }\n\n /**\n * Gets the current time\n * @returns number\n */\n get currentTime() {\n return this.player && (this.player.getSongTime() * 1000) || 0;\n }\n\n /**\n * Sets the current time of this player (in milliseconds)\n * @param {number} time - The time position where the player pointer must be placed\n */\n set currentTime(time) {\n if (this.player)\n this.player.skipToSeconds(time / 1000);\n }\n\n /**\n * Plays a MIDI event\n * @param {object} ev - The event data. See http://grimmdude.com/MidiPlayerJS/docs/index.html for details\n */\n playEvent(ev) {\n if (this.player && MidiAudioPlayer.instrument) {\n // Check for specific interval\n if (this.playTo > 0 && this.currentTime >= this.playTo)\n this.pause();\n // Set main volume\n else if (ev.name === 'Controller Change' && ev.number === 7)\n this.mainVolume = ev.value / 127;\n // Process 'Note on' messages. Max gain set to 2.0 for better results with the used soundfont\n else if (ev.name === 'Note on' && ev.velocity > 0)\n this.startedNotes[ev.noteNumber] = MidiAudioPlayer.instrument.play(ev.noteName, MidiAudioPlayer.audioContext.currentTime, { gain: 2 * (this.mainVolume * ev.velocity / 100) });\n // Process 'Note off' messages\n else if (ev.name === 'Note off' && ev.noteNumber && this.startedNotes[ev.noteNumber]) {\n this.startedNotes[ev.noteNumber].stop();\n delete (this.startedNotes[ev.noteNumber]);\n }\n }\n }\n}\n\nObject.assign(MidiAudioPlayer.prototype, {\n /**\n * The MIDI file data used by this MIDI player\n * @name module:media/MidiAudioPlayer.MidiAudioPlayer#data\n * @type {external:ArrayBuffer} */\n data: null,\n /**\n * The grimmdude's MidiPlayer used by this player\n * @name module:media/MidiAudioPlayer.MidiAudioPlayer#player\n * @type {external:MidiPlayerJS} */\n player: null,\n /**\n * When >0, time position at which the music must end\n * @name module:media/MidiAudioPlayer.MidiAudioPlayer#playTo\n * @type {number} */\n playTo: 0,\n /**\n * Main volume of this track (set with a MIDI message of type `Controller Change` #7)\n * @name module:media/MidiAudioPlayer.MidiAudioPlayer#mainVolume\n * @type {number} */\n mainVolume: 1.0,\n /**\n * This array is used when processing 'Note off' events to stop notes that are currently playing.\n * It contains a collection of 'instrument.play' instances, one for each active note\n * @name module:media/MidiAudioPlayer.MidiAudioPlayer#startedNotes\n * @type {function[]} */\n startedNotes: [],\n});\n\n/**\n * The {@link external:AudioContext} used by this MIDI player.\n * @type {external:AudioContext}\n */\nMidiAudioPlayer.audioContext = null;\n\n/**\n * The \"Instrument\" object used by this MIDI player.\n * See: https://github.com/danigb/soundfont-player\n * @type {external:Instrument}\n */\nMidiAudioPlayer.instrument = null;\n\n/**\n * A flag used to avoid re-entrant calls to {@link module:media/MidiAudioPlayer.MidiAudioPlayer#prepareInstrument prepareInstrument}\n * @type {boolean}\n */\nMidiAudioPlayer.loadingInstrument = false;\n\n/**\n * An object containing the full soundfont data used by {@link module:media/MidiAudioPlayer.MidiAudioPlayer#instrument instrument}\n * When this member is set, no other settings related to the sounfFont will be used.\n * This value can be overwritten by the global parameter `MIDISoundFontObject`\n * @type {object}\n */\nMidiAudioPlayer.MIDISoundFontObject = null;\n\n/**\n * The URL used as base for the current collection of MIDI soundfonts.\n * This value can be overwritten by the global parameter `MIDISoundFontBase`\n * @type {string}\n */\nMidiAudioPlayer.MIDISoundFontBase = 'https://clic.xtec.cat/dist/jclic.js/soundfonts/MusyngKite';\n// Alternative sites are:\n// 'https://clic.xtec.cat/dist/jclic.js/soundfonts/FluidR3_GM'\n// 'https://raw.githubusercontent.com/gleitz/midi-js-soundfonts/gh-pages/FluidR3_GM'\n// 'https://raw.githubusercontent.com/gleitz/midi-js-soundfonts/gh-pages/MusyngKite'\n\n/**\n * The MIDI instrument name.\n * This value can be overwritten by the global parameter `MIDISoundFontName`\n * See [MIDI.js Soundfonts](https://github.com/gleitz/midi-js-soundfonts) for full lists of MIDI instrument names.\n * @type {string}\n */\nMidiAudioPlayer.MIDISoundFontName = 'acoustic_grand_piano';\n\n/**\n * An extension to be added to `MIDISoundFontName` in order to build the full file name of the soundfont JS file.\n * Current valid options are `-mp3.js` and `-ogg.js`\n * This value can be overwritten by the global parameter `MIDISoundFontExtension`\n * @type {string}\n */\nMidiAudioPlayer.MIDISoundFontExtension = '-mp3.js';\n\nexport default MidiAudioPlayer;\n"],"names":[],"sourceRoot":""}