1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
| import pyglet
#Set Audio
pyglet.options['audio'] = ('openal', 'pulse', 'directsound', 'silent')
# creating a window
window = pyglet.window.Window(1920, 1080)
# video path
vidPath = "Vidéo.mp4"
# creating a media player object
player = pyglet.media.Player()
# creating a source object
#source = pyglet.media.StreamingSource()
# load the media from the source
MediaLoad = pyglet.media.load(vidPath)
# add this media in the queue
player.queue(MediaLoad)
# play the video
player.play()
# on draw event
@window.event
def on_draw():
# clear the window
window.clear()
# if player source exist
# and video format exist
if player.source and player.source.video_format:
# get the texture of video and
# make surface to display on the screen
player.get_texture().blit(0, 0)
# run the pyglet application
pyglet.app.run() |