@vnejs/plugins.audio 0.1.2 → 0.1.3
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/modules/media.js +1 -0
- package/modules/pause.js +3 -3
- package/modules/resume.js +3 -3
- package/package.json +1 -1
package/modules/media.js
CHANGED
|
@@ -10,6 +10,7 @@ export class AudioMedia extends Module {
|
|
|
10
10
|
|
|
11
11
|
init = () => {
|
|
12
12
|
this.quality = this.PARAMS.AUDIO.QUALITY;
|
|
13
|
+
this.shared.audioNoSmoothSources = [];
|
|
13
14
|
};
|
|
14
15
|
|
|
15
16
|
onAudioMediaLoad = ({ name, layer: mediaType, priority = this.CONST.MEDIA.PRIORITIES.BACKGROUND } = {}) => {
|
package/modules/pause.js
CHANGED
|
@@ -7,11 +7,11 @@ export class AudioPause extends Module {
|
|
|
7
7
|
this.on(this.EVENTS.AUDIO.PAUSE, this.onAudioPause);
|
|
8
8
|
};
|
|
9
9
|
|
|
10
|
-
onAudioPause = async ({ layer, name, duration } = {}) => {
|
|
10
|
+
onAudioPause = async ({ layer, name, duration = 0 } = {}) => {
|
|
11
11
|
const media = await this.emitOne(this.EVENTS.AUDIO.MEDIA_GET, { layer, name });
|
|
12
12
|
const audio = await this.emitOne(this.EVENTS.AUDIO.TMP_GET, { src: media.src });
|
|
13
13
|
|
|
14
|
-
if (!duration) return audio.pause();
|
|
14
|
+
if (!duration || this.shared.audioNoSmoothSources.length) return audio.pause();
|
|
15
15
|
|
|
16
16
|
return new Promise(async (resolve) => {
|
|
17
17
|
const initialVolume = await this.emitOne(this.EVENTS.AUDIO.VOLUME_GET, { layer, name });
|
|
@@ -20,7 +20,7 @@ export class AudioPause extends Module {
|
|
|
20
20
|
const onTick = () => {
|
|
21
21
|
const ts = new Date().getTime();
|
|
22
22
|
|
|
23
|
-
if (ts - initialTs >= duration || audio.currentTime + 0.1 >= audio.duration) {
|
|
23
|
+
if (ts - initialTs >= duration || audio.currentTime + 0.1 >= audio.duration || this.shared.audioNoSmoothSources.length) {
|
|
24
24
|
audio.pause();
|
|
25
25
|
|
|
26
26
|
this.emit(this.EVENTS.AUDIO.VOLUME, { layer, name, volume: initialVolume });
|
package/modules/resume.js
CHANGED
|
@@ -7,11 +7,11 @@ export class AudioResume extends Module {
|
|
|
7
7
|
this.on(this.EVENTS.AUDIO.RESUME, this.onAudioResume);
|
|
8
8
|
};
|
|
9
9
|
|
|
10
|
-
onAudioResume = async ({ layer, name, duration } = {}) => {
|
|
10
|
+
onAudioResume = async ({ layer, name, duration = 0 } = {}) => {
|
|
11
11
|
const media = await this.emitOne(this.EVENTS.AUDIO.MEDIA_GET, { layer, name });
|
|
12
12
|
const audio = await this.emitOne(this.EVENTS.AUDIO.TMP_GET, { src: media.src });
|
|
13
13
|
|
|
14
|
-
if (!duration) return audio.play();
|
|
14
|
+
if (!duration || this.shared.audioNoSmoothSources.length) return audio.play();
|
|
15
15
|
|
|
16
16
|
return new Promise(async (resolve) => {
|
|
17
17
|
const initialVolume = await this.emitOne(this.EVENTS.AUDIO.VOLUME_GET, { layer, name });
|
|
@@ -23,7 +23,7 @@ export class AudioResume extends Module {
|
|
|
23
23
|
const onTick = () => {
|
|
24
24
|
const ts = new Date().getTime();
|
|
25
25
|
|
|
26
|
-
if (ts - initialTs >= duration || audio.currentTime + 0.1 >= audio.duration)
|
|
26
|
+
if (ts - initialTs >= duration || audio.currentTime + 0.1 >= audio.duration || this.shared.audioNoSmoothSources.length)
|
|
27
27
|
return this.emit(this.EVENTS.AUDIO.VOLUME, { layer, name, volume: initialVolume }).then(resolve);
|
|
28
28
|
|
|
29
29
|
const delta = (ts - initialTs) / duration;
|