| 1450 | const players = this.mediaPlayers (type, true) as Record<string, HTMLAudioElement | HTMLVideoElement | AudioPlayer> | undefined; |
| 1451 | |
| 1452 | const cleanupPlayer = (player: HTMLAudioElement | HTMLVideoElement | AudioPlayer): void => { |
| 1453 | if (player instanceof AudioPlayer) { |
| 1454 | // Use AudioPlayer's destroy method which handles cleanup properly |
| 1455 | player.destroy(); |
| 1456 | } else { |
| 1457 | // Handle HTMLAudioElement/HTMLVideoElement |
| 1458 | if (typeof player.pause === 'function') { |
| 1459 | player.pause(); |
| 1460 | } |
| 1461 | if (typeof player.setAttribute === 'function') { |
| 1462 | player.setAttribute('src', ''); |
| 1463 | player.currentTime = 0; |
| 1464 | } |
| 1465 | } |
| 1466 | }; |
| 1467 | |
| 1468 | if (typeof key === 'undefined') { |
| 1469 | if (players) { |