接上篇:https://developer.aliyun.com/article/1222367?groupCode=t-headocc
2)播放一首基于网络应用层协议的MP3音频
本例程基于YoC软件平台av组件采⽤http协议播放⼀⾸⽹络mp3歌曲。
当开发板成功通过sal(底层通过at指令连接内置的⽹卡芯⽚)连接⽹络后,可输⼊相应串⼝命令⾏从web服务器上拉取mp3歌曲实现边拉取⾳频源数据边播放的功能。开发者可基于该例程实现更为丰富的⽹络播放功能。本例程名为ch2601_webplayer_demo,可以通过CDK直接从OCC拉取。
a) 下载代码并编译运行
① 打开CDK软件,点击⼯具栏最右侧的平头哥图标,搜索找到对应的工程后点击【创建工程】。
② 在IDE上编译通过后,点击下载进⾏烧录。烧录成功后,复位运⾏。成功运⾏后,串⼝会有如何打印输出:
b) 网络连接
通过ifconfig命令可配置需要连接的热点。具体命令为:
ifconfig ap WiFi_ssid WiFi_psk
热点配置成功后,会有下图如下打印:
c) 命令行播放控制
可通过在串⼝下输⼊如下命令来控制歌曲的播放
# player help player play welcom/url[http://] #播放内置开机⾳频或⽹络歌曲 player pause #暂停播放 player resume #恢复播放 player stop #停⽌播放 player help #播放器帮助命令
播放http歌曲:
player play http://yocbook.oss-cn-hangzhou.aliyuncs.com/av_repo/alibaba.mp3,
示例如下:
player play http://yocbook.oss-cn-hangzhou.aliyuncs.com/av_repo/alibaba.mp3 # [ 13.620]<E>w800_api domain to ip: 47.110.23.146 [ 13.630]<D>sals remote_port -- : 80 [ 13.710]<D>WEB http request: GET /av_repo/alibaba.mp3 HTTP/1.0 Host: yocbook.oss-cn-hangzhou.aliyuncs.com User-Agent: CSKY/YOC [ 15.000]<D>stream upto cache threshold2,pos = 553,cache_pos = 809,diff = 256 [ 15.420]<D>avparser find a parser,name = mp3,id = 1 [ 15.440]<D>ad find a decode,name = pvmp3dec,id = 1 [ 15.450]<D>filter_swr open a avfilter,name = swr [ 15.470]<D>filter_vol open a avfilter,name = vol [ 15.470]<D>ao_alsa ao open [ 15.490]<D>ao ao ref: openref = 1,startref = 0,fun = __ao_open [ 15.510]<D>ao ori sf ==>sf = 90317074,rate = 44100,ch = 2,bits = 16 ,siged = 1,float = 0,endian = 0 [ 15.540]<D>ao ao sf ==>sf = 90316946,rate = 44100,ch = 1,bits = 16 ,siged = 1,float = 0,endian = 0 [ 15.810]<D>ao ao ref: openref = 1,startref = 1,fun = __ao_start [ 15.820]<D>player_demo =====_player_event,24,type = 2 [ 15.820]<D>player player_get_media_info,809 enter. player = 20009E00 [ 15.830]<D>player player_get_media_info,821 leave. player = 20009E00 [ 15.830]<D>player_demo =====rc = 0,duration = 415807ms,bps = 64000,si ze = 3326462
关于RVB2601开发板播放一首基于http网络应用层协议的mp3音频文件详细介绍,可以进入芯片开放社区(OCC)查看。
接下篇:https://developer.aliyun.com/article/1222364?spm=a2c6h.13148508.setting.16.5cfd4f0eUo8V8R