anthpo 发表于 2022-4-26 23:59

【平头哥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 &amp;&amp; strcmp(argv, "play") == 0) {
      char url;
      if (strcmp(argv, "welcom") == 0) {
            snprintf(url, sizeof(url), "mem://addr=%u&amp;size=%u", (uint32_t)&amp;_welcome_mp3, _welcome_mp3_len);
            player_play(get_player_demo(), url, 0);
      } else {
            player_play(get_player_demo(), argv, 0);
      }
    } else if (argc == 2 &amp;&amp; strcmp(argv, "stop") == 0) {
      player_stop(get_player_demo());
    } else if (argc == 2 &amp;&amp; strcmp(argv, "volup") == 0) {
                player_get_vol(g_player, &amp;vol_temp);
                printf("Original Vol:%d\n",vol_temp);
                if((vol_temp)&lt;=245)
                        player_set_vol(g_player, vol_temp+10);
                player_get_vol(g_player, &amp;vol_temp);
                printf("Current Vol:%d\n",vol_temp);
    } else if (argc == 2 &amp;&amp; strcmp(argv, "voldown") == 0) {
                player_get_vol(g_player, &amp;vol_temp);
                printf("Original Vol:%d\n",vol_temp);
                if((vol_temp)&gt;=10)
                        player_set_vol(g_player, vol_temp-10);
                player_get_vol(g_player, &amp;vol_temp);
                printf("Current Vol:%d\n",vol_temp);
    } else if (argc == 2 &amp;&amp; strcmp(argv, "pause") == 0) {
      player_pause(get_player_demo());
    } else if (argc == 2 &amp;&amp; strcmp(argv, "resume") == 0) {
      player_resume(get_player_demo());
    } else if (argc == 3 &amp;&amp; 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>&nbsp;</p>

<p>在串口中使用命令会显示如下:</p>

<pre>
<code class="language-bash">Current Vol:70

#
# player voldown
&lt;D&gt;player player_get_vol, 839 enter. player = 20009E00

&lt;D&gt;player player_get_vol, 844 leave. player = 20009E00

Original Vol:70
&lt;D&gt;player player_set_vol, 862 enter. player = 20009E00

&lt;D&gt;player player_set_vol, 877 leave. player = 20009E00

&lt;D&gt;player player_get_vol, 839 enter. player = 20009E00

&lt;D&gt;player player_get_vol, 844 leave. player = 20009E00

Current Vol:60

#
# player voldown
&lt;D&gt;player player_get_vol, 839 enter. player = 20009E00

&lt;D&gt;player player_get_vol, 844 leave. player = 20009E00

Original Vol:60
&lt;D&gt;player player_set_vol, 862 enter. player = 20009E00

&lt;D&gt;player player_set_vol, 877 leave. player = 20009E00

&lt;D&gt;player player_get_vol, 839 enter. player = 20009E00

&lt;D&gt;player player_get_vol, 844 leave. player = 20009E00

Current Vol:50

#
# player voldown
&lt;D&gt;player player_get_vol, 839 enter. player = 20009E00

&lt;D&gt;player player_get_vol, 844 leave. player = 20009E00

Original Vol:50
&lt;D&gt;player player_set_vol, 862 enter. player = 20009E00

&lt;D&gt;player player_set_vol, 877 leave. player = 20009E00

&lt;D&gt;player player_get_vol, 839 enter. player = 20009E00

&lt;D&gt;player player_get_vol, 844 leave. player = 20009E00

Current Vol:40

#
# player volup
&lt;D&gt;player player_get_vol, 839 enter. player = 20009E00

&lt;D&gt;player player_get_vol, 844 leave. player = 20009E00

Original Vol:40
&lt;D&gt;player player_set_vol, 862 enter. player = 20009E00

&lt;D&gt;player player_set_vol, 877 leave. player = 20009E00

&lt;D&gt;player player_get_vol, 839 enter. player = 20009E00

&lt;D&gt;player player_get_vol, 844 leave. player = 20009E00

Current Vol:50

#
# player volup
&lt;D&gt;player player_get_vol, 839 enter. player = 20009E00

&lt;D&gt;player player_get_vol, 844 leave. player = 20009E00

Original Vol:50
&lt;D&gt;player player_set_vol, 862 enter. player = 20009E00

&lt;D&gt;player player_set_vol, 877 leave. player = 20009E00

&lt;D&gt;player player_get_vol, 839 enter. player = 20009E00

&lt;D&gt;player player_get_vol, 844 leave. player = 20009E00

Current Vol:60

#
# player volup
&lt;D&gt;player player_get_vol, 839 enter. player = 20009E00

&lt;D&gt;player player_get_vol, 844 leave. player = 20009E00

Original Vol:60
&lt;D&gt;player player_set_vol, 862 enter. player = 20009E00

&lt;D&gt;player player_set_vol, 877 leave. player = 20009E00

&lt;D&gt;player player_get_vol, 839 enter. player = 20009E00

&lt;D&gt;player player_get_vol, 844 leave. player = 20009E00

Current Vol:70

#
# player volup
&lt;D&gt;player player_get_vol, 839 enter. player = 20009E00

&lt;D&gt;player player_get_vol, 844 leave. player = 20009E00

Original Vol:70
&lt;D&gt;player player_set_vol, 862 enter. player = 20009E00

&lt;D&gt;player player_set_vol, 877 leave. player = 20009E00

&lt;D&gt;player player_get_vol, 839 enter. player = 20009E00

&lt;D&gt;player player_get_vol, 844 leave. player = 20009E00

Current Vol:80

#
# player volup
&lt;D&gt;player player_get_vol, 839 enter. player = 20009E00

&lt;D&gt;player player_get_vol, 844 leave. player = 20009E00

Original Vol:80
&lt;D&gt;player player_set_vol, 862 enter. player = 20009E00

&lt;D&gt;player player_set_vol, 877 leave. player = 20009E00

&lt;D&gt;player player_get_vol, 839 enter. player = 20009E00

&lt;D&gt;player player_get_vol, 844 leave. player = 20009E00

Current Vol:90

#
# player volup
&lt;D&gt;player player_get_vol, 839 enter. player = 20009E00

&lt;D&gt;player player_get_vol, 844 leave. player = 20009E00

Original Vol:90
&lt;D&gt;player player_set_vol, 862 enter. player = 20009E00

&lt;D&gt;player player_set_vol, 877 leave. player = 20009E00

&lt;D&gt;player player_get_vol, 839 enter. player = 20009E00

&lt;D&gt;player player_get_vol, 844 leave. player = 20009E00

Current Vol:100

#
# player volup
&lt;D&gt;player player_get_vol, 839 enter. player = 20009E00

&lt;D&gt;player player_get_vol, 844 leave. player = 20009E00

Original Vol:100
&lt;D&gt;player player_set_vol, 862 enter. player = 20009E00

&lt;D&gt;player player_set_vol, 877 leave. player = 20009E00

&lt;D&gt;player player_get_vol, 839 enter. player = 20009E00

&lt;D&gt;player player_get_vol, 844 leave. player = 20009E00

Current Vol:110

#
# player volup
&lt;D&gt;player player_get_vol, 839 enter. player = 20009E00

&lt;D&gt;player player_get_vol, 844 leave. player = 20009E00

Original Vol:110
&lt;D&gt;player player_set_vol, 862 enter. player = 20009E00

&lt;D&gt;player player_set_vol, 877 leave. player = 20009E00

&lt;D&gt;player player_get_vol, 839 enter. player = 20009E00

&lt;D&gt;player player_get_vol, 844 leave. player = 20009E00

Current Vol:120

#
# player volup
&lt;D&gt;player player_get_vol, 839 enter. player = 20009E00

&lt;D&gt;player player_get_vol, 844 leave. player = 20009E00

Original Vol:120
&lt;D&gt;player player_set_vol, 862 enter. player = 20009E00

&lt;D&gt;player player_set_vol, 877 leave. player = 20009E00

&lt;D&gt;player player_get_vol, 839 enter. player = 20009E00

&lt;D&gt;player player_get_vol, 844 leave. player = 20009E00

Current Vol:130

#
# player volup
&lt;D&gt;player player_get_vol, 839 enter. player = 20009E00

&lt;D&gt;player player_get_vol, 844 leave. player = 20009E00

Original Vol:130
&lt;D&gt;player player_set_vol, 862 enter. player = 20009E00

&lt;D&gt;player player_set_vol, 877 leave. player = 20009E00

&lt;D&gt;player player_get_vol, 839 enter. player = 20009E00

&lt;D&gt;player player_get_vol, 844 leave. player = 20009E00

Current Vol:140

#
# player volup
&lt;D&gt;player player_get_vol, 839 enter. player = 20009E00

&lt;D&gt;player player_get_vol, 844 leave. player = 20009E00

Original Vol:140
&lt;D&gt;player player_set_vol, 862 enter. player = 20009E00

&lt;D&gt;player player_set_vol, 877 leave. player = 20009E00

&lt;D&gt;player player_get_vol, 839 enter. player = 20009E00

&lt;D&gt;player player_get_vol, 844 leave. player = 20009E00

Current Vol:150

#
# player volup
&lt;D&gt;player player_get_vol, 839 enter. player = 20009E00

&lt;D&gt;player player_get_vol, 844 leave. player = 20009E00

Original Vol:150
&lt;D&gt;player player_set_vol, 862 enter. player = 20009E00

&lt;D&gt;player player_set_vol, 877 leave. player = 20009E00

&lt;D&gt;player player_get_vol, 839 enter. player = 20009E00

&lt;D&gt;player player_get_vol, 844 leave. player = 20009E00

Current Vol:160

#
# player volup
&lt;D&gt;player player_get_vol, 839 enter. player = 20009E00

&lt;D&gt;player player_get_vol, 844 leave. player = 20009E00

Original Vol:160
&lt;D&gt;player player_set_vol, 862 enter. player = 20009E00

&lt;D&gt;player player_set_vol, 877 leave. player = 20009E00

&lt;D&gt;player player_get_vol, 839 enter. player = 20009E00

&lt;D&gt;player player_get_vol, 844 leave. player = 20009E00

Current Vol:170

#
# player voldown
&lt;D&gt;player player_get_vol, 839 enter. player = 20009E00

&lt;D&gt;player player_get_vol, 844 leave. player = 20009E00

Original Vol:170
&lt;D&gt;player player_set_vol, 862 enter. player = 20009E00

&lt;D&gt;player player_set_vol, 877 leave. player = 20009E00

&lt;D&gt;player player_get_vol, 839 enter. player = 20009E00

&lt;D&gt;player player_get_vol, 844 leave. player = 20009E00

Current Vol:160

#
# player voldown
&lt;D&gt;player player_get_vol, 839 enter. player = 20009E00

&lt;D&gt;player player_get_vol, 844 leave. player = 20009E00

Original Vol:160
&lt;D&gt;player player_set_vol, 862 enter. player = 20009E00

&lt;D&gt;player player_set_vol, 877 leave. player = 20009E00

&lt;D&gt;player player_get_vol, 839 enter. player = 20009E00

&lt;D&gt;player player_get_vol, 844 leave. player = 20009E00

Current Vol:150

#
# player voldown
&lt;D&gt;player player_get_vol, 839 enter. player = 20009E00

&lt;D&gt;player player_get_vol, 844 leave. player = 20009E00

Original Vol:150
&lt;D&gt;player player_set_vol, 862 enter. player = 20009E00

&lt;D&gt;player player_set_vol, 877 leave. player = 20009E00

&lt;D&gt;player player_get_vol, 839 enter. player = 20009E00

&lt;D&gt;player player_get_vol, 844 leave. player = 20009E00

Current Vol:140

#
# player voldown
&lt;D&gt;player player_get_vol, 839 enter. player = 20009E00

&lt;D&gt;player player_get_vol, 844 leave. player = 20009E00

Original Vol:140
&lt;D&gt;player player_set_vol, 862 enter. player = 20009E00

&lt;D&gt;player player_set_vol, 877 leave. player = 20009E00

&lt;D&gt;player player_get_vol, 839 enter. player = 20009E00

&lt;D&gt;player player_get_vol, 844 leave. player = 20009E00

Current Vol:130

#
# player voldown
&lt;D&gt;player player_get_vol, 839 enter. player = 20009E00

&lt;D&gt;player player_get_vol, 844 leave. player = 20009E00

Original Vol:130
&lt;D&gt;player player_set_vol, 862 enter. player = 20009E00

&lt;D&gt;player player_set_vol, 877 leave. player = 20009E00

&lt;D&gt;player player_get_vol, 839 enter. player = 20009E00

&lt;D&gt;player player_get_vol, 844 leave. player = 20009E00

Current Vol:120

#
# player voldown
&lt;D&gt;player player_get_vol, 839 enter. player = 20009E00

&lt;D&gt;player player_get_vol, 844 leave. player = 20009E00

Original Vol:120
&lt;D&gt;player player_set_vol, 862 enter. player = 20009E00

&lt;D&gt;player player_set_vol, 877 leave. player = 20009E00

&lt;D&gt;player player_get_vol, 839 enter. player = 20009E00

&lt;D&gt;player player_get_vol, 844 leave. player = 20009E00

Current Vol:110</code></pre>

<p>&nbsp;</p>

freebsder 发表于 2022-4-27 22:40

<p>好长的命令记录。。。</p>
页: [1]
查看完整版本: 【平头哥RVB2601创意应用开发】为webplayer播放例程增加串口调节音量