当前位置: 首页>>代码示例>>Python>>正文


Python media.load函数代码示例

本文整理汇总了Python中pyglet.media.load函数的典型用法代码示例。如果您正苦于以下问题:Python load函数的具体用法?Python load怎么用?Python load使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了load函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

 def __init__(self, *args, **kwargs):
     super(self.__class__, self).__init__(*args, **kwargs)
     self.right = create_svg('ninja_right.svg')
     self.left = create_svg('ninja.svg')
     self.dead = create_svg('ninja_death.svg')
     self.sounds = [StaticSource(load('resources/sounds/ninja_hiya_1.ogg')),
                    StaticSource(load('resources/sounds/ninja_hiya_2.ogg'))]
开发者ID:jseutter,项目名称:getoffmylawn,代码行数:7,代码来源:enemies.py

示例2: media

    def media(self, name, streaming=True):
        '''Load a sound or video resource.

        The meaning of `streaming` is as for `media.load`.  Compressed
        sources cannot be streamed (that is, video and compressed audio
        cannot be streamed from a ZIP archive).

        :Parameters:
            `name` : str
                Filename of the media source to load.
            `streaming` : bool
                True if the source should be streamed from disk, False if
                it should be entirely decoded into memory immediately.

        :rtype: `media.Source`
        '''
        self._require_index()
        from pyglet import media
        try:
            location = self._index[name]
            if isinstance(location, FileLocation):
                # Don't open the file if it's streamed from disk -- AVbin
                # needs to do it.
                path = os.path.join(location.path, name)
                return media.load(path, streaming=streaming)
            else:
                file = location.open(name)
                return media.load(name, file=file, streaming=streaming)
        except KeyError:
            raise ResourceNotFoundException(name)
开发者ID:Eaglemania,项目名称:ASS,代码行数:30,代码来源:resource.py

示例3: play

def play(audio):
    if audio != "silent":
        player1 = Player()
        player1.queue(load(join(DATA, "chronotank.ogg")))
        player1.queue(load(join(DATA, "imagine_a_world.ogg")))
        player1.play()

        player2 = Player()
        player2.eos_action = Player.EOS_LOOP
        player2.queue(load(join(DATA, "stupidsongimadenofarting.ogg")))
        player2.play()
开发者ID:tartley,项目名称:chronotank,代码行数:11,代码来源:audio.py

示例4: find_resource

def find_resource(type, filename):
    """return resource given type (e.g. RESOURCE_IMAGE) and filename"""

    path = os.path.join(path_for_resource_type(type), filename)

    if type == RESOURCE_IMAGE: return image.load(path)
    if type == RESOURCE_FONT:  return font.load(path)
    if type == RESOURCE_SOUND: return media.load(path, streaming=False)
    if type == RESOURCE_MUSIC: return media.load(path, streaming=True)

    assert False
开发者ID:gingi007,项目名称:python-poker-engine,代码行数:11,代码来源:resources.py

示例5: load_source

 def load_source(self, filename):
     print 'loading source: ', filename
     self.source = media.load(filename)
     try:
         self.source = media.load(filename)
         print '1'
         self.width = int(self.source.video_format.width)
         self.height = int(self.source.video_format.height)
         self.duration = self.source.duration
         print 'loaded movie.. height: ', self.height, ' | width: ', self.width
     except:
         print 'failed to open movie!'
         ValueError('failed to open movie!')
开发者ID:florisvb,项目名称:pymovie,代码行数:13,代码来源:pygmovie.py

示例6: main

def main():
    usage = '%prog [options] FILE'

    parser = OptionParser(usage)

    parser.add_option("--format", type='string', default=None)

    (options, args) = parser.parse_args()

    in_filename = args[0]

    if options.format is None or options.format.lower() != 'mono8':
        raise NotImplementedError('Only mono8 format is supported with no '
                                  'autodetection. Use "--format=mono8".')

    source = media.load(in_filename)
    imn, ts = get_frame(source)

    file_base = os.path.splitext(in_filename)[0]
    out_filename = file_base+'.fmf'

    fmf = fmf_mod.FlyMovieSaver(out_filename,
                                format='MONO8',
                                bits_per_pixel=8,
                                version=3,
                                )

    while imn is not None:
        fmf.add_frame( imn, ts )
        imn, ts = get_frame(source)
开发者ID:motmot,项目名称:flymovieformat,代码行数:30,代码来源:ffmpeg2fmf.py

示例7: queue_soundtrack

def queue_soundtrack(song='8bp069-06-she-streets.mp3', soundtrack=None):
    if not soundtrack:
        soundtrack = media.Player()
        soundtrack.eos_action = 'loop'

    soundtrack.queue(media.load(data_file(song)))
    return soundtrack
开发者ID:pdevine,项目名称:suburbia,代码行数:7,代码来源:sound.py

示例8: playSounds

def playSounds(instrument, notes, mutex, turnstile, turnstile2, counter):
	sound = media.load(instrument, streaming=False)
	pitch = 0
	for c in notes:
		mutex.acquire()
		counter.increment()
		if counter.get() == counter.getNum():
			turnstile2.acquire()
			turnstile.release()
		mutex.release()
		turnstile.acquire()
		turnstile.release()
		if c.isdigit():
			player = media.Player()
			player.queue(sound)
			player.pitch = (2.0**(float(c)/12))
			#player.pitch = int(c)
			#print player.pitch
			player.play()
			sleep(2)
		mutex.acquire()
		counter.decrement()
		if counter.get() == 0:
			turnstile.acquire()
			turnstile2.release()
		mutex.release()
		turnstile2.acquire()
		turnstile2.release()
开发者ID:lyra833,项目名称:Stufts2,代码行数:28,代码来源:rockband.py

示例9: queueSoundtrack

def queueSoundtrack(song):
    global soundtrack
    if not soundtrack:
        soundtrack = media.Player()
        soundtrack.eos_action = 'loop'
    soundtrack.queue(media.load(os.path.join(data.data_dir, song)))
    return soundtrack
开发者ID:avuserow,项目名称:yoyobrawlah,代码行数:7,代码来源:level.py

示例10: load_file

 def load_file(self, name, ext, path):
     if ext in self.image_filetypes:
         self.image_dict[name + ext] = image.load(os.path.join(path, 
             '%s%s' % (name, ext))).get_texture()
         print "Image '%s' loaded!" % (name + ext)
     if ext in self.sound_filetypes:
         self.sound_dict[name + ext] = media.load(path + os.sep + name + ext,
                                                  streaming = False)
         print "Sound '%s' loaded!" % (name + ext)
开发者ID:DMAshura,项目名称:porcupyne,代码行数:9,代码来源:resources.py

示例11: load_sound

def load_sound(path):
    """Load a static sound source from the sounds directory.

    :Parameters:
        `path` : str
            The relative path from the sounds directory to the file.

    """
    sound_path = os.path.join(DATA_DIR, "sounds", path)
    return media.load(sound_path, streaming=False)
开发者ID:jseutter,项目名称:pyweek10,代码行数:10,代码来源:data.py

示例12: main

def main():
    director.init(**window)
    main_scene = Scene(StartLayer())

    player = Player()
    player.queue(load("resources/audios/cave.wav"))
    player.eos_action = player.EOS_LOOP
    player.play()

    director.run(main_scene)
开发者ID:Kelossus,项目名称:King-of-the-Dungeon,代码行数:10,代码来源:king_of_the_dungeon.py

示例13: load_song

def load_song(path):
    """Load a music stream from the music directory.

    :Parameters:
        `path` : str
            The relative path from the music directory to the file.

    """
    song_path = os.path.join(DATA_DIR, "music", path)
    return media.load(song_path)
开发者ID:jseutter,项目名称:pyweek10,代码行数:10,代码来源:data.py

示例14: __init__

    def __init__(self, parent, file=None, source=None, playing=False,
                 x=0, y=0, z=0, width=None, height=None, scale=True, **kw):
        self.parent = parent
        self.scale = scale

        if file is not None:
            source = self.source = media.load(file, streaming=True)
        else:
            assert source is not None, 'one of file or source is required'

        self.player = media.Player()
        self.player.eos_action = self.player.EOS_PAUSE
        self.player.on_eos = self.on_eos

        # poke at the video format
        if not source.video_format:
            raise ValueError("Movie file doesn't contain video")
        video_format = source.video_format
        if width is None:
            width = video_format.width
            if video_format.sample_aspect > 1:
                width *= video_format.sample_aspect
        if height is None:
            height = video_format.height
            if video_format.sample_aspect < 1:
                height /= video_format.sample_aspect

        super().__init__(parent, x, y, z, width, height, **kw)

        # control frame top-level
        c = self.control = Frame(self, bgcolor=(1, 1, 1, .5),
                                 is_visible=False, width='100%', height=64)

        # controls underlay
        f = Frame(c, is_transparent=True, width='100%', height='100%')
        f.layout = layouts.Horizontal(f, valign='center', halign='center',
                                      padding=10)
        c.play = Image(f, data.load_gui_image('media-play.png'),
                       classes=('-play-button',), is_visible=not playing)
        c.pause = Image(f, data.load_gui_image('media-pause.png'),
                        bgcolor=None, classes=('-pause-button',),
                        is_visible=playing)
        fi = Frame(f, is_transparent=True)
        c.range = Image(fi, data.load_gui_image('media-range.png'))
        im = data.load_gui_image('media-position.png')
        c.position = Image(fi, im, x=0, y=-2, classes=('-position',))
        c.time = Label(f, '00:00', font_size=20)
        c.anim = None

        # make sure we get at least one frame to display
        self.player.queue(source)
        clock.schedule(self.update)
        self.playing = False
        if playing:
            self.play()
开发者ID:bitcraft,项目名称:pyglet,代码行数:55,代码来源:movie.py

示例15: main

def main():
    fname='/home/evan/Desktop/openJarvis/openJarvis/speech/tdfw.mp3'
    src=media.load(fname)
    player=media.Player()
    player.queue(src)
    player.volume=1.0
    player.play()
    try:
        pyglet.app.run()
    except KeyboardInterrupt:
        player.next()
开发者ID:Evanc123,项目名称:openJarvis,代码行数:11,代码来源:audio.py


注:本文中的pyglet.media.load函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。