andrewmcgivery / obsidian-soundscapes

A plugin for Obsidian.MD that adds a music/ambiance player to the status bar to play Lofi beats, nature sounds, ambiance, relaxing music, and more.
MIT License
46 stars 7 forks source link

Bug: Toolbar does not appear if offline or YouTube is blocked #26

Closed chrisgurney closed 3 months ago

chrisgurney commented 4 months ago

Problem

On launch of Obsidian, my Soundscapes toolbar controls are no longer loading this afternoon, while they were working fine this morning.

CleanShot 2024-02-28 at 14 09 40

My hunch right now is that I am using an app on MacOS called SelfControl that completely blacklists a bunch of websites. One I have set is YouTube (www.youtube.com). At the moment I can't disable my block (that's by design) to see if that's the issue. I'll re-confirm this evening and update my post then. Could not having access to YouTube (say using Obsidian completely offline) prevent Soundscapes from starting up correctly? (Confirmed, see next comment.)

CleanShot 2024-02-28 at 14 01 58@2x

CleanShot 2024-02-28 at 14 42 58@2x

Other things I've tried...

chrisgurney commented 4 months ago

@andrewmcgivery I've confirmed that the Soundscapes toolbar does not appear in Obsidian, AND the music player does not allow playback if:

Going offline and blocking sites are both strategies I use when I want to focus and minimize distractions, which seem analogous with the goals of this plugin. I'd like to use the My Music feature to play music/sounds locally, and don't (currently) use the YouTube playback.

Is it possible to update the plugin to support offline use?

Thanks!

chrisgurney commented 4 months ago

I don't know for sure but it looks like the player is created here... but it's within the callback from YouTube's API, so it never gets triggered when YouTube's not available.

I'm not sure where the fix is to be made; perhaps in main.ts: createPlayer()?

I think then if the Soundscape is set to My Music the player can just go ahead and be initiated:

if (this.soundscapeType === SOUNDSCAPE_TYPE.MY_MUSIC) {
   this.onPlayerReady.bind(this)

I can successfully swap from a YouTube soundscape to My Music while I'm offline, so I think the fix only needs to be made in the player startup code. Though, maybe the YouTube player will need another kick, if it's not initiated in the first place?

andrewmcgivery commented 3 months ago

Apologies, I was out on a work trip. :)

I've added this to my TODO list to take a look at. :)

andrewmcgivery commented 3 months ago

This should now be fixed in 1.3.0 (just released). :)

chrisgurney commented 3 months ago

@andrewmcgivery Much appreciated, thank you! Works great! (Tested with both SelfControl and while offline.)