From 08b5e3bc8535f3a5d386381adaa727c6dbe055a9 Mon Sep 17 00:00:00 2001 From: Sora <8521327+SoraKasvgano@users.noreply.github.com> Date: Tue, 20 Jan 2026 10:02:50 +0800 Subject: [PATCH] Fix APlayer instance scope in initialization Refactored APlayer initialization to use a properly scoped variable for the instance, ensuring it is accessible outside the try block. This improves logging and debugging of the APlayer instance after creation. --- resources/aplayer-share.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/resources/aplayer-share.js b/resources/aplayer-share.js index e3c2ee60b..6df55fb71 100644 --- a/resources/aplayer-share.js +++ b/resources/aplayer-share.js @@ -76,9 +76,10 @@ console.log('Container styles:', window.getComputedStyle(container)); console.log('Creating APlayer with playlist:', playlist); - + + let ap; try { - const ap = new APlayer({ + ap = new APlayer({ container: container, lrcType: 0, audio: playlist, @@ -98,19 +99,19 @@ // Log initialization console.log('APlayer initialized with', playlist.length, 'tracks'); console.log('APlayer instance:', ap); - + // Check if APlayer created DOM elements setTimeout(() => { const aplayerElements = container.querySelectorAll('*'); console.log('APlayer created', aplayerElements.length, 'child elements'); - + if (aplayerElements.length === 0) { console.error('APlayer did not create any child elements - initialization failed'); } else { console.log('APlayer child elements:', aplayerElements); } }, 100); - + } catch (error) { console.error('APlayer initialization failed:', error); return;