tonhowtf/omniget · error

[player] Spotify SDK failed, trying YouTube fallback:

Error message

[player] Spotify SDK failed, trying YouTube fallback:

What it means

Logged when the Spotify Web Playback SDK fails to start/play a track; the store captures the error and falls back to the YouTube player. If the free fallback is disabled or no audio element exists, the captured error is classified and rethrown as a player error.

Solutions

  1. Ensure Spotify Premium and re-authenticate with the streaming scopes
  2. Enable DRM (Widevine/EME) in the browser and use a supported browser
  3. Keep spotifyFreeFallback enabled (and an audio element present) so the YouTube fallback can take over
  4. Check the Spotify device is active: open another Spotify session or re-select the device to register it

Example fix

// before
throw sdkErr ?? new Error("spotify sdk failed");
// after
if (this.spotifyFreeFallback && this.audio) {
  await this.playViaYoutubeFallback(track);
} else {
  throw classifyPlayerError(sdkErr ?? "spotify sdk failed", "spotify", track.id);
}
Defensive patterns

Strategy: fallback

Validate before calling

const canSpotify = Boolean(spotifyToken) && ('MediaSession' in navigator) && navigator.mediaDevices !== undefined;

Type guard

function hasSpotifySdk(w: Window): w is Window & { Spotify: { Player: new (o: unknown) => unknown } } { return "Spotify" in w && typeof (w as any).Spotify?.Player === "function"; }

Try / catch

try { await startSpotifySdk(track); return; } catch (e) { console.warn("[player] Spotify SDK failed, trying YouTube fallback:", e); if (spotifyFreeFallback && audio) { await playViaYoutube(track); } else { throw classifyPlayerError(e, "spotify", track.id); } }

Prevention

When it happens

Trigger: Calling the Spotify play path when the SDK cannot initialize: Premium authentication failure, device not registered as the active playback device, unsupported browser (no EME/DRM), or a track unavailable on Spotify.

Common situations: User without Spotify Premium; Spotify OAuth token expired or scopes missing (streaming/user-read-email); Chrome/Firefox DRM disabled; corporate network blocking Spotify CDN endpoints.

Related errors


AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12). Data as JSON: /api/errors/768e9b5e7604fa86. Report an issue: GitHub.

Appendix: source

Thrown at src/lib/study-music/player-store.svelte.ts:1758

      console.info(
        "[player] spotify timing",
        {
          stop_ms: Math.round(tStop - t0),
          ready_ms: Math.round(tReady - tStop),
          play_ms: Math.round(tPlay - tReady),
          total_ms: Math.round(tPlay - t0),
        },
      );
      this.saveQueueNow();
      this.updateMediaSessionMetadata(track);
      if (track.spotify_cover_url) {
        void this.refreshDominantColorFromUrl(track.spotify_cover_url);
      }
      if (this._spotifyHeartbeatEnabled) this.startSpotifyHeartbeat();
      return;
    } catch (e) {
      sdkErr = e;
      console.warn("[player] Spotify SDK failed, trying YouTube fallback:", e);
    }

    if (!this.spotifyFreeFallback || !this.audio) {
      this.setError(classifyPlayerError(sdkErr ?? "spotify sdk failed", "spotify", track.id));
      throw sdkErr ?? new Error("spotify sdk failed");
    }

    try {
      const url = await this.spotifyFreeFallback(track);
      track.youtube_url = url;
      this.audio.src = url;
      await this.audio.play();
      this.ensureEqGraph();
      this.saveQueueNow();
      this.updateMediaSessionMetadata(track);
    } catch (e) {
      this.setError(classifyPlayerError(e, "spotify", track.id));
      throw e;

View on GitHub (pinned to 8600b91f42)