Advertisement
Domarius

LibVLC aspect parameter error

Apr 28th, 2019
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.57 KB | None | 0 0
  1. import sys
  2. import ctypes
  3.  
  4. from sdl2 import *
  5.  
  6. #VLC stuff
  7. import vlc
  8.  
  9.  
  10. def main():
  11.     SDL_Init(SDL_INIT_VIDEO)
  12.     window = SDL_CreateWindow(b"Hello World",
  13.                               0, 0,
  14.                               592, 460, SDL_WINDOW_SHOWN | SDL_WINDOW_FULLSCREEN_DESKTOP)
  15.     windowsurface = SDL_GetWindowSurface(window)
  16.    
  17.     #Xwindow ID stuff
  18.     wminfo = SDL_SysWMinfo();
  19.     SDL_GetVersion(wminfo.version);
  20.     if(SDL_GetWindowWMInfo(window, wminfo) == 0):
  21.         print("can't get SDL WM info");
  22.         sys.exit(1);
  23.     win_id = wminfo.info.x11.window;
  24.  
  25.     #VLC stuff
  26.     vlcInstance = vlc.Instance("--no-xlib")
  27.     player = vlcInstance.media_player_new()
  28.  
  29.     #Player setup
  30.     player.set_xwindow(win_id)
  31.     player.set_mrl("your_video.mp4")
  32.     player.play()
  33.     media = player.get_media()
  34.  
  35.     running = True
  36.     event = SDL_Event()
  37.     while running:
  38.         while SDL_PollEvent(ctypes.byref(event)) != 0:
  39.             if event.type == SDL_QUIT:
  40.                 running = False
  41.                 break
  42.             elif event.type == SDL_KEYDOWN:
  43.                 if event.key.keysym.sym == SDLK_ESCAPE:
  44.                     running = False
  45.                 if event.key.keysym.sym == SDLK_1:
  46.                     vlc.libvlc_video_set_aspect_ratio(player, (16,9))
  47.                 if event.key.keysym.sym == SDLK_2:
  48.                     vlc.libvlc_video_set_aspect_ratio(player, (4,3))
  49.  
  50.     player.stop()
  51.     vlcInstance.release()
  52.  
  53.     SDL_DestroyWindow(window)
  54.     SDL_Quit()
  55.     return 0
  56.  
  57. if __name__ == "__main__":
  58.     sys.exit(main())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement