mirror of
https://github.com/algerkong/AlgerMusicPlayer.git
synced 2026-04-24 08:07:23 +08:00
🔧 fix: 优化音频服务和EQ设置的跨平台兼容性
This commit is contained in:
@@ -38,6 +38,7 @@ module.exports = {
|
|||||||
rules: {
|
rules: {
|
||||||
'vue/require-default-prop': 'off',
|
'vue/require-default-prop': 'off',
|
||||||
'vue/multi-word-component-names': 'off',
|
'vue/multi-word-component-names': 'off',
|
||||||
|
'no-underscore-dangle': 'off',
|
||||||
'no-nested-ternary': 'off',
|
'no-nested-ternary': 'off',
|
||||||
'no-console': 'off',
|
'no-console': 'off',
|
||||||
'no-await-in-loop': 'off',
|
'no-await-in-loop': 'off',
|
||||||
|
|||||||
@@ -120,6 +120,7 @@
|
|||||||
{{ playMusic.id ? t('player.playBar.lyric') : t('player.playBar.noSongPlaying') }}
|
{{ playMusic.id ? t('player.playBar.lyric') : t('player.playBar.noSongPlaying') }}
|
||||||
</n-tooltip>
|
</n-tooltip>
|
||||||
<n-popover
|
<n-popover
|
||||||
|
v-if="isElectron"
|
||||||
trigger="click"
|
trigger="click"
|
||||||
:z-index="99999999"
|
:z-index="99999999"
|
||||||
content-class="music-eq"
|
content-class="music-eq"
|
||||||
|
|||||||
@@ -1,18 +1,7 @@
|
|||||||
import { Howl, Howler } from 'howler';
|
import { Howl, Howler } from 'howler';
|
||||||
|
|
||||||
import type { SongResult } from '@/type/music';
|
import type { SongResult } from '@/type/music';
|
||||||
|
import { isElectron } from '@/utils'; // 导入isElectron常量
|
||||||
// 使用下划线前缀表示允许未使用的变量
|
|
||||||
interface _Window {
|
|
||||||
webkitAudioContext: typeof AudioContext;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 使用下划线前缀表示允许未使用的变量
|
|
||||||
interface _HowlSound {
|
|
||||||
node: HTMLMediaElement & {
|
|
||||||
audioSource?: MediaElementAudioSourceNode;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
class AudioService {
|
class AudioService {
|
||||||
private currentSound: Howl | null = null;
|
private currentSound: Howl | null = null;
|
||||||
@@ -248,6 +237,11 @@ class AudioService {
|
|||||||
|
|
||||||
private async setupEQ(sound: Howl) {
|
private async setupEQ(sound: Howl) {
|
||||||
try {
|
try {
|
||||||
|
if (!isElectron) {
|
||||||
|
console.log('Web环境中跳过EQ设置,避免CORS问题');
|
||||||
|
this.bypass = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
const howl = sound as any;
|
const howl = sound as any;
|
||||||
// eslint-disable-next-line no-underscore-dangle
|
// eslint-disable-next-line no-underscore-dangle
|
||||||
const audioNode = howl._sounds?.[0]?._node;
|
const audioNode = howl._sounds?.[0]?._node;
|
||||||
|
|||||||
@@ -25,8 +25,6 @@ export class EQService {
|
|||||||
|
|
||||||
private gainNode: GainNode | null = null;
|
private gainNode: GainNode | null = null;
|
||||||
|
|
||||||
private howlInstance: Howl | null = null;
|
|
||||||
|
|
||||||
private bypass = false;
|
private bypass = false;
|
||||||
|
|
||||||
// 预设频率
|
// 预设频率
|
||||||
@@ -80,7 +78,6 @@ export class EQService {
|
|||||||
|
|
||||||
// 创建新的处理链
|
// 创建新的处理链
|
||||||
this.tuna = new Tuna(this.context);
|
this.tuna = new Tuna(this.context);
|
||||||
this.howlInstance = howl;
|
|
||||||
|
|
||||||
// 创建/复用源节点
|
// 创建/复用源节点
|
||||||
if (!sound._node.destination) {
|
if (!sound._node.destination) {
|
||||||
@@ -180,7 +177,6 @@ export class EQService {
|
|||||||
this.source = null;
|
this.source = null;
|
||||||
this.equalizer = null;
|
this.equalizer = null;
|
||||||
this.gainNode = null;
|
this.gainNode = null;
|
||||||
this.howlInstance = null;
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('资源清理失败:', error);
|
console.error('资源清理失败:', error);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user