quadule / knobby

A little Spotify remote to remind you that there's a lot of music out there.
MIT License
173 stars 14 forks source link

Knobby reboot when using external speaker on Mac Spotify App #10

Open pnevin10 opened 1 year ago

pnevin10 commented 1 year ago

Hi, I've noticed that Knobby will reboot when the Spotify app (Mac v1.2.21.1104.g42cf0a50) tries to use an external speaker. I can start Spotify App and Knobby can control audio. As soon as I tell the Spotify app to use an external speaker the Knobby will reboot. This problem does not occur when you use the web-based Spotify application (Chrome tested).

I can reproduce this issue on two Knobby devices with the latest firmware installed.

Working just fine with Mac Spotify App using internal laptop speaker

[ 47020][I][main.cpp:2238] spotifyApiRequest(): GET /v1/me/player?market=from_token [ 57354][I][main.cpp:2238] spotifyApiRequest(): GET /v1/me/player?market=from_token [ 67803][I][main.cpp:2238] spotifyApiRequest(): GET /v1/me/player?market=from_token ####### Selected external speaker here! Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled.

Core 1 register dump: PC : 0x40001650 PS : 0x00060e30 A0 : 0x800dd555 A1 : 0x3ffe2aa0
A2 : 0x50000454 A3 : 0x00000000 A4 : 0x0000003f A5 : 0x0000ff00
A6 : 0x00ff0000 A7 : 0xff000000 A8 : 0x00000000 A9 : 0x3ffe2a50
A10 : 0x50000454 A11 : 0x000000ff A12 : 0x00000001 A13 : 0x00000000
A14 : 0x00ff0000 A15 : 0x40404040 SAR : 0x00000020 EXCCAUSE: 0x0000001c
EXCVADDR: 0x00000000 LBEG : 0x4000164d LEND : 0x40001667 LCOUNT : 0xffffffff

Backtrace: 0x4000164d:0x3ffe2aa0 0x400dd552:0x3ffe2ab0 0x400dfa80:0x3ffe2c60

ELF file SHA256: 373458490d8a5009

Rebooting... ets Jul 29 2019 12:21:46

rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT) configsip: 0, SPIWP:0xee clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00 mode:DIO, clock div:2 load:0x3fff0030,len:3992 load:0x40078000,len:15024 load:0x40080400,len:3648 entry 0x40080600 [ 1257][I][ArduinoOTA.cpp:141] begin(): OTA server at: knobby.local:3232

_                 _     _              |

| | | | | | | | | _ __ _ | | | |_ | mac C8:C9:A3:FC:08:28 | |/ ) \ / | | | | | | | built Jul 20 2023 22:51:53 | (| | | | || | |) ) |) ) || | | git version a281064 || _)| ||_/|/|/ __ | | esp-idf 4.4.4 by milo winningham (_/ | arduino 2.0.10 https://knobby.net | ____|____

E (2726) wifi:Association refused temporarily, comeback time 25 mSec setup this device via usb or wifi:

E (2808) wifi:Association refused temporarily, comeback time 25 mSec E (2837) wifi:Association refused temporarily, comeback time 25 mSec

pnevin10 commented 1 year ago

The Chrome Spotify app does the same thing.

JJSphar commented 1 year ago

What kind of external speaker are you trying to use?

Specifically, I saw this happen on my Knobby when trying to move playback onto a Sonos speaker. It looks like they are locked down behind the API: Sonos speakers not showing in GET /player/devices

quadule commented 1 year ago

Hi @pnevin10, I've been looking into this but can't seem to reproduce the problem yet. I also suspect the issue may be related to the external speaker. Could you share the response you get from the /v1/me/player Spotify API when playing something on that speaker?

icurnvs commented 11 months ago

@quadule Hi there - here's the result of my API call. In my devices list within the knobby menu, I have my two Amazon Echo devices, my PC (spotify app), and 'Everywhere'. My Sonos speakers do not show up and when I use the Spotify PC app to move playback to a Sonos speaker, the Knobby sort of glitches out and seems to go into a quick boot loop. If I use the Spotify PC app to return playback to either of the Echos or my PC Spotify app, the knobby exits its boot loop.

In this case, 'Beam' is a Sonos soundbar.

{
  "device": {
    "id": null,
    "is_active": true,
    "is_private_session": false,
    "is_restricted": true,
    "name": "Beam",
    "type": "Speaker",
    "volume_percent": 9,
    "supports_volume": true
  },
  "repeat_state": "off",
  "shuffle_state": false,
  "context": {
    "type": "collection",
    "href": "https://api.spotify.com/v1/me/tracks",
    "external_urls": {
      "spotify": "https://open.spotify.com/collection/tracks"
    },
    "uri": "spotify:user:tylerrydell:collection"
  },
  "timestamp": 1701139334404,
  "progress_ms": 245579,
  "is_playing": true,
  "item": {
    "album": {
      "album_type": "album",
      "total_tracks": 13,
      "external_urls": {
        "spotify": "https://open.spotify.com/album/52AeC4gwbxDfFlLHgK1ByD"
      },
      "href": "https://api.spotify.com/v1/albums/52AeC4gwbxDfFlLHgK1ByD",
      "id": "52AeC4gwbxDfFlLHgK1ByD",
      "images": [
        {
          "url": "https://i.scdn.co/image/ab67616d0000b273707d13d3f87652e737e94d45",
          "height": 640,
          "width": 640
        },
        {
          "url": "https://i.scdn.co/image/ab67616d00001e02707d13d3f87652e737e94d45",
          "height": 300,
          "width": 300
        },
        {
          "url": "https://i.scdn.co/image/ab67616d00004851707d13d3f87652e737e94d45",
          "height": 64,
          "width": 64
        }
      ],
      "name": "Urban Hymns (Remastered 2016)",
      "release_date": "1997-09-29",
      "release_date_precision": "day",
      "type": "album",
      "uri": "spotify:album:52AeC4gwbxDfFlLHgK1ByD",
      "artists": [
        {
          "external_urls": {
            "spotify": "https://open.spotify.com/artist/2cGwlqi3k18jFpUyTrsR84"
          },
          "href": "https://api.spotify.com/v1/artists/2cGwlqi3k18jFpUyTrsR84",
          "id": "2cGwlqi3k18jFpUyTrsR84",
          "name": "The Verve",
          "type": "artist",
          "uri": "spotify:artist:2cGwlqi3k18jFpUyTrsR84"
        }
      ],
      "is_playable": true
    },
    "artists": [
      {
        "external_urls": {
          "spotify": "https://open.spotify.com/artist/2cGwlqi3k18jFpUyTrsR84"
        },
        "href": "https://api.spotify.com/v1/artists/2cGwlqi3k18jFpUyTrsR84",
        "id": "2cGwlqi3k18jFpUyTrsR84",
        "name": "The Verve",
        "type": "artist",
        "uri": "spotify:artist:2cGwlqi3k18jFpUyTrsR84"
      }
    ],
    "disc_number": 1,
    "duration_ms": 357266,
    "explicit": false,
    "external_ids": {
      "isrc": "GBUM71601816"
    },
    "external_urls": {
      "spotify": "https://open.spotify.com/track/57iDDD9N9tTWe75x6qhStw"
    },
    "href": "https://api.spotify.com/v1/tracks/57iDDD9N9tTWe75x6qhStw",
    "id": "57iDDD9N9tTWe75x6qhStw",
    "is_playable": true,
    "name": "Bitter Sweet Symphony - Remastered 2016",
    "popularity": 82,
    "preview_url": "https://p.scdn.co/mp3-preview/8b56a0a99ec6675ac20c4c9d69565897e510c491?cid=aea2247cc55a49b1bc6d97895c4b6de9",
    "track_number": 1,
    "type": "track",
    "uri": "spotify:track:57iDDD9N9tTWe75x6qhStw",
    "is_local": false
  },
  "currently_playing_type": "track",
  "actions": {
    "disallows": {
      "resuming": true,
      "skipping_prev": true
    }
  }
}
icurnvs commented 11 months ago

As @JJSphar pointed out, it looks like Sonos speakers aren't returned in the device list. Is there a way for knobby to handle when playback is occurring on a device not in the devices list? If it's not feasible to initiate playback on a restricted device, is it perhaps possible for us to start playback on knobby, move playback to a restricted device, and then be able to control that session(skip, play/pause, etc.)?