下了本块播放声音的例程,听了一下只是一声就完了。
所以我改造一下,在主函数里加上一个循环:
#include <app_config.h>
#include <aos/aos.h>
#include <aos/cli.h>
#include <aos/kernel.h>
#include "app_main.h"
#include "app_init.h"
#include "board.h"
#include "player_demo.h"
#include "oled.h"
#define TAG "app"
//class cli_reg_cmd_player;
extern void cxx_system_init(void);
int main(void)
{
// must call this func when use c++
cxx_system_init();
board_yoc_init();
oled_init();
while(1)
{
player_init();
cli_reg_cmd_player();
aos_msleep(11000);
}
return 0;
}
在player_demo.c里改一下音量:
player_t *get_player_demo()
{
if (!g_player) {
ply_conf_t ply_cnf;
player_conf_init(&ply_cnf);
ply_cnf.vol_en = 1;
ply_cnf.vol_index = 100; // 0~255
ply_cnf.event_cb = _player_event;
ply_cnf.period_num = 12; // 12 * 5 period_ms = 60ms
g_player = player_new(&ply_cnf);
}
return g_player;
}
这样就可以循环扩例程的声音了,且不刺耳。