Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
app-pyaudioplayer
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
santiago duque
app-pyaudioplayer
Commits
2c8e241e
Commit
2c8e241e
authored
Jan 13, 2025
by
Squareclouds Raspberry
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
now working with pygame
parent
8c45815e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
9 deletions
+42
-9
main.py
main.py
+42
-9
No files found.
main.py
View file @
2c8e241e
import
os
from
os.path
import
isfile
,
join
import
pygame
import
keyboard
#
from storage_media import USBDeviceHandler
from
storage_media
import
USBDeviceHandler
# import time
# import signal
# import keyboard
pygame
.
init
()
winW
=
pygame
.
display
.
Info
()
.
current_w
*
0.9
winH
=
pygame
.
display
.
Info
()
.
current_h
*
0.9
window
=
pygame
.
display
.
set_mode
((
winW
,
winH
))
#Fullscreen = True
#window.fill((205,100,100))
#pygame.display.update()
#clock = pygame.time.Clock()
dir_path
=
os
.
getcwd
()
...
...
@@ -19,7 +28,7 @@ channel = False
current_sound_index
=
-
1
contentlist
=
sorted
(
contentlist
)
#
usb_handler = USBDeviceHandler()
usb_handler
=
USBDeviceHandler
()
def
setup_sounds
():
...
...
@@ -48,7 +57,7 @@ def play_sound(index):
""" todo
make sounds stop when new key pressed
else:
if current_sound_index == index:
current_sound_index = index
...
...
@@ -59,34 +68,58 @@ def play_sound(index):
print("Finished.")
else:
print("STOP.")
"""
pygame
.
init
()
clock
=
pygame
.
time
.
Clock
()
setup_sounds
()
run
=
True
while
run
:
clock
.
tick
(
30
)
#
clock.tick(30)
for
event
in
pygame
.
event
.
get
():
if
event
.
type
==
pygame
.
QUIT
:
run
=
False
# keyboard module
'''
if keyboard.is_pressed("q"):
print("You Pressed A Key!")
play_sound(0)
elif keyboard.is_pressed("w"):
print("You Pressed A Key!")
play_sound(1)
elif keyboard.is_pressed("e"):
print("You Pressed A Key!")
play_sound(2)
elif keyboard.is_pressed("r"):
print("You Pressed A Key!")
play_sound(3)
'''
if
event
.
type
==
pygame
.
KEYDOWN
:
print
(
"you pressed "
+
pygame
.
key
.
name
(
event
.
key
))
if
event
.
key
==
pygame
.
K_q
:
play_sound
(
0
)
elif
event
.
key
==
pygame
.
K_w
:
play_sound
(
1
)
play_sound
(
1
)
elif
event
.
key
==
pygame
.
K_e
:
play_sound
(
2
)
elif
event
.
key
==
pygame
.
K_r
:
play_sound
(
3
)
'''
elif event.key == pygame.K_f:
if Fullscreen:
window = pygame.display.set_mode((winW,winH))
Fullscreen = False
else:
window = pygame.display.set_mode((0,0), pygame.FULLSCREEN)
Fullscreen = True
'''
pygame
.
quit
()
exit
()
# time.sleep(5.5)
# signal.pause()
# signal.pause()
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment