问题
I am using python wrapper around libvlc for playing videos. The problem is that after I stop previous video playback and start to play new one, window is reopened. I am trying to achieve state where window is still opened and I can change videos in this window without flash of the desktop behind it.
import time
import vlc
i = vlc.Instance()
media_player = i.media_player_new()
media_player.set_fullscreen(True)
m1 = i.media_new('vid1.mp4')
m2 = i.media_new('vid2.mp4')
media_player.set_media(m1)
media_player.play()
time.sleep(5)
media_player.stop()
media_player.set_media(m2)
media_player.play()
time.sleep(5)
media_player.stop()
I also tried using set_xwindow()
function but without success.
Thanks for advance.
回答1:
libvlc will create (and I guess close) windows if you don't specify one.
You should tell libvlc which window to use. How you do it depends on which platform you use.
- On Linux, use
libvlc_media_player_set_xwindow
with the window handle. - On Windows
libvlc_media_player_set_hwnd
. - On macOS, that's
libvlc_media_player_set_nsobject
.
This will allow you to use any given window for successive playbacks.
来源:https://stackoverflow.com/questions/65056433/libvlc-keep-window-opened-between-videos