def main(): time_now = 0 media_title = "" old_album = "" thumbnail = "" helper.printout("[info] ", _ConfigDefault['mesg.cyan']) print("Start: KodiDisplayInfo") pygame.init() screen = pygame.display.set_mode( getattr(draw_default, 'Screen' + _ConfigDefault['display.resolution'])(), 0, 32) pygame.display.set_caption('KodiDisplayInfo') pygame.mouse.set_visible(1) clock = pygame.time.Clock() RELOAD_SPEED = 750 # create a bunch of events reloaded_event = pygame.USEREVENT + 1 # set timer for the event pygame.time.set_timer(reloaded_event, RELOAD_SPEED) draw_default.setPygameScreen(pygame, screen) #if _ConfigDefault['config.screenmodus_video'] == "time": # draw_videotime.setPygameScreen(pygame, screen, draw_default) if _ConfigDefault['config.screenmodus_music'] == "thumbnail": draw_musicthumbnail.setPygameScreen(pygame, screen, draw_default) running = True # run the game loop try: while running: clock.tick(4) # 4 x in one seconds for event in pygame.event.get(): if event.type == pygame.QUIT: running = False time_now = datetime.datetime.now() # start draw screen.fill(_ConfigDefault['color.black']) #reset playerid, playertype = KODI_WEBSERVER.KODI_GetActivePlayers() #if playertype=="video" and int(playerid) >= 0: #media_title = KODI_WEBSERVER.KODI_GetItem(playerid, playertype) #speed, media_time, media_totaltime = KODI_WEBSERVER.KODI_GetProperties(playerid) #if _ConfigDefault['config.screenmodus_video']=="time": #draw_videotime.drawProperties(media_title, time_now, speed, media_time, media_totaltime) if playertype == "audio" and int(playerid) >= 0: # Artist, Album und Titel herausfinden media_artist, media_album, media_title = KODI_WEBSERVER.KODI_GetItem( playerid, playertype) speed, media_time, media_totaltime = KODI_WEBSERVER.KODI_GetProperties( playerid) if _ConfigDefault['config.screenmodus_music'] == "time": draw_videotime.drawProperties(media_title, time_now, speed, media_time, media_totaltime) # Anzeigemodus "Thumbnail" ist gewählt if _ConfigDefault['config.screenmodus_music'] == "thumbnail": # Neues Cover nur anfordern wenn sich das Album geändert hat if not media_album == old_album and media_album != "#error": # Die URL für das Cover herausfinden url = KODI_WEBSERVER.KODI_GetCoverURL(playerid) # Das Cover nur herunterladen wenn es es auch gibt if not url == "": thumbnail = KODI_WEBSERVER.KODI_DownloadCover(url) helper.printout("[info] ", _ConfigDefault['mesg.green']) print("Cover gefunden für: " + str(media_album)) else: helper.printout("[info] ", _ConfigDefault['mesg.yellow']) print("Kein Cover gefunden für: " + str(media_album)) thumbnail = "#empty" if media_album != "#error": old_album = media_album else: if media_album == "": thumbnail = "#empty" # Das Cover auf's Display bringen draw_musicthumbnail.DrawMusicInfo(thumbnail, media_artist, media_album, media_title) else: # API has nothing media_title = "" draw_default.drawLogoStartScreen(time_now) pygame.display.flip() helper.printout("[end] ", _ConfigDefault['mesg.magenta']) print("bye ...") main_exit() except SystemExit: main_exit() except KeyboardInterrupt: main_exit()
def main(): time_now = 0 video_title = "" helper.printout("[info] ", _ConfigDefault['mesg.cyan']) print "Start: KodiDisplayInfo Video" pygame.init() screen = pygame.display.set_mode( getattr(draw_default, 'Screen' + _ConfigDefault['display.resolution'])(), 0, 32) pygame.display.set_caption('KodiDisplayInfo Video') pygame.mouse.set_visible(0) draw_default.setPygameScreen(pygame, screen) draw_videotime.setPygameScreen(pygame, screen, draw_default) running = True # run the game loop try: while running: for event in pygame.event.get(): if event.type == pygame.QUIT: running = False elif event.type == KEYDOWN and event.key == K_ESCAPE: running = False time_now = datetime.datetime.now() #start draw screen.fill(_ConfigDefault['color.black']) #reset playerid, playertype = KODI_WEBSERVER.KODI_GetActivePlayers() if playertype == "video" and int(playerid) > 0: if video_title == "": video_title = KODI_WEBSERVER.KODI_GetItem(playerid) helper.printout("[info] ", _ConfigDefault['mesg.green']) print "Video: " + video_title speed, minutes_time, minutes_timetotal = KODI_WEBSERVER.KODI_GetProperties( playerid) if minutes_timetotal > 0: if _ConfigDefault['config.screenmodus'] == "time": draw_videotime.drawProperties(video_title, time_now, speed, minutes_time, minutes_timetotal) else: # API has nothing video_title = "" draw_default.drawLogoStartScreen(time_now) pygame.display.flip() time.sleep(1) pygame.display.update() helper.printout("[end] ", _ConfigDefault['mesg.magenta']) print "bye ..." main_exit() except SystemExit: main_exit() except KeyboardInterrupt: main_exit()
# Das Cover auf's Display bringen draw_musicthumbnail.DrawMusicInfo(thumbnail, media_artist, media_album, media_title) else: # API has nothing media_title = "" draw_default.drawLogoStartScreen(time_now) pygame.display.flip() helper.printout("[end] ", _ConfigDefault['mesg.magenta']) print("bye ...") main_exit() except SystemExit: main_exit() except KeyboardInterrupt: main_exit() if __name__ == "__main__": draw_default = DrawToDisplay_Default(helper, _ConfigDefault) #if _ConfigDefault['config.screenmodus_video']=="time": # draw_videotime = DrawToDisplay_VideoTime(helper, _ConfigDefault) if _ConfigDefault['config.screenmodus_music'] == "thumbnail": draw_musicthumbnail = DrawToDisplay_MusicThumbnail( helper, _ConfigDefault) KODI_WEBSERVER = KODI_WEBSERVER(helper, _ConfigDefault, draw_default) main()
def main(): time_now = 0 media_title = "" helper.printout("[info] ", _ConfigDefault['mesg.cyan']) print "Start: KodiDisplayInfo" pygame.init() screen = pygame.display.set_mode(getattr(draw_default, 'Screen'+_ConfigDefault['display.resolution'])(), 0, 32) pygame.display.set_caption('KodiDisplayInfo') pygame.mouse.set_visible(0) clock = pygame.time.Clock() RELOAD_SPEED = 750 # create a bunch of events reloaded_event = pygame.USEREVENT + 1 # set timer for the event pygame.time.set_timer(reloaded_event, RELOAD_SPEED) draw_default.setPygameScreen(pygame, screen) draw_videotime.setPygameScreen(pygame, screen, draw_default) running = True # run the game loop try: while running: clock.tick(4) # 4 x in one seconds for event in pygame.event.get(): if event.type == pygame.QUIT: running = False #elif event.type == pygame.MOUSEBUTTONDOWN: # print "mouse at (%d, %d)" % event.pos #elif event.type == KEYDOWN and event.key == K_ESCAPE: # running = False time_now = datetime.datetime.now() #start draw screen.fill(_ConfigDefault['color.black']) #reset playerid, playertype = KODI_WEBSERVER.KODI_GetActivePlayers() if playertype=="video" and int(playerid) >= 0: media_title = KODI_WEBSERVER.KODI_GetItem(playerid, playertype) speed, media_time, media_totaltime = KODI_WEBSERVER.KODI_GetProperties(playerid) if _ConfigDefault['config.screenmodus']=="time": draw_videotime.drawProperties(media_title, time_now, speed, media_time, media_totaltime) elif playertype == "audio" and int(playerid) >= 0: # Clone from Video media_title = KODI_WEBSERVER.KODI_GetItem(playerid, playertype) speed, media_time, media_totaltime = KODI_WEBSERVER.KODI_GetProperties(playerid) if _ConfigDefault['config.screenmodus']=="time": draw_videotime.drawProperties(media_title, time_now, speed, media_time, media_totaltime) else: # API has nothing media_title = "" draw_default.drawLogoStartScreen(time_now) pygame.display.flip() helper.printout("[end] ", _ConfigDefault['mesg.magenta']) print "bye ..." main_exit() except SystemExit: main_exit() except KeyboardInterrupt: main_exit()