SoCo / SoCo

SoCo (Sonos Controller) is a Python project that allows you to programmatically control Sonos speakers.
http://python-soco.com/
MIT License
1.5k stars 232 forks source link

play_uri File Not Found Error (in the SONOS app), but no error reported from soco? #365

Open bhelabhav opened 9 years ago

bhelabhav commented 9 years ago

It looks like the response from the Sonos is successful (200), but the song from the uri does not play. The uri is the one in the example in the README.

Here is my code:

import soco

def _get_coordinators():
    players = soco.discover(timeout=3) or []
    coordinators = [player for player in players if player.is_coordinator]
    return coordinators

if __name__ == '__main__':
    coordinators = _get_coordinators()
    uri = 'http://archive.org/download/TenD2005-07-16.flac16/TenD2005-07-16t10Wonderboy_64kb.mp3'
    for coordinator in coordinators:
        # this line does not throw any errors, but the sonos controller app will say
        # something along the lines of file not found and the song will not play...
        coordinator.play_uri(uri) 
RJ commented 7 years ago

Same issue here - if i have the sonos desktop app open when i attempt this, an error message appears briefly:

"unable to play TenD2005-07-16t10Wonderboy_64kb.mp3 the file cannot be found"

the url is valid and plays fine in my browser.

did you find a solution?

KennethNielsen commented 7 years ago

There was an issue where the song in the example was only available via a redirect, which the Sonos speaker does not support. It should be updated in the examples now.

Can one of you confirm whether this is still an issue.

bbrendon commented 7 years ago

I'm having a problem I'm trying to debug and scouring around for solutions...

How long does the "File Not Found Error" show in the win32 app?

My issue is that a scheduled play (say a clock) works intermittently. The wav file shows as queued in the win32 app and if I click play in the win32 app it plays.

I'm not sure how to troubleshoot but thought it might be related to this issue?

DPH commented 7 years ago

Hi @bbrendon, is you .wav file local or being pulled off the internet? If local then it is not a re-direct issue, if from the internet then it could be and could explain the intermittent behaviour.

If it plays from the controller (win32 app) then it implies it is something in your code when you make it play. Can you post the code snippet to allow us to help. Cheers David

bbrendon commented 7 years ago

I'm calling it from Home Assistant so I'm not sure if this is the right place to discuss this. The audio files are local. Same premise as below. Both are intermittent.

Script part

      - service: script.sonos_say_no_restore
        data_template:
          sonos_entity: media_player.kitchen
          volume: 0.60
          delay: '00:00:05'
          message: Good night

Script template

  sonos_say_no_restore:
    sequence:
      - service: media_player.volume_set
        data_template:
          entity_id: "{{ sonos_entity }}"
          volume_level: "{{ volume }}"
      - service: tts.google_say
        data_template:
          entity_id: "{{ sonos_entity }}"
          message: '{{ message }}'
      - delay: "{{ delay }}"
ghcs27 commented 6 years ago

The problem here is that the Sonos speaker does not try to play the URI before it sends the response. Therefore, the URI will be successfully set as the music source and you will get a 200 SUCCESSFUL response. However, you might want to subscribe to the player.avTransport service: If an error occurs, the event variables will include 'transport_status': 'ERROR_NO_RESOURCE'.