Pause playing track and play local file and then resume.

356 views
Skip to first unread message

Hans P Nyholm

unread,
Feb 19, 2016, 6:29:27 AM2/19/16
to SoCo - Sonos Controller
I'am writing a script that I will pause the current playing track and play a localfile and then resume playing the current track and the rest of the queue or playlist.

I can play a local file, thats working. But the rest...

#!/usr/bin/env python
# -*- coding: utf-8 -*-
from soco import SoCo
import httplib, urllib

volume_now = "0"

sonos = SoCo('192.168.1.168')
volume_now = sonos.volume
sonos.volume = 45
sonos.volume = volume_now

DPH

unread,
Feb 21, 2016, 7:33:58 AM2/21/16
to SoCo - Sonos Controller
Hi Hans,
use the snapshot class in SoCo.
This saves all current state and then allows you to restore it.
Example:


# Snapshot of current state 

from soco import SoCo
from soco.snapshot import Snapshot

zp = SoCo('192.168.1.76')

snap = Snapshot(zp)     # create snapshot class
snap.snapshot()            # take a snapshot of current state

# play your local file

snap.restore()


Have fun
Cheers Daivd

Hans P Nyholm

unread,
Feb 23, 2016, 4:47:10 PM2/23/16
to SoCo - Sonos Controller
Thank you, that works great.

I also have problem whit the Swedish letters å,ä,ö in the speaker names.
It can discover the speaker and print the name but i cant use a name whit å,ä,ö in it.

Kenneth Nielsen

unread,
May 5, 2016, 6:28:14 AM5/5/16
to SoCo - Sonos Controller
Hallo Hans

I realize this thread is a bit old, but thought I should answer anyway. Whan you say that you can't use speaker names with special Swedish letters in them, then what exactly do you mean? That you cannot set a new player_namer that contains these? (I'm a Dane myself, so I know of the special letters). When you test this, make sure you pass in the new name as a unicode string (Should happen automatically on Python 3, on python 2 use

new_name = u'Køkken'

If this fails, then you should report it as a bug on: https://github.com/SoCo/SoCo/issues

Thanks in advance
Regards Kenneth
Reply all
Reply to author
Forward
0 new messages