12
Return list

3386

Posts

0

Resources
21
 

mPython Graphics Programming

 
 

3386

Posts

0

Resources
22
 
This post was last edited by eagle8 on 2020-5-21 09:54

 
 
 

3386

Posts

0

Resources
23
 
This post was last edited by eagler8 on 2020-5-21 08:06

6. Play local sound files

The control panel supports playing many file types, such as MP3, WAV, etc. Since the control panel does not have much space to store files, it is generally more appropriate to use local files in MP3 format. In order to effectively use the storage space, the files uploaded by the control panel cannot be too large. The current version is limited to 100KB, which is not suitable for storing the entire music, but it is more suitable for storing sound effect files.

(1) Upload the mp3 file to the control board
Click "File Management" on the mPythonX toolbar, and click "Upload to the board" in the file management dialog box. In the open file dialog box, select "All Files" as the file type, select the required mp3 file, and click "Open". Finally, follow the prompts to select OK to upload to complete the upload. (It takes a long time to flash the file, and a file of dozens of KB may take 1-2 minutes, so please wait patiently)

 
 
 

3386

Posts

0

Resources
24
 

After the flashing is complete, the corresponding files can be seen in the "Onboard File Management" window:

 
 
 

3386

Posts

0

Resources
25
 

(2) Play local files: The method of playing local MP3 files is the same as that of playing network MP3 files. You only need to change the network MP3 address to the local file name.

#MicroPython Hands-on (24) - Expanding the Control Panel
# Playing Local Sound Files

#MicroPython动手做(24)——掌控板之拓展掌控宝
#播放本地声音文件

from mpython import *
import time
import audio

def on_button_a_down(_):
    time.sleep_ms(10)
    if button_a.value() == 1: return
    oled.fill(0)
    oled.DispChar("播放本地音乐......", 16, 16, 1)
    oled.show()
    audio.player_init()
    audio.set_volume(66)
    audio.play("music_1.mp3")

button_a.irq(trigger=Pin.IRQ_FALLING, handler=on_button_a_down)

 
 
 

3386

Posts

0

Resources
26
 
This post was last edited by eagler8 on 2020-5-21 10:00

mPython X Graphical Programming

 
 
 

3386

Posts

0

Resources
27
 

 
 
 

3386

Posts

0

Resources
28
 

Table of Contents
MicroPython Hands-on (01) - I bought a K210 chip AI development board after the Spring Festival
https://en.eeworld.com/bbs/thread-1115786-1-1.html

MicroPython Hands-on (02) - Try to build the IDE environment of K210 development board
https://en.eeworld.com/bbs/thread-1115831-1-1.html

MicroPython Hands-on (03) - Learn to start and run MicroPython from scratch
https://en.eeworld.com/bbs/thread-1116184-1-1.html

MicroPython Hands-on (04) - Basic examples of learning MicroPython from scratch
https://en.eeworld.com/bbs/thread-1116438-1-1.html

MicroPython Hands-on (05) - Learn MicroPython from scratch - LCD screen
https://en.eeworld.com/bbs/thread-1116577-1-1.html

MicroPython Hands-on (06) - Learn MaixPy from scratch for monocular camera
https://en.eeworld.com/bbs/thread-1116591-1-1.html

MicroPython Hands-on (07) - Learn Machine Vision with MaixPy from Scratch
https://en.eeworld.com/bbs/thread-1116617-1-1.html

MicroPython Hands-on (08) - Learn MaixPy from scratch to recognize colors
https://en.eeworld.com/bbs/thread-1116662-1-1.html

MicroPython Hands-on (09) - Learn MaixPy face recognition from scratch
https://en.eeworld.com/bbs/thread-1116720-1-1.html

MicroPython Hands-on (10) - Learn MaixPy Neural Network KPU from scratch
https://en.eeworld.com/bbs/thread-1116925-1-1.html

MicroPython Hands-on (11) - Building the control board IDE environment
https://en.eeworld.com/bbs/thread-1117964-1-1.html

MicroPython Hands-on (12) - Hello World on the Control Board
https://en.eeworld.com/bbs/thread-1118180-1-1.html

MicroPython Hands-on (13) - RGB tricolor light of the control board
https://en.eeworld.com/bbs/thread-1118275-1-1.html

MicroPython Hands-on (14) - OLED screen of the control board
https://en.eeworld.com/bbs/thread-1118389-1-1.html

MicroPython Hands-on (15) - AB buttons on the control panel
https://en.eeworld.com/bbs/thread-1118496-1-1.html

MicroPython Hands-on (16) - Image display of the control board
https://en.eeworld.com/bbs/thread-1118945-1-1.html

MicroPython Hands-on (17) - Touch pin of control board
https://en.eeworld.com/bbs/thread-1119462-1-1.html

MicroPython Hands-on (18) - Sound and light sensor of the control board
https://en.eeworld.com/bbs/thread-1119583-1-1.html

MicroPython Hands-on (19) - Buzzer and music on the control board
https://en.eeworld.com/bbs/thread-1119668-1-1.html

MicroPython Hands-on (20) - Three-axis acceleration of the control board
https://en.eeworld.com/bbs/thread-1119998-1-1.html

MicroPython Hands-on (21) - Magnetic Field Sensor of Control Board
https://en.eeworld.com/bbs/thread-1120188-1-1.html

MicroPython Hands-on (22) - Wireless Broadcasting of Control Board
https://en.eeworld.com/bbs/thread-1120835-1-1.html

MicroPython Hands-on (23) - WiFi and Bluetooth of the control board
https://en.eeworld.com/bbs/thread-1120934-1-1.html

MicroPython Hands-on (24) - Extension of the control board and control treasure
https://en.eeworld.com/bbs/thread-1121208-1-1.html

MicroPython Hands-on (25) - Speech Synthesis and Speech Recognition
https://en.eeworld.com/bbs/thread-1123752-1-1.html

Supplementary content (2020-6-2 15:52): MicroPython hands-on (26) - OneNET of the Internet of Things https://en.eeworld.com/bbs/thread-1125172-1-1.html MicroPython hands-on (27) - WeChat applet of the Internet of Things https://en.eeworld.com/bbs/thread-1125520-1-1.html
 
 
 

12
Return list
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews

Room 1530, Zhongguancun MOOC Times Building, Block B, 18 Zhongguancun Street, Haidian District, Beijing 100190, China Tel:(010)82350740 Postcode:100190

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list