libvlc - keep window opened between videos

ぃ、小莉子 提交于 2021-01-07 02:31:28

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!