1737|1

20

帖子

1

TA的资源

一粒金砂(中级)

楼主
 

【平头哥RVB2601创意应用开发】为webplayer播放例程增加串口调节音量 [复制链接]

 

只需要将player_demo中的cmd_ipc_func函数修改为如下即可:

static void cmd_ipc_func(char *wbuf, int wbuf_len, int argc, char **argv)
{
	uint8_t vol_temp;
    if (argc == 3 && strcmp(argv[1], "play") == 0) {
        char url[128];
        if (strcmp(argv[2], "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[2], 0);
        }
    } else if (argc == 2 && strcmp(argv[1], "stop") == 0) {
        player_stop(get_player_demo());
    } else if (argc == 2 && strcmp(argv[1], "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[1], "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[1], "pause") == 0) {
        player_pause(get_player_demo());
    } else if (argc == 2 && strcmp(argv[1], "resume") == 0) {
        player_resume(get_player_demo());
    } else if (argc == 3 && strcmp(argv[1], "web") == 0) {
        g_url = strdup(argv[2]);
        LOGD(TAG, "g_url = %s", g_url);
        aos_task_new("web_task", _webtask, NULL, 6*1024);
    } else {
        printf("\tplayer play welcom/url[http://]\n");
        printf("\tplayer pause\n");
        printf("\tplayer resume\n");
        printf("\tplayer stop\n");
		printf("\tplayer volup\n");
		printf("\tplayer voldown\n");
        printf("\tplayer help");
    }
}

使用方式:

player volup 增加音量

player voldown 降低音量

一次增加或减少10个单位。

 

在串口中使用命令会显示如下:

Current Vol:70

# 
# player voldown
[  21.230]<D>player player_get_vol, 839 enter. player = 20009E00

[  21.240]<D>player player_get_vol, 844 leave. player = 20009E00

Original Vol:70
[  21.260]<D>player player_set_vol, 862 enter. player = 20009E00

[  21.270]<D>player player_set_vol, 877 leave. player = 20009E00

[  21.300]<D>player player_get_vol, 839 enter. player = 20009E00

[  21.300]<D>player player_get_vol, 844 leave. player = 20009E00

Current Vol:60

# 
# player voldown
[  21.370]<D>player player_get_vol, 839 enter. player = 20009E00

[  21.370]<D>player player_get_vol, 844 leave. player = 20009E00

Original Vol:60
[  21.410]<D>player player_set_vol, 862 enter. player = 20009E00

[  21.410]<D>player player_set_vol, 877 leave. player = 20009E00

[  21.450]<D>player player_get_vol, 839 enter. player = 20009E00

[  21.450]<D>player player_get_vol, 844 leave. player = 20009E00

Current Vol:50

# 
# player voldown
[  21.940]<D>player player_get_vol, 839 enter. player = 20009E00

[  21.940]<D>player player_get_vol, 844 leave. player = 20009E00

Original Vol:50
[  21.960]<D>player player_set_vol, 862 enter. player = 20009E00

[  21.970]<D>player player_set_vol, 877 leave. player = 20009E00

[  21.990]<D>player player_get_vol, 839 enter. player = 20009E00

[  21.990]<D>player player_get_vol, 844 leave. player = 20009E00

Current Vol:40

# 
# player volup
[  26.880]<D>player player_get_vol, 839 enter. player = 20009E00

[  26.880]<D>player player_get_vol, 844 leave. player = 20009E00

Original Vol:40
[  26.930]<D>player player_set_vol, 862 enter. player = 20009E00

[  26.940]<D>player player_set_vol, 877 leave. player = 20009E00

[  26.960]<D>player player_get_vol, 839 enter. player = 20009E00

[  26.960]<D>player player_get_vol, 844 leave. player = 20009E00

Current Vol:50

# 
# player volup
[  27.770]<D>player player_get_vol, 839 enter. player = 20009E00

[  27.770]<D>player player_get_vol, 844 leave. player = 20009E00

Original Vol:50
[  27.820]<D>player player_set_vol, 862 enter. player = 20009E00

[  27.820]<D>player player_set_vol, 877 leave. player = 20009E00

[  27.840]<D>player player_get_vol, 839 enter. player = 20009E00

[  27.850]<D>player player_get_vol, 844 leave. player = 20009E00

Current Vol:60

# 
# player volup
[  28.740]<D>player player_get_vol, 839 enter. player = 20009E00

[  28.740]<D>player player_get_vol, 844 leave. player = 20009E00

Original Vol:60
[  28.760]<D>player player_set_vol, 862 enter. player = 20009E00

[  28.770]<D>player player_set_vol, 877 leave. player = 20009E00

[  28.800]<D>player player_get_vol, 839 enter. player = 20009E00

[  28.810]<D>player player_get_vol, 844 leave. player = 20009E00

Current Vol:70

# 
# player volup
[  29.470]<D>player player_get_vol, 839 enter. player = 20009E00

[  29.470]<D>player player_get_vol, 844 leave. player = 20009E00

Original Vol:70
[  29.490]<D>player player_set_vol, 862 enter. player = 20009E00

[  29.500]<D>player player_set_vol, 877 leave. player = 20009E00

[  29.530]<D>player player_get_vol, 839 enter. player = 20009E00

[  29.530]<D>player player_get_vol, 844 leave. player = 20009E00

Current Vol:80

# 
# player volup
[  30.330]<D>player player_get_vol, 839 enter. player = 20009E00

[  30.340]<D>player player_get_vol, 844 leave. player = 20009E00

Original Vol:80
[  30.360]<D>player player_set_vol, 862 enter. player = 20009E00

[  30.360]<D>player player_set_vol, 877 leave. player = 20009E00

[  30.390]<D>player player_get_vol, 839 enter. player = 20009E00

[  30.390]<D>player player_get_vol, 844 leave. player = 20009E00

Current Vol:90

# 
# player volup
[  30.950]<D>player player_get_vol, 839 enter. player = 20009E00

[  30.960]<D>player player_get_vol, 844 leave. player = 20009E00

Original Vol:90
[  30.980]<D>player player_set_vol, 862 enter. player = 20009E00

[  30.990]<D>player player_set_vol, 877 leave. player = 20009E00

[  31.010]<D>player player_get_vol, 839 enter. player = 20009E00

[  31.010]<D>player player_get_vol, 844 leave. player = 20009E00

Current Vol:100

# 
# player volup
[  31.110]<D>player player_get_vol, 839 enter. player = 20009E00

[  31.120]<D>player player_get_vol, 844 leave. player = 20009E00

Original Vol:100
[  31.150]<D>player player_set_vol, 862 enter. player = 20009E00

[  31.150]<D>player player_set_vol, 877 leave. player = 20009E00

[  31.170]<D>player player_get_vol, 839 enter. player = 20009E00

[  31.180]<D>player player_get_vol, 844 leave. player = 20009E00

Current Vol:110

# 
# player volup
[  31.300]<D>player player_get_vol, 839 enter. player = 20009E00

[  31.310]<D>player player_get_vol, 844 leave. player = 20009E00

Original Vol:110
[  31.330]<D>player player_set_vol, 862 enter. player = 20009E00

[  31.340]<D>player player_set_vol, 877 leave. player = 20009E00

[  31.360]<D>player player_get_vol, 839 enter. player = 20009E00

[  31.360]<D>player player_get_vol, 844 leave. player = 20009E00

Current Vol:120

# 
# player volup
[  31.440]<D>player player_get_vol, 839 enter. player = 20009E00

[  31.440]<D>player player_get_vol, 844 leave. player = 20009E00

Original Vol:120
[  31.460]<D>player player_set_vol, 862 enter. player = 20009E00

[  31.470]<D>player player_set_vol, 877 leave. player = 20009E00

[  31.500]<D>player player_get_vol, 839 enter. player = 20009E00

[  31.520]<D>player player_get_vol, 844 leave. player = 20009E00

Current Vol:130

# 
# player volup
[  31.600]<D>player player_get_vol, 839 enter. player = 20009E00

[  31.600]<D>player player_get_vol, 844 leave. player = 20009E00

Original Vol:130
[  31.630]<D>player player_set_vol, 862 enter. player = 20009E00

[  31.640]<D>player player_set_vol, 877 leave. player = 20009E00

[  31.680]<D>player player_get_vol, 839 enter. player = 20009E00

[  31.690]<D>player player_get_vol, 844 leave. player = 20009E00

Current Vol:140

# 
# player volup
[  31.790]<D>player player_get_vol, 839 enter. player = 20009E00

[  31.800]<D>player player_get_vol, 844 leave. player = 20009E00

Original Vol:140
[  31.820]<D>player player_set_vol, 862 enter. player = 20009E00

[  31.820]<D>player player_set_vol, 877 leave. player = 20009E00

[  31.840]<D>player player_get_vol, 839 enter. player = 20009E00

[  31.850]<D>player player_get_vol, 844 leave. player = 20009E00

Current Vol:150

# 
# player volup
[  32.390]<D>player player_get_vol, 839 enter. player = 20009E00

[  32.390]<D>player player_get_vol, 844 leave. player = 20009E00

Original Vol:150
[  32.410]<D>player player_set_vol, 862 enter. player = 20009E00

[  32.410]<D>player player_set_vol, 877 leave. player = 20009E00

[  32.440]<D>player player_get_vol, 839 enter. player = 20009E00

[  32.440]<D>player player_get_vol, 844 leave. player = 20009E00

Current Vol:160

# 
# player volup
[  32.730]<D>player player_get_vol, 839 enter. player = 20009E00

[  32.740]<D>player player_get_vol, 844 leave. player = 20009E00

Original Vol:160
[  32.770]<D>player player_set_vol, 862 enter. player = 20009E00

[  32.770]<D>player player_set_vol, 877 leave. player = 20009E00

[  32.820]<D>player player_get_vol, 839 enter. player = 20009E00

[  32.820]<D>player player_get_vol, 844 leave. player = 20009E00

Current Vol:170

# 
# player voldown
[  38.580]<D>player player_get_vol, 839 enter. player = 20009E00

[  38.580]<D>player player_get_vol, 844 leave. player = 20009E00

Original Vol:170
[  38.600]<D>player player_set_vol, 862 enter. player = 20009E00

[  38.600]<D>player player_set_vol, 877 leave. player = 20009E00

[  38.620]<D>player player_get_vol, 839 enter. player = 20009E00

[  38.630]<D>player player_get_vol, 844 leave. player = 20009E00

Current Vol:160

# 
# player voldown
[  38.920]<D>player player_get_vol, 839 enter. player = 20009E00

[  38.920]<D>player player_get_vol, 844 leave. player = 20009E00

Original Vol:160
[  38.950]<D>player player_set_vol, 862 enter. player = 20009E00

[  38.950]<D>player player_set_vol, 877 leave. player = 20009E00

[  38.980]<D>player player_get_vol, 839 enter. player = 20009E00

[  38.980]<D>player player_get_vol, 844 leave. player = 20009E00

Current Vol:150

# 
# player voldown
[  39.270]<D>player player_get_vol, 839 enter. player = 20009E00

[  39.270]<D>player player_get_vol, 844 leave. player = 20009E00

Original Vol:150
[  39.300]<D>player player_set_vol, 862 enter. player = 20009E00

[  39.300]<D>player player_set_vol, 877 leave. player = 20009E00

[  39.350]<D>player player_get_vol, 839 enter. player = 20009E00

[  39.360]<D>player player_get_vol, 844 leave. player = 20009E00

Current Vol:140

# 
# player voldown
[  39.920]<D>player player_get_vol, 839 enter. player = 20009E00

[  39.920]<D>player player_get_vol, 844 leave. player = 20009E00

Original Vol:140
[  39.940]<D>player player_set_vol, 862 enter. player = 20009E00

[  39.960]<D>player player_set_vol, 877 leave. player = 20009E00

[  40.020]<D>player player_get_vol, 839 enter. player = 20009E00

[  40.030]<D>player player_get_vol, 844 leave. player = 20009E00

Current Vol:130

# 
# player voldown
[  40.890]<D>player player_get_vol, 839 enter. player = 20009E00

[  40.900]<D>player player_get_vol, 844 leave. player = 20009E00

Original Vol:130
[  40.920]<D>player player_set_vol, 862 enter. player = 20009E00

[  40.920]<D>player player_set_vol, 877 leave. player = 20009E00

[  40.940]<D>player player_get_vol, 839 enter. player = 20009E00

[  40.960]<D>player player_get_vol, 844 leave. player = 20009E00

Current Vol:120

# 
# player voldown
[  41.780]<D>player player_get_vol, 839 enter. player = 20009E00

[  41.780]<D>player player_get_vol, 844 leave. player = 20009E00

Original Vol:120
[  41.820]<D>player player_set_vol, 862 enter. player = 20009E00

[  41.820]<D>player player_set_vol, 877 leave. player = 20009E00

[  41.890]<D>player player_get_vol, 839 enter. player = 20009E00

[  41.890]<D>player player_get_vol, 844 leave. player = 20009E00

Current Vol:110

 

最新回复

好长的命令记录。。。   详情 回复 发表于 2022-4-27 22:40
点赞 关注
 
 

回复
举报

7504

帖子

2

TA的资源

五彩晶圆(高级)

沙发
 

好长的命令记录。。。

个人签名

默认摸鱼,再摸鱼。2022、9、28

 
 
 

回复
您需要登录后才可以回帖 登录 | 注册

随便看看
查找数据手册?

EEWorld Datasheet 技术支持

相关文章 更多>>
关闭
站长推荐上一条 1/10 下一条

 
EEWorld订阅号

 
EEWorld服务号

 
汽车开发圈

About Us 关于我们 客户服务 联系方式 器件索引 网站地图 最新更新 手机版

站点相关: 国产芯 安防电子 汽车电子 手机便携 工业控制 家用电子 医疗电子 测试测量 网络通信 物联网

北京市海淀区中关村大街18号B座15层1530室 电话:(010)82350740 邮编:100190

电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号 Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved
快速回复 返回顶部 返回列表