Search code examples
pythonwindowsfullscreenvlc

Windows 10. Python. VLC in fullscreen mode does not play in foreground


I have a python daemon process which periodically starts VLC player in fullscreen mode, plays some video and stops it:

import vlc
...
player = vlc.MediaPlayer()
player.set_fullscreen(True)
...
player.play()
...
player.stop()
...

But if I open or focus any other window after I start my script, VLC player pops up in fullscreen mode but don't go over this new top-level window. There is no such problem for Linux Mint. VLC in fullscreen overwrite anything, no matter what.

Is there any solution or workaround for such problem?


Solution

  • I solved this problem by using --video-on-top flag with vlc.Instance:

    class Player():
        def __init__(self):
            self._instance = vlc.Instance(['--video-on-top'])
            self._player = self._instance.media_player_new()
            self._player.set_fullscreen(True)
    
        def play(self, path):
            media = self._instance.media_new(path)
            self._player.set_media(media)
            self._player.play()
    
        def stop(self):
            self._player.stop()