@@ -74,11 +74,15 @@ SPDX-License-Identifier: AGPL-3.0-only
74
74
<i v-else class="ti ti-volume"></i>
75
75
</button>
76
76
<MkMediaRange
77
- v-model="rangePercent"
78
- :class="$style.seekbarRoot"
79
- :buffer="bufferedDataRatio"
77
+ v-model="volume"
78
+ :class="$style.volumeSeekbar"
80
79
/>
81
80
</div>
81
+ <MkMediaRange
82
+ v-model="rangePercent"
83
+ :class="$style.seekbarRoot"
84
+ :buffer="bufferedDataRatio"
85
+ />
82
86
</div>
83
87
</div>
84
88
</template>
@@ -93,13 +97,11 @@ import * as os from '@/os.js';
93
97
import { type Keymap } from '@/scripts/hotkey.js';
94
98
import bytes from '@/filters/bytes.js';
95
99
import { hms } from '@/filters/hms.js';
96
- import MkAudioVisualizer from '@/components/MkAudioVisualizer.vue';
97
100
import MkMediaRange from '@/components/MkMediaRange.vue';
98
101
import { $i, iAmModerator } from '@/account.js';
99
102
100
103
const props = defineProps<{
101
104
audio: Misskey.entities.DriveFile;
102
- user?: Misskey.entities.UserLite;
103
105
}>();
104
106
105
107
const keymap = {
@@ -150,7 +152,6 @@ function hasFocus() {
150
152
151
153
const playerEl = shallowRef<HTMLDivElement>();
152
154
const audioEl = shallowRef<HTMLAudioElement>();
153
- const audioVisualizer = ref<InstanceType<typeof MkAudioVisualizer>>();
154
155
155
156
// eslint-disable-next-line vue/no-setup-props-reactivity-loss
156
157
const hide = ref((defaultStore.state.nsfw === 'force' || defaultStore.state.dataSaver.media) ? true : (props.audio.isSensitive && defaultStore.state.nsfw !== 'ignore'));
@@ -249,11 +250,6 @@ const isPlaying = ref(false);
249
250
const isActuallyPlaying = ref(false);
250
251
const elapsedTimeMs = ref(0);
251
252
const durationMs = ref(0);
252
- const audioContext = ref<AudioContext | null>(null);
253
- const sourceNode = ref<MediaElementAudioSourceNode | null>(null);
254
- const gainNode = ref<GainNode | null>(null);
255
- const analyserGainNode = ref<GainNode | null>(null);
256
- const analyserNode = ref<AnalyserNode | null>(null);
257
253
const rangePercent = computed({
258
254
get: () => {
259
255
return (elapsedTimeMs.value / durationMs.value) || 0;
@@ -276,33 +272,11 @@ const bufferedDataRatio = computed(() => {
276
272
function togglePlayPause() {
277
273
if (!isReady.value || !audioEl.value) return;
278
274
279
- if (!sourceNode.value) {
280
- audioContext.value = new (window.AudioContext || window.webkitAudioContext)();
281
- sourceNode.value = audioContext.value.createMediaElementSource(audioEl.value);
282
-
283
- analyserGainNode.value = audioContext.value.createGain();
284
- gainNode.value = audioContext.value.createGain();
285
- analyserNode.value = audioContext.value.createAnalyser();
286
-
287
- sourceNode.value.connect(analyserGainNode.value);
288
- analyserGainNode.value.connect(analyserNode.value);
289
- analyserNode.value.connect(gainNode.value);
290
- gainNode.value.connect(audioContext.value.destination);
291
-
292
- analyserNode.value.fftSize = 2048;
293
-
294
- analyserGainNode.value.gain.setValueAtTime(0.8, audioContext.value.currentTime);
295
-
296
- gainNode.value.gain.setValueAtTime(volume.value, audioContext.value.currentTime);
297
- }
298
-
299
275
if (isPlaying.value) {
300
276
audioEl.value.pause();
301
- audioVisualizer.value?.pauseAnimation();
302
277
isPlaying.value = false;
303
278
} else {
304
279
audioEl.value.play();
305
- audioVisualizer.value?.resumeAnimation();
306
280
isPlaying.value = true;
307
281
oncePlayed.value = true;
308
282
}
@@ -360,7 +334,6 @@ function init() {
360
334
oncePlayed.value = false;
361
335
isActuallyPlaying.value = false;
362
336
isPlaying.value = false;
363
- audioVisualizer.value?.pauseAnimation();
364
337
});
365
338
366
339
durationMs.value = audioEl.value.duration * 1000;
@@ -369,15 +342,16 @@ function init() {
369
342
durationMs.value = audioEl.value.duration * 1000;
370
343
}
371
344
});
372
- gainNode.value?.gain.setValueAtTime(volume.value, audioContext.value?.currentTime);
345
+
346
+ audioEl.value.volume = volume.value;
373
347
}
374
348
}, {
375
349
immediate: true,
376
350
});
377
351
}
378
352
379
353
watch(volume, (to) => {
380
- if (audioEl.value) gainNode .value?.gain.setValueAtTime(to, audioContext.value?.currentTime) ;
354
+ if (audioEl.value) audioEl .value.volume = to ;
381
355
});
382
356
383
357
watch(speed, (to) => {
0 commit comments