pygame导入音频
来源:互联网 发布:电脑usb端口怎么打开 编辑:程序博客网 时间:2024/06/10 19:01
导入 pygame.mixer.music.load()
播放 pygame.mixer.music.play()
暂停pygame.mixer.music.pause()
import pygameimport sysfrom pygame.locals import *pygame.init()pygame.mixer.init()pygame.mixer.music.load('Forever Love.ogg')pygame.mixer.music.set_volume(0.2)pygame.mixer.music.play()cat_sound=pygame.mixer.Sound('cat.wav')cat_sound.set_volume(0.2)dog_sound=pygame.mixer.Sound('dog.wav')dog_sound.set_volume(0.2)bg_size=width,height=300,200screen=pygame.display.set_mode(bg_size)pygame.display.set_caption('suguoliang---music')pause=Falsepause_image=pygame.image.load('pause.png').convert_alpha()unpause_image=pygame.image.load('unpause.png').convert_alpha()pause_rect=pause_image.get_rect()pause_rect.left,pause_rect.top=(width-pause_rect.width)//2,(height-pause_rect.width)//2clock=pygame.time.Clock()while True: for event in pygame.event.get(): if event.type==QUIT: sys.exit() if event.type==MOUSEBUTTONDOWN: if event.button==1: cat_sound.play() if event.button==3: dog_sound.play() if event.type==KEYDOWN: if event.key==K_SPACE: pause= not pause screen.fill((255,255,255)) if pause: screen.blit(pause_image,pause_rect) pygame.mixer.music.pause() else: screen.blit(unpause_image,pause_rect) pygame.mixer.music.unpause() pygame.display.flip() clock.tick(30)
阅读全文
0 0
- pygame导入音频
- Pygame 中控制音频流的模块
- eclipse无法导入import pygame解决方法
- eclipse无法导入import pygame解决方法
- Pygame 中访问音频采样数据的模块。
- pygame
- pygame
- pygame
- 【pygame】
- 关于python中如何导入pygame模块(超详细)
- flash CS6 导入音频不成功的问题
- pygame学习:pygame简介
- Hello, PyGame
- PYGAME 入门
- pygame.Font
- pygame.font
- pygame实例
- python_pyopengl,pygame
- (对象类作为参数的方法)
- Java Web 服务器的消息推送 几种方案
- 异步IO、协程、yield from
- opencv 2.4+ c++ 边缘梯度计算
- 多线程
- pygame导入音频
- linux系统之iscsi存储服务
- Yarn产生的历史背景
- python学习—Day41—多进程锁与多进程共享内存
- Codeforces Round #445 Div1 C:Maximum Element (组合数学+DP)
- 采用原生JSP实现页面静态化技术
- juicer 管道符
- Netty Buffer(缓冲)
- 解决tensorflow下的报错。mportError: libcudart.so.8.0: