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