kthen
This commit is contained in:
parent
a7b14fe39d
commit
9b23688c10
24
__main__.py
24
__main__.py
@ -1,7 +1,7 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
DEBUG=False
|
DEBUG=False
|
||||||
try:
|
try:
|
||||||
from winrt.windows.media.control import GlobalSystemMediaTransportControlsSessionManager as MediaManager
|
from winrt.windows.media.control import GlobalSystemMediaTransportControlsSessionManager as MediaManager
|
||||||
except:
|
except:
|
||||||
print("DEBUG; winrt disabled")
|
print("DEBUG; winrt disabled")
|
||||||
DEBUG = True
|
DEBUG = True
|
||||||
@ -23,7 +23,7 @@ def sendSerial(byte):
|
|||||||
except SerialException:
|
except SerialException:
|
||||||
print('port already open')
|
print('port already open')
|
||||||
|
|
||||||
class PhoneLineEventHandler():
|
class PhoneLineEventHandler():
|
||||||
phone_mgr = None
|
phone_mgr = None
|
||||||
lines = []
|
lines = []
|
||||||
line_selected = None
|
line_selected = None
|
||||||
@ -53,8 +53,8 @@ class PhoneLineEventHandler():
|
|||||||
for linenum in range(self.phone_mgr.DispNumberOfLines):
|
for linenum in range(self.phone_mgr.DispNumberOfLines):
|
||||||
line = self.phone_mgr.DispGetLine(linenum)
|
line = self.phone_mgr.DispGetLine(linenum)
|
||||||
if line.DispState != LineState.Inactive:
|
if line.DispState != LineState.Inactive:
|
||||||
return True
|
return True
|
||||||
asyncio.run(try_play())
|
asyncio.run(try_play())
|
||||||
sendSerial(b'o')
|
sendSerial(b'o')
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@ -89,18 +89,18 @@ class PhoneLineEventHandler():
|
|||||||
async def try_play():
|
async def try_play():
|
||||||
print("try_play")
|
print("try_play")
|
||||||
if not DEBUG:
|
if not DEBUG:
|
||||||
sessions = await MediaManager.request_async()
|
sessions = await MediaManager.request_async()
|
||||||
current_session = sessions.get_current_session()
|
current_session = sessions.get_current_session()
|
||||||
if current_session:
|
if current_session:
|
||||||
await current_session.try_play_async()
|
await current_session.try_play_async()
|
||||||
|
|
||||||
async def try_pause():
|
async def try_pause():
|
||||||
print("try_pause")
|
print("try_pause")
|
||||||
if not DEBUG:
|
if not DEBUG:
|
||||||
sessions = await MediaManager.request_async()
|
sessions = await MediaManager.request_async()
|
||||||
current_session = sessions.get_current_session()
|
current_session = sessions.get_current_session()
|
||||||
if current_session:
|
if current_session:
|
||||||
await current_session.try_pause_async()
|
await current_session.try_pause_async()
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
win32com.client.WithEvents("CLMgr.ClientLineMgr", PhoneLineEventHandler)
|
win32com.client.WithEvents("CLMgr.ClientLineMgr", PhoneLineEventHandler)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user