@94ai/nf-audio 3.3.62 → 3.3.64
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/nf-audio.cjs.js +44 -22
- package/lib/nf-audio.esm-bundler.js +44 -22
- package/package/nf-audio.vue +42 -20
- package/package.json +3 -3
package/lib/nf-audio.cjs.js
CHANGED
|
@@ -97,6 +97,10 @@ const _sfc_main = {
|
|
|
97
97
|
betweenEnd: {
|
|
98
98
|
type: Number,
|
|
99
99
|
default: 0
|
|
100
|
+
},
|
|
101
|
+
highPrecision: {
|
|
102
|
+
type: Boolean,
|
|
103
|
+
default: false
|
|
100
104
|
}
|
|
101
105
|
},
|
|
102
106
|
data() {
|
|
@@ -274,33 +278,41 @@ const _sfc_main = {
|
|
|
274
278
|
} catch (e) {
|
|
275
279
|
}
|
|
276
280
|
},
|
|
281
|
+
isHighPrecision() {
|
|
282
|
+
if (this.highPrecision) {
|
|
283
|
+
return true;
|
|
284
|
+
}
|
|
285
|
+
return window.location.protocol === "https:" || window.location.hostname === "localhost";
|
|
286
|
+
},
|
|
277
287
|
async startAudioCtx() {
|
|
278
|
-
if (
|
|
279
|
-
this.audioCtx
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
if (
|
|
287
|
-
if (this.
|
|
288
|
-
if (this.
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
this.
|
|
288
|
+
if (this.isHighPrecision()) {
|
|
289
|
+
if (!this.audioCtx) {
|
|
290
|
+
this.audioCtx = new (window.AudioContext || window.webkitAudioContext)();
|
|
291
|
+
this.audioSource = this.audioCtx.createMediaElementSource(this.audio);
|
|
292
|
+
await this.audioCtx.audioWorklet.addModule("data:application/javascript," + encodeURIComponent(this.audioWorkletProcessor));
|
|
293
|
+
this.processor = new AudioWorkletNode(this.audioCtx, "tick");
|
|
294
|
+
this.audioSource.connect(this.processor).connect(this.audioCtx.destination);
|
|
295
|
+
this.processor.port.onmessage = (event) => {
|
|
296
|
+
if (event.data.command === "tick") {
|
|
297
|
+
if (this.betweenPlaying) {
|
|
298
|
+
if (this.betweenEnd) {
|
|
299
|
+
if (this.debuglog) {
|
|
300
|
+
console.log(this.audio.currentTime);
|
|
301
|
+
}
|
|
302
|
+
if (this.audio.currentTime >= this.betweenEnd) {
|
|
303
|
+
this.pause();
|
|
304
|
+
}
|
|
293
305
|
}
|
|
294
306
|
}
|
|
295
307
|
}
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
|
|
308
|
+
};
|
|
309
|
+
} else {
|
|
310
|
+
this.audioCtx.resume();
|
|
311
|
+
}
|
|
312
|
+
this.processor.port.postMessage({
|
|
313
|
+
command: "start"
|
|
314
|
+
});
|
|
300
315
|
}
|
|
301
|
-
this.processor.port.postMessage({
|
|
302
|
-
command: "start"
|
|
303
|
-
});
|
|
304
316
|
},
|
|
305
317
|
pause() {
|
|
306
318
|
this.pauseAudio();
|
|
@@ -336,6 +348,16 @@ const _sfc_main = {
|
|
|
336
348
|
this.$refs.progressCurrent.style.width = MoveX + "px";
|
|
337
349
|
this.$refs.progressBar.style.left = MoveX - this.$refs.progressBar.clientWidth / 2 + "px";
|
|
338
350
|
this.paused = false;
|
|
351
|
+
if (!this.isHighPrecision() && this.betweenPlaying) {
|
|
352
|
+
if (this.betweenEnd) {
|
|
353
|
+
if (this.debuglog) {
|
|
354
|
+
console.log(this.audio.currentTime);
|
|
355
|
+
}
|
|
356
|
+
if (this.audio.currentTime >= this.betweenEnd) {
|
|
357
|
+
this.pause();
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
}
|
|
339
361
|
}
|
|
340
362
|
},
|
|
341
363
|
betweenPlay() {
|
|
@@ -95,6 +95,10 @@ const _sfc_main = {
|
|
|
95
95
|
betweenEnd: {
|
|
96
96
|
type: Number,
|
|
97
97
|
default: 0
|
|
98
|
+
},
|
|
99
|
+
highPrecision: {
|
|
100
|
+
type: Boolean,
|
|
101
|
+
default: false
|
|
98
102
|
}
|
|
99
103
|
},
|
|
100
104
|
data() {
|
|
@@ -272,33 +276,41 @@ const _sfc_main = {
|
|
|
272
276
|
} catch (e) {
|
|
273
277
|
}
|
|
274
278
|
},
|
|
279
|
+
isHighPrecision() {
|
|
280
|
+
if (this.highPrecision) {
|
|
281
|
+
return true;
|
|
282
|
+
}
|
|
283
|
+
return window.location.protocol === "https:" || window.location.hostname === "localhost";
|
|
284
|
+
},
|
|
275
285
|
async startAudioCtx() {
|
|
276
|
-
if (
|
|
277
|
-
this.audioCtx
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
if (
|
|
285
|
-
if (this.
|
|
286
|
-
if (this.
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
this.
|
|
286
|
+
if (this.isHighPrecision()) {
|
|
287
|
+
if (!this.audioCtx) {
|
|
288
|
+
this.audioCtx = new (window.AudioContext || window.webkitAudioContext)();
|
|
289
|
+
this.audioSource = this.audioCtx.createMediaElementSource(this.audio);
|
|
290
|
+
await this.audioCtx.audioWorklet.addModule("data:application/javascript," + encodeURIComponent(this.audioWorkletProcessor));
|
|
291
|
+
this.processor = new AudioWorkletNode(this.audioCtx, "tick");
|
|
292
|
+
this.audioSource.connect(this.processor).connect(this.audioCtx.destination);
|
|
293
|
+
this.processor.port.onmessage = (event) => {
|
|
294
|
+
if (event.data.command === "tick") {
|
|
295
|
+
if (this.betweenPlaying) {
|
|
296
|
+
if (this.betweenEnd) {
|
|
297
|
+
if (this.debuglog) {
|
|
298
|
+
console.log(this.audio.currentTime);
|
|
299
|
+
}
|
|
300
|
+
if (this.audio.currentTime >= this.betweenEnd) {
|
|
301
|
+
this.pause();
|
|
302
|
+
}
|
|
291
303
|
}
|
|
292
304
|
}
|
|
293
305
|
}
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
|
|
306
|
+
};
|
|
307
|
+
} else {
|
|
308
|
+
this.audioCtx.resume();
|
|
309
|
+
}
|
|
310
|
+
this.processor.port.postMessage({
|
|
311
|
+
command: "start"
|
|
312
|
+
});
|
|
298
313
|
}
|
|
299
|
-
this.processor.port.postMessage({
|
|
300
|
-
command: "start"
|
|
301
|
-
});
|
|
302
314
|
},
|
|
303
315
|
pause() {
|
|
304
316
|
this.pauseAudio();
|
|
@@ -334,6 +346,16 @@ const _sfc_main = {
|
|
|
334
346
|
this.$refs.progressCurrent.style.width = MoveX + "px";
|
|
335
347
|
this.$refs.progressBar.style.left = MoveX - this.$refs.progressBar.clientWidth / 2 + "px";
|
|
336
348
|
this.paused = false;
|
|
349
|
+
if (!this.isHighPrecision() && this.betweenPlaying) {
|
|
350
|
+
if (this.betweenEnd) {
|
|
351
|
+
if (this.debuglog) {
|
|
352
|
+
console.log(this.audio.currentTime);
|
|
353
|
+
}
|
|
354
|
+
if (this.audio.currentTime >= this.betweenEnd) {
|
|
355
|
+
this.pause();
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
}
|
|
337
359
|
}
|
|
338
360
|
},
|
|
339
361
|
betweenPlay() {
|
package/package/nf-audio.vue
CHANGED
|
@@ -253,6 +253,10 @@ export default {
|
|
|
253
253
|
betweenEnd: {
|
|
254
254
|
type: Number,
|
|
255
255
|
default: 0
|
|
256
|
+
},
|
|
257
|
+
highPrecision: {
|
|
258
|
+
type: Boolean,
|
|
259
|
+
default: false
|
|
256
260
|
}
|
|
257
261
|
},
|
|
258
262
|
data() {
|
|
@@ -437,31 +441,39 @@ export default {
|
|
|
437
441
|
//
|
|
438
442
|
}
|
|
439
443
|
},
|
|
444
|
+
isHighPrecision() {
|
|
445
|
+
if (this.highPrecision) {
|
|
446
|
+
return true
|
|
447
|
+
}
|
|
448
|
+
return window.location.protocol === 'https:' || window.location.hostname === 'localhost'
|
|
449
|
+
},
|
|
440
450
|
async startAudioCtx() {
|
|
441
|
-
if (
|
|
442
|
-
this.audioCtx
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
if (
|
|
450
|
-
if (this.
|
|
451
|
-
if (this.
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
this.
|
|
451
|
+
if (this.isHighPrecision()) {
|
|
452
|
+
if (!this.audioCtx) {
|
|
453
|
+
this.audioCtx = new (window.AudioContext || window.webkitAudioContext)();
|
|
454
|
+
this.audioSource = this.audioCtx.createMediaElementSource(this.audio);
|
|
455
|
+
await this.audioCtx.audioWorklet.addModule('data:application/javascript,' + encodeURIComponent(this.audioWorkletProcessor));
|
|
456
|
+
this.processor = new AudioWorkletNode(this.audioCtx, 'tick');
|
|
457
|
+
this.audioSource.connect(this.processor).connect(this.audioCtx.destination);
|
|
458
|
+
this.processor.port.onmessage = (event) => {
|
|
459
|
+
if (event.data.command === 'tick') {
|
|
460
|
+
if (this.betweenPlaying) {
|
|
461
|
+
if (this.betweenEnd) {
|
|
462
|
+
if (this.debuglog) {
|
|
463
|
+
console.log(this.audio.currentTime)
|
|
464
|
+
}
|
|
465
|
+
if (this.audio.currentTime >= this.betweenEnd) {
|
|
466
|
+
this.pause()
|
|
467
|
+
}
|
|
456
468
|
}
|
|
457
469
|
}
|
|
458
470
|
}
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
|
|
471
|
+
};
|
|
472
|
+
} else {
|
|
473
|
+
this.audioCtx.resume()
|
|
474
|
+
}
|
|
475
|
+
this.processor.port.postMessage({ command: 'start' });
|
|
463
476
|
}
|
|
464
|
-
this.processor.port.postMessage({ command: 'start' });
|
|
465
477
|
},
|
|
466
478
|
pause() {
|
|
467
479
|
this.pauseAudio()
|
|
@@ -499,6 +511,16 @@ export default {
|
|
|
499
511
|
this.$refs.progressCurrent.style.width = MoveX + 'px'
|
|
500
512
|
this.$refs.progressBar.style.left = MoveX - (this.$refs.progressBar.clientWidth / 2) + 'px'
|
|
501
513
|
this.paused = false
|
|
514
|
+
if (!this.isHighPrecision() && this.betweenPlaying) {
|
|
515
|
+
if (this.betweenEnd) {
|
|
516
|
+
if (this.debuglog) {
|
|
517
|
+
console.log(this.audio.currentTime)
|
|
518
|
+
}
|
|
519
|
+
if (this.audio.currentTime >= this.betweenEnd) {
|
|
520
|
+
this.pause()
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
}
|
|
502
524
|
}
|
|
503
525
|
},
|
|
504
526
|
betweenPlay() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@94ai/nf-audio",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.64",
|
|
4
4
|
"description": "> TODO: description",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"author": "liuxiangxiang <liuxiangxiang@94ai.com>",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"url": "http://94ai.gitlab.com/zoujiahe/common-ui.git"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@94ai/nf-theme-chalk": "^3.3.
|
|
17
|
+
"@94ai/nf-theme-chalk": "^3.3.64",
|
|
18
18
|
"vue-demi": "^0.14.5"
|
|
19
19
|
},
|
|
20
20
|
"peerDependenciesMeta": {
|
|
@@ -30,5 +30,5 @@
|
|
|
30
30
|
"types": "lib/index.d.ts",
|
|
31
31
|
"main": "lib/nf-audio.cjs.js",
|
|
32
32
|
"module": "lib/nf-audio.esm-bundler.js",
|
|
33
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "e4fb754b3e4a7deb29d4200826491496fd813aa9"
|
|
34
34
|
}
|