Skip to content

Special event processing for LastChange events#194

Merged
lawrenceakka merged 7 commits intoSoCo:masterfrom
lawrenceakka:last-change-events
Sep 14, 2014
Merged

Special event processing for LastChange events#194
lawrenceakka merged 7 commits intoSoCo:masterfrom
lawrenceakka:last-change-events

Conversation

@lawrenceakka
Copy link
Copy Markdown
Contributor

Incorporating @robwebset 's ideas into the event processing code - see #189

To see it in operation:

try:
    from queue import Empty
except:  # Py2.7
    from Queue import Empty

import soco
import time
from pprint import pprint
from soco.events import event_listener
# import logging
# logging.basicConfig(level=logging.DEBUG)
# pick a device
device = soco.discover().pop()
sub = device.renderingControl.subscribe()
sub2 = device.avTransport.subscribe()

while True:
    try:
        event = sub.events.get(timeout=0.5)
        pprint (event.variables)
    except Empty:
        pass
    try:
        event = sub2.events.get(timeout=0.5)
        pprint (event.variables)
    except Empty:
        pass

    except KeyboardInterrupt:
        sub.unsubscribe()
        sub2.unsubscribe()
        event_listener.stop()
        break

Then fiddle with your volume/add tracks/play etc

The next step would be to integrate this with #192 so that track metadata is returned as an ML_Library_Item instance, once #192 is committed.

--HG--
extra : rebase_source : d79713bd55186a54bfc844a840da3ae49c083ca4
@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.48%) when pulling 336d63f on lawrenceakka:last-change-events into 35ab843 on SoCo:master.

@stefankoegl
Copy link
Copy Markdown
Member

+1

@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.47%) when pulling 2b83cdc on lawrenceakka:last-change-events into d0c7f57 on SoCo:master.

@lawrenceakka lawrenceakka added this to the 0.9 milestone Jul 25, 2014
@KennethNielsen
Copy link
Copy Markdown
Member

Hi @lawrenceakka

Looks like a good idea. A few points.

  1. Regarding using a data structure for the track metadata I think that is a good idea, but you should probably use the QueueItem class. What characterises the metadata that we get from the active queue (at least when asking the get_queue method), is that it is not enough information to distinguish between ML and MS items and in the case of MS items, not enough information to re-add them to the queue. That is the reason why the QueueItem class exists and it is probably what should be used here.
  2. As mentioned in Add a stucture to hold the Last Change Event message #189 I sometimes prefer specialized class for data structures e.g because the allow data type conversion and possibly dublication as described there, but there could of course also be other ways to do that. If it is possible, one could create a global list of variables which can and should be converted or duplicated. If that is not possible due to type clashes, we could do one for each service or something like that. It would be a bit of extra work, but I think worth it.

I will make a few inline comments as well.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned in conversation, probably QueueItem

@KennethNielsen
Copy link
Copy Markdown
Member

In general +1 for the code as is, but with a few inline comments to consider.

@stefankoegl stefankoegl mentioned this pull request Sep 8, 2014
@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.45%) when pulling c98b64e on lawrenceakka:last-change-events into 4501f70 on SoCo:master.

@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.5%) when pulling 16a6b2e on lawrenceakka:last-change-events into 4501f70 on SoCo:master.

@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.5%) when pulling 21f160b on lawrenceakka:last-change-events into 4501f70 on SoCo:master.

The evented variables are now accessible as attributes on the event object
@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.25%) when pulling 67ab9eb on lawrenceakka:last-change-events into 4501f70 on SoCo:master.

@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.28%) when pulling 3bc172f on lawrenceakka:last-change-events into 4501f70 on SoCo:master.

@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.28%) when pulling 5237667 on lawrenceakka:last-change-events into 4501f70 on SoCo:master.

lawrenceakka added a commit that referenced this pull request Sep 14, 2014
Special event processing for LastChange events. Thanks to all for comments
@lawrenceakka lawrenceakka merged commit 6f318df into SoCo:master Sep 14, 2014
@lawrenceakka lawrenceakka deleted the last-change-events branch November 9, 2014 16:42
@poirier poirier mentioned this pull request Jan 17, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants