Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- import ctypes
- from sdl2 import *
- #VLC stuff
- import vlc
- def main():
- SDL_Init(SDL_INIT_VIDEO)
- window = SDL_CreateWindow(b"Hello World",
- 0, 0,
- 592, 460, SDL_WINDOW_SHOWN | SDL_WINDOW_FULLSCREEN_DESKTOP)
- windowsurface = SDL_GetWindowSurface(window)
- #Xwindow ID stuff
- wminfo = SDL_SysWMinfo();
- SDL_GetVersion(wminfo.version);
- if(SDL_GetWindowWMInfo(window, wminfo) == 0):
- print("can't get SDL WM info");
- sys.exit(1);
- win_id = wminfo.info.x11.window;
- #VLC stuff
- vlcInstance = vlc.Instance("--no-xlib")
- player = vlcInstance.media_player_new()
- #Player setup
- player.set_xwindow(win_id)
- player.set_mrl("your_video.mp4")
- player.play()
- media = player.get_media()
- running = True
- event = SDL_Event()
- while running:
- while SDL_PollEvent(ctypes.byref(event)) != 0:
- if event.type == SDL_QUIT:
- running = False
- break
- elif event.type == SDL_KEYDOWN:
- if event.key.keysym.sym == SDLK_ESCAPE:
- running = False
- if event.key.keysym.sym == SDLK_1:
- vlc.libvlc_video_set_aspect_ratio(player, (16,9))
- if event.key.keysym.sym == SDLK_2:
- vlc.libvlc_video_set_aspect_ratio(player, (4,3))
- player.stop()
- vlcInstance.release()
- SDL_DestroyWindow(window)
- SDL_Quit()
- return 0
- if __name__ == "__main__":
- sys.exit(main())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement