1#!/usr/bin/env python 2# ---------------------------------------------------------------------------- 3# pyglet 4# Copyright (c) 2006-2008 Alex Holkner 5# All rights reserved. 6# 7# Redistribution and use in source and binary forms, with or without 8# modification, are permitted provided that the following conditions 9# are met: 10# 11# * Redistributions of source code must retain the above copyright 12# notice, this list of conditions and the following disclaimer. 13# * Redistributions in binary form must reproduce the above copyright 14# notice, this list of conditions and the following disclaimer in 15# the documentation and/or other materials provided with the 16# distribution. 17# * Neither the name of pyglet nor the names of its 18# contributors may be used to endorse or promote products 19# derived from this software without specific prior written 20# permission. 21# 22# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 25# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 26# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 27# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 28# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 30# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 32# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33# POSSIBILITY OF SUCH DAMAGE. 34# ---------------------------------------------------------------------------- 35 36"""Simple example of video playback. 37 38Usage:: 39 40 video.py <filename> 41 42See the Programming Guide for a partial list of supported video formats. 43""" 44 45from __future__ import print_function 46 47__docformat__ = 'restructuredtext' 48__version__ = '$Id$' 49 50import sys 51import pyglet 52 53if len(sys.argv) < 2: 54 print(__doc__) 55 sys.exit(1) 56 57source = pyglet.media.load(sys.argv[1]) 58fmt = source.video_format 59if not fmt: 60 print('No video track in this source.') 61 sys.exit(1) 62 63player = pyglet.media.Player() 64player.queue(source) 65player.play() 66 67window = pyglet.window.Window(width=fmt.width, height=fmt.height) 68 69 70@window.event 71def on_draw(): 72 player.texture.blit(0, 0) 73 74 75pyglet.app.run() 76