|
| 1 | +import machine |
| 2 | +import uos |
| 3 | +import _thread |
| 4 | + |
1 | 5 | from mpos.apps import Activity |
2 | 6 | import mpos.sdcard |
3 | 7 | import mpos.ui |
4 | | -# play music |
5 | | -import machine |
6 | | -import uos |
7 | | -from machine import I2S, Pin |
8 | 8 |
|
9 | 9 | class MusicPlayer(Activity): |
10 | 10 |
|
@@ -37,7 +37,9 @@ def file_explorer_event_cb(self, event): |
37 | 37 | fullpath = f"{clean_path}{file}" |
38 | 38 | print(f"Selected: {fullpath}") |
39 | 39 | if fullpath.lower().endswith('.wav'): |
40 | | - self.play_wav(fullpath) |
| 40 | + _thread.stack_size(mpos.apps.good_stack_size()) |
| 41 | + _thread.start_new_thread(self.play_wav, (fullpath,)) |
| 42 | + #self.play_wav(fullpath) |
41 | 43 | else: |
42 | 44 | print("INFO: ignoring unsupported file format") |
43 | 45 |
|
@@ -68,13 +70,13 @@ def play_wav(self, filename): |
68 | 70 | raise ValueError("Only mono audio supported (convert with -ac 1 in FFmpeg)") |
69 | 71 |
|
70 | 72 | # Configure I2S (TX mode for output) |
71 | | - i2s = I2S(0, # I2S peripheral 0 |
72 | | - sck=Pin(2, Pin.OUT), # BCK |
73 | | - ws=Pin(47, Pin.OUT), # LRCK |
74 | | - sd=Pin(16, Pin.OUT), # DIN |
75 | | - mode=I2S.TX, |
| 73 | + i2s = machine.I2S(0, # I2S peripheral 0 |
| 74 | + sck=machine.Pin(2, machine.Pin.OUT), # BCK |
| 75 | + ws=machine.Pin(47, machine.Pin.OUT), # LRCK |
| 76 | + sd=machine.Pin(16, machine.Pin.OUT), # DIN |
| 77 | + mode=machine.I2S.TX, |
76 | 78 | bits=16, |
77 | | - format=I2S.MONO, |
| 79 | + format=machine.I2S.MONO, |
78 | 80 | rate=sample_rate, |
79 | 81 | ibuf=16000) # Internal buffer size (adjust if audio stutters) |
80 | 82 |
|
|
0 commit comments