【平头哥RVB2601创意应用开发】为webplayer播放例程增加串口调节音量
<p>只需要将player_demo中的cmd_ipc_func函数修改为如下即可:</p><pre>
<code>static void cmd_ipc_func(char *wbuf, int wbuf_len, int argc, char **argv)
{
uint8_t vol_temp;
if (argc == 3 && strcmp(argv, "play") == 0) {
char url;
if (strcmp(argv, "welcom") == 0) {
snprintf(url, sizeof(url), "mem://addr=%u&size=%u", (uint32_t)&_welcome_mp3, _welcome_mp3_len);
player_play(get_player_demo(), url, 0);
} else {
player_play(get_player_demo(), argv, 0);
}
} else if (argc == 2 && strcmp(argv, "stop") == 0) {
player_stop(get_player_demo());
} else if (argc == 2 && strcmp(argv, "volup") == 0) {
player_get_vol(g_player, &vol_temp);
printf("Original Vol:%d\n",vol_temp);
if((vol_temp)<=245)
player_set_vol(g_player, vol_temp+10);
player_get_vol(g_player, &vol_temp);
printf("Current Vol:%d\n",vol_temp);
} else if (argc == 2 && strcmp(argv, "voldown") == 0) {
player_get_vol(g_player, &vol_temp);
printf("Original Vol:%d\n",vol_temp);
if((vol_temp)>=10)
player_set_vol(g_player, vol_temp-10);
player_get_vol(g_player, &vol_temp);
printf("Current Vol:%d\n",vol_temp);
} else if (argc == 2 && strcmp(argv, "pause") == 0) {
player_pause(get_player_demo());
} else if (argc == 2 && strcmp(argv, "resume") == 0) {
player_resume(get_player_demo());
} else if (argc == 3 && strcmp(argv, "web") == 0) {
g_url = strdup(argv);
LOGD(TAG, "g_url = %s", g_url);
aos_task_new("web_task", _webtask, NULL, 6*1024);
} else {
printf("\tplayer play welcom/url\n");
printf("\tplayer pause\n");
printf("\tplayer resume\n");
printf("\tplayer stop\n");
printf("\tplayer volup\n");
printf("\tplayer voldown\n");
printf("\tplayer help");
}
}</code></pre>
<p>使用方式:</p>
<p>player volup 增加音量</p>
<p>player voldown 降低音量</p>
<p>一次增加或减少10个单位。</p>
<p> </p>
<p>在串口中使用命令会显示如下:</p>
<pre>
<code class="language-bash">Current Vol:70
#
# player voldown
<D>player player_get_vol, 839 enter. player = 20009E00
<D>player player_get_vol, 844 leave. player = 20009E00
Original Vol:70
<D>player player_set_vol, 862 enter. player = 20009E00
<D>player player_set_vol, 877 leave. player = 20009E00
<D>player player_get_vol, 839 enter. player = 20009E00
<D>player player_get_vol, 844 leave. player = 20009E00
Current Vol:60
#
# player voldown
<D>player player_get_vol, 839 enter. player = 20009E00
<D>player player_get_vol, 844 leave. player = 20009E00
Original Vol:60
<D>player player_set_vol, 862 enter. player = 20009E00
<D>player player_set_vol, 877 leave. player = 20009E00
<D>player player_get_vol, 839 enter. player = 20009E00
<D>player player_get_vol, 844 leave. player = 20009E00
Current Vol:50
#
# player voldown
<D>player player_get_vol, 839 enter. player = 20009E00
<D>player player_get_vol, 844 leave. player = 20009E00
Original Vol:50
<D>player player_set_vol, 862 enter. player = 20009E00
<D>player player_set_vol, 877 leave. player = 20009E00
<D>player player_get_vol, 839 enter. player = 20009E00
<D>player player_get_vol, 844 leave. player = 20009E00
Current Vol:40
#
# player volup
<D>player player_get_vol, 839 enter. player = 20009E00
<D>player player_get_vol, 844 leave. player = 20009E00
Original Vol:40
<D>player player_set_vol, 862 enter. player = 20009E00
<D>player player_set_vol, 877 leave. player = 20009E00
<D>player player_get_vol, 839 enter. player = 20009E00
<D>player player_get_vol, 844 leave. player = 20009E00
Current Vol:50
#
# player volup
<D>player player_get_vol, 839 enter. player = 20009E00
<D>player player_get_vol, 844 leave. player = 20009E00
Original Vol:50
<D>player player_set_vol, 862 enter. player = 20009E00
<D>player player_set_vol, 877 leave. player = 20009E00
<D>player player_get_vol, 839 enter. player = 20009E00
<D>player player_get_vol, 844 leave. player = 20009E00
Current Vol:60
#
# player volup
<D>player player_get_vol, 839 enter. player = 20009E00
<D>player player_get_vol, 844 leave. player = 20009E00
Original Vol:60
<D>player player_set_vol, 862 enter. player = 20009E00
<D>player player_set_vol, 877 leave. player = 20009E00
<D>player player_get_vol, 839 enter. player = 20009E00
<D>player player_get_vol, 844 leave. player = 20009E00
Current Vol:70
#
# player volup
<D>player player_get_vol, 839 enter. player = 20009E00
<D>player player_get_vol, 844 leave. player = 20009E00
Original Vol:70
<D>player player_set_vol, 862 enter. player = 20009E00
<D>player player_set_vol, 877 leave. player = 20009E00
<D>player player_get_vol, 839 enter. player = 20009E00
<D>player player_get_vol, 844 leave. player = 20009E00
Current Vol:80
#
# player volup
<D>player player_get_vol, 839 enter. player = 20009E00
<D>player player_get_vol, 844 leave. player = 20009E00
Original Vol:80
<D>player player_set_vol, 862 enter. player = 20009E00
<D>player player_set_vol, 877 leave. player = 20009E00
<D>player player_get_vol, 839 enter. player = 20009E00
<D>player player_get_vol, 844 leave. player = 20009E00
Current Vol:90
#
# player volup
<D>player player_get_vol, 839 enter. player = 20009E00
<D>player player_get_vol, 844 leave. player = 20009E00
Original Vol:90
<D>player player_set_vol, 862 enter. player = 20009E00
<D>player player_set_vol, 877 leave. player = 20009E00
<D>player player_get_vol, 839 enter. player = 20009E00
<D>player player_get_vol, 844 leave. player = 20009E00
Current Vol:100
#
# player volup
<D>player player_get_vol, 839 enter. player = 20009E00
<D>player player_get_vol, 844 leave. player = 20009E00
Original Vol:100
<D>player player_set_vol, 862 enter. player = 20009E00
<D>player player_set_vol, 877 leave. player = 20009E00
<D>player player_get_vol, 839 enter. player = 20009E00
<D>player player_get_vol, 844 leave. player = 20009E00
Current Vol:110
#
# player volup
<D>player player_get_vol, 839 enter. player = 20009E00
<D>player player_get_vol, 844 leave. player = 20009E00
Original Vol:110
<D>player player_set_vol, 862 enter. player = 20009E00
<D>player player_set_vol, 877 leave. player = 20009E00
<D>player player_get_vol, 839 enter. player = 20009E00
<D>player player_get_vol, 844 leave. player = 20009E00
Current Vol:120
#
# player volup
<D>player player_get_vol, 839 enter. player = 20009E00
<D>player player_get_vol, 844 leave. player = 20009E00
Original Vol:120
<D>player player_set_vol, 862 enter. player = 20009E00
<D>player player_set_vol, 877 leave. player = 20009E00
<D>player player_get_vol, 839 enter. player = 20009E00
<D>player player_get_vol, 844 leave. player = 20009E00
Current Vol:130
#
# player volup
<D>player player_get_vol, 839 enter. player = 20009E00
<D>player player_get_vol, 844 leave. player = 20009E00
Original Vol:130
<D>player player_set_vol, 862 enter. player = 20009E00
<D>player player_set_vol, 877 leave. player = 20009E00
<D>player player_get_vol, 839 enter. player = 20009E00
<D>player player_get_vol, 844 leave. player = 20009E00
Current Vol:140
#
# player volup
<D>player player_get_vol, 839 enter. player = 20009E00
<D>player player_get_vol, 844 leave. player = 20009E00
Original Vol:140
<D>player player_set_vol, 862 enter. player = 20009E00
<D>player player_set_vol, 877 leave. player = 20009E00
<D>player player_get_vol, 839 enter. player = 20009E00
<D>player player_get_vol, 844 leave. player = 20009E00
Current Vol:150
#
# player volup
<D>player player_get_vol, 839 enter. player = 20009E00
<D>player player_get_vol, 844 leave. player = 20009E00
Original Vol:150
<D>player player_set_vol, 862 enter. player = 20009E00
<D>player player_set_vol, 877 leave. player = 20009E00
<D>player player_get_vol, 839 enter. player = 20009E00
<D>player player_get_vol, 844 leave. player = 20009E00
Current Vol:160
#
# player volup
<D>player player_get_vol, 839 enter. player = 20009E00
<D>player player_get_vol, 844 leave. player = 20009E00
Original Vol:160
<D>player player_set_vol, 862 enter. player = 20009E00
<D>player player_set_vol, 877 leave. player = 20009E00
<D>player player_get_vol, 839 enter. player = 20009E00
<D>player player_get_vol, 844 leave. player = 20009E00
Current Vol:170
#
# player voldown
<D>player player_get_vol, 839 enter. player = 20009E00
<D>player player_get_vol, 844 leave. player = 20009E00
Original Vol:170
<D>player player_set_vol, 862 enter. player = 20009E00
<D>player player_set_vol, 877 leave. player = 20009E00
<D>player player_get_vol, 839 enter. player = 20009E00
<D>player player_get_vol, 844 leave. player = 20009E00
Current Vol:160
#
# player voldown
<D>player player_get_vol, 839 enter. player = 20009E00
<D>player player_get_vol, 844 leave. player = 20009E00
Original Vol:160
<D>player player_set_vol, 862 enter. player = 20009E00
<D>player player_set_vol, 877 leave. player = 20009E00
<D>player player_get_vol, 839 enter. player = 20009E00
<D>player player_get_vol, 844 leave. player = 20009E00
Current Vol:150
#
# player voldown
<D>player player_get_vol, 839 enter. player = 20009E00
<D>player player_get_vol, 844 leave. player = 20009E00
Original Vol:150
<D>player player_set_vol, 862 enter. player = 20009E00
<D>player player_set_vol, 877 leave. player = 20009E00
<D>player player_get_vol, 839 enter. player = 20009E00
<D>player player_get_vol, 844 leave. player = 20009E00
Current Vol:140
#
# player voldown
<D>player player_get_vol, 839 enter. player = 20009E00
<D>player player_get_vol, 844 leave. player = 20009E00
Original Vol:140
<D>player player_set_vol, 862 enter. player = 20009E00
<D>player player_set_vol, 877 leave. player = 20009E00
<D>player player_get_vol, 839 enter. player = 20009E00
<D>player player_get_vol, 844 leave. player = 20009E00
Current Vol:130
#
# player voldown
<D>player player_get_vol, 839 enter. player = 20009E00
<D>player player_get_vol, 844 leave. player = 20009E00
Original Vol:130
<D>player player_set_vol, 862 enter. player = 20009E00
<D>player player_set_vol, 877 leave. player = 20009E00
<D>player player_get_vol, 839 enter. player = 20009E00
<D>player player_get_vol, 844 leave. player = 20009E00
Current Vol:120
#
# player voldown
<D>player player_get_vol, 839 enter. player = 20009E00
<D>player player_get_vol, 844 leave. player = 20009E00
Original Vol:120
<D>player player_set_vol, 862 enter. player = 20009E00
<D>player player_set_vol, 877 leave. player = 20009E00
<D>player player_get_vol, 839 enter. player = 20009E00
<D>player player_get_vol, 844 leave. player = 20009E00
Current Vol:110</code></pre>
<p> </p>
<p>好长的命令记录。。。</p>
页:
[1]