Skip to content

Commit

Permalink
upnp resume on same minute after reconnect
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-ld committed Mar 27, 2021
1 parent cd92c49 commit e168450
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions smart_tv_telegram/devices/upnp_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ def __init__(self, service: async_upnp_client.UpnpService):
self._service = service

async def handle(self):
await _upnp_safe_stop(self._service)
play = self._service.action("Play")
await play.async_call(InstanceID=0, Speed="1")

Expand Down Expand Up @@ -115,10 +114,12 @@ def _player_status(data: bytes) -> UpnpPlayerStatus:
class DeviceStatus:
reconnect: UpnpReconnectFunction
playing: bool
errored: bool

def __init__(self, reconnect: UpnpReconnectFunction, playing: bool = False):
def __init__(self, reconnect: UpnpReconnectFunction, playing: bool = False, errored: bool = False):
self.reconnect = reconnect
self.playing = playing
self.errored = errored


class UpnpNotifyServer(RequestHandler):
Expand Down Expand Up @@ -159,6 +160,10 @@ async def handle(self, request: Request) -> Response:
device.playing = True

if status == UpnpPlayerStatus.ERROR and device.playing:
device.errored = True

if device.errored and status == UpnpPlayerStatus.NOTHING:
device.errored = False
device.playing = False
await device.reconnect.handle()

Expand Down

0 comments on commit e168450

Please sign in to comment.