tasks a-s
This commit is contained in:
parent
47bf37c096
commit
b83f433714
12433 changed files with 156208 additions and 123 deletions
28
Task/Play-recorded-sounds/Python/play-recorded-sounds-1.py
Normal file
28
Task/Play-recorded-sounds/Python/play-recorded-sounds-1.py
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
import time
|
||||
from pygame import mixer
|
||||
|
||||
mixer.init(frequency=16000) #set frequency for wav file
|
||||
s1 = mixer.Sound('test.wav')
|
||||
s2 = mixer.Sound('test2.wav')
|
||||
|
||||
#individual
|
||||
s1.play(-1) #loops indefinitely
|
||||
time.sleep(0.5)
|
||||
|
||||
#simultaneously
|
||||
s2.play() #play once
|
||||
time.sleep(2)
|
||||
s2.play(2) #optional parameter loops three times
|
||||
time.sleep(10)
|
||||
|
||||
#set volume down
|
||||
s1.set_volume(0.1)
|
||||
time.sleep(5)
|
||||
|
||||
#set volume up
|
||||
s1.set_volume(1)
|
||||
time.sleep(5)
|
||||
|
||||
s1.stop()
|
||||
s2.stop()
|
||||
mixer.quit()
|
||||
12
Task/Play-recorded-sounds/Python/play-recorded-sounds-2.py
Normal file
12
Task/Play-recorded-sounds/Python/play-recorded-sounds-2.py
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
import time
|
||||
from pygame import mixer
|
||||
from pygame.mixer import music
|
||||
|
||||
mixer.init()
|
||||
music.load('test.mp3')
|
||||
|
||||
music.play()
|
||||
time.sleep(10)
|
||||
|
||||
music.stop()
|
||||
mixer.quit()
|
||||
Loading…
Add table
Add a link
Reference in a new issue