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
b3f06347
Commit
b3f06347
authored
Jan 14, 2025
by
santiago duque
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added second button and logic to stop events as a test
parent
3aa4d70c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
11 deletions
+14
-11
main.py
main.py
+14
-11
No files found.
main.py
View file @
b3f06347
import
sys
import
os
from
os.path
import
isfile
,
join
import
pygame
...
...
@@ -56,17 +57,18 @@ def play_sound(index):
global
sound_array
global
btn_array
sound_playing
=
True
print
(
'play func called'
)
sound_playing
=
True
if
not
cut_current_sound
:
current_sound_index
=
index
channel
=
sound_array
[
current_sound_index
]
.
play
()
while
channel
.
get_busy
():
pygame
.
time
.
wait
(
100
)
# ms
print
(
"Playing..."
)
pygame
.
event
.
clear
()
sound_playing
=
False
#btn_array[current_sound_index].when_pressed = lambda: btn_pressed(index)
print
(
"Finished. "
)
...
...
@@ -125,31 +127,31 @@ setup_paths(False)
def
btn_pressed
(
index
):
global
btn_array
global
sound_playing
btn_array
[
index
]
.
when_pressed
=
None
btn_array
[
index
]
.
when_released
=
lambda
:
resetBtn
(
index
)
#
btn_array[index].when_pressed = None
#
btn_array[index].when_released = lambda: resetBtn(index)
print
(
'keeps pressing'
)
if
(
not
sound_playing
):
print
(
'btn pressed'
)
play_sound
(
index
)
def
resetBtn
(
index
):
"""
def resetBtn(index):
global btn_array
#if(sound_playing):
print('btn released')
btn_array[index].when_released = None
pygame
.
time
.
wait
(
100
)
btn_array
[
index
]
.
when_pressed
=
lambda
:
btn_pressed
(
index
)
btn_array[index].when_pressed = lambda: btn_pressed(index) """
btn1
=
Button
(
21
)
btn1
.
when_pressed
=
lambda
:
btn_pressed
(
0
)
btn1
.
when_held
=
None
btn1
.
when_released
=
lambda
:
resetBtn
(
0
)
#
btn1.when_held = None
#
btn1.when_released = lambda: resetBtn(0)
btn2
=
Button
(
13
)
btn2
.
when_pressed
=
lambda
:
btn_pressed
(
1
)
btn2
.
when_held
=
None
btn2
.
when_released
=
lambda
:
resetBtn
(
1
)
#
btn2.when_held = None
#
btn2.when_released = lambda: resetBtn(1)
btn_array
=
[
btn1
,
btn2
]
...
...
@@ -201,6 +203,7 @@ while run:
pygame
.
quit
()
sys
.
exit
()
exit
()
# time.sleep(5.5)
# signal.pause()
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