1

I am using pygame and vlc to play some video files. Here is small piece of my code:

    ...
    pygame.init()
    self._screen = pygame.display.set_mode((1280,720),pygame.RESIZABLE)
    self._size = (pygame.display.Info().current_w, pygame.display.Info().current_h)

    # Create instane of VLC.
    self._vlcInstance = vlc.Instance()
    
    # Create new instance of vlc player
    self._player = self._vlcInstance.media_player_new()
    self._player.video_set_mouse_input(False)
    
    # Pass pygame window id to vlc player, so it can render its contents there.
    win_id = pygame.display.get_wm_info()['window']
    if sys.platform == "linux": # for Linux using the X Server
        self._player.set_xwindow(win_id)
    elif sys.platform == "win32": # for Windows
        self._player.set_hwnd(win_id)
    elif sys.platform == "darwin": # for MacOS
        self._player.set_agl(win_id)
    ...

Everything is working fine. However I would like to use supervisor to make sure that my app is running 24/7. Unfortunately I am getting an error that there is no key 'window' in the win_id variable (win_id= {}):

   # Pass pygame window id to vlc player, so it can render its contents there.
   win_id = pygame.display.get_wm_info()['window']

Here is my conf file for supervisor:

[program:Digital_Signage_Player]
command=python3 -u -m Digital_Signage_Player.Digital_Signage_Player
autostart=true
autorestart=unexpected
startsecs=5
stderr_logfile=/var/log/Digital_Signage_Player.err.log
stdout_logfile=/var/log/Digital_Signage_Player.out.log
KD82
  • 91
  • 1
  • 1
  • 5
  • I would log what the dictionary `pygame.display.get_wm_info()` is returning. Obviously it does not have `window`. Are you sure the window is actually open before this function is called? Maybe you could trigger this on the first event or suchlike? – Kingsley Jul 05 '20 at 23:17

0 Answers0