flutter_sound.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /*
  2. * Copyright 2018, 2019, 2020 Dooboolab.
  3. *
  4. * This file is part of Flutter-Sound.
  5. *
  6. * Flutter-Sound is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU Lesser General Public License version 3 (LGPL-V3), as published by
  8. * the Free Software Foundation.
  9. *
  10. * Flutter-Sound is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Lesser General Public License
  16. * along with Flutter-Sound. If not, see <https://www.gnu.org/licenses/>.
  17. */
  18. const VERSION = '8.2.0'
  19. const VERBOSE = 0;
  20. const DBG = 1;
  21. const INFO = 2;
  22. const WARNING = 3;
  23. const ERROR = 4;
  24. const WTF = 5;
  25. const NOTHING = 6;
  26. const codec =
  27. {
  28. defaultCodec: 'defaultCodec',
  29. aacADTS: 'aacADTS',
  30. opusOGG: 'opusOGG',
  31. opusCAF: 'opusCAF',
  32. mp3: 'mp3',
  33. vorbisOGG: 'vorbisOGG',
  34. pcm16: 'pcm16',
  35. pcm16WAV: 'pcm16WAV',
  36. pcm16AIFF: 'pcm16AIFF',
  37. pcm16CAF: 'pcm16CAF',
  38. flac: 'flac',
  39. aacMP4: 'aacMP4',
  40. amrNB: 'amrNB',
  41. amrWB: 'amrWB',
  42. pcm8: 'pcm8',
  43. pcmFloat32: 'pcmFloat32',
  44. pcmWebM: 'pcmWebM',
  45. opusWebM: 'opusWebM',
  46. vorbisWebM: 'vorbisWebM',
  47. };
  48. const tabCodec =
  49. [
  50. codec.opusWebM, // codec.defaultCodec,
  51. codec.aacADTS,
  52. codec.opusOGG,
  53. codec.opusCAF,
  54. codec.mp3,
  55. codec.vorbisOGG,
  56. codec.pcm16,
  57. codec.pcm16WAV,
  58. codec.pcm16AIFF,
  59. codec.pcm16CAF,
  60. codec.flac,
  61. codec.aacMP4,
  62. codec.amrNB,
  63. codec.amrWB,
  64. codec.pcm8,
  65. codec.pcmFloat32,
  66. codec.pcmWebM,
  67. codec.opusWebM,
  68. codec.vorbisWebM,
  69. ];
  70. const mime_types =
  71. [
  72. 'audio/webm\;codecs=opus', // defaultCodec,
  73. 'audio/aac', // aacADTS,
  74. 'audio/opus\;codecs=opus', // opusOGG,
  75. 'audio/x-caf', // opusCAF,
  76. 'audio/mp3', // mp3,
  77. 'audio/ogg\;codecs=vorbis', // vorbisOGG,
  78. 'audio/pcm', // pcm16,
  79. 'audio/wav\;codecs=1', // pcm16WAV,
  80. 'audio/aiff', // pcm16AIFF,
  81. 'audio/x-caf', // pcm16CAF,
  82. 'audio/x-flac', // flac,
  83. 'audio/mp4', // aacMP4,
  84. 'audio/AMR', // amrNB,
  85. 'audio/AMR-WB', // amrWB,
  86. 'audio/pcm', // pcm8,
  87. 'audio/pcm', // pcmFloat32,
  88. 'audio/webm\;codecs=pcm', // pcmWebM,
  89. 'audio/webm\;codecs=opus', // opusWebM,
  90. 'audio/webm\;codecs=vorbis', // vorbisWebM
  91. ];
  92. const tabFormat =
  93. [
  94. 'opus', // defaultCodec,
  95. 'aac', // aacADTS,
  96. 'opus', // opusOGG,
  97. 'caf', // opusCAF,
  98. 'mp3', // mp3,
  99. 'vorbis', // vorbisOGG,
  100. '', // pcm16,
  101. 'wav', // pcm16WAV,
  102. 'aiff', // pcm16AIFF,
  103. 'caf', // pcm16CAF,
  104. 'flac', // flac,
  105. 'mp4', // aacMP4,
  106. 'AMR', // amrNB,
  107. 'AMR-WB', // amrWB,
  108. '', // pcm8,
  109. '', // pcmFloat32,
  110. 'pcm', // pcmWebM,
  111. 'opus', // opusWebM,
  112. 'webm', // vorbisWebM
  113. ];
  114. var instanceNumber = 0;
  115. var lastUrl = '';
  116. function getRecordURL( aPath,)
  117. {
  118. var path ;
  119. var myStorage;
  120. if ((aPath == null) || (aPath == ''))
  121. {
  122. path = lastUrl;
  123. } else
  124. {
  125. path = aPath;
  126. }
  127. if (path.substring(0,1) == '/')
  128. {
  129. myStorage = window.localStorage;
  130. } else
  131. {
  132. myStorage = window.sessionStorage;
  133. }
  134. var url = myStorage.getItem(path);
  135. return url;
  136. }