1578|0

6783

帖子

10

TA的资源

版主

【平头哥RVB2601创意应用开发】MP3播放器 [复制链接]

项目目的:1、在本地建立音乐播放服务器。

                  2、RVB2601连接路由器

                  3、播放本地的歌曲

一、用python建立自己的服务器:

      本项目用python的tornado建立音乐播放服务器:

     1、环境为python3+pycharm。具体如何安装,可自行网上找例程。因为不是本帖的重点,如果有需要可以单独联系我哈。

     服务器源码如下,就是23行,简单吧:

#!/usr/bin/env python
# -*- coding:utf-8 -*-

import os
import tornado.ioloop
import tornado.web


class MainHandler(tornado.web.RequestHandler):
    def get(self, filename):
        self.set_header('Content-Type', 'audio/mpeg')
        if os.path.exists(filename):
            with open(filename, 'rb') as f:
                while True:
                    data = f.read(1024)
                    if not data:
                        break
                    self.write(data)
            self.finish()
        else:
            self.send_error(404)


def make_app():
    return tornado.web.Application([
        (r"/(.*)", MainHandler),
    ])


if __name__ == "__main__":
    app = make_app()
    app.listen(8888)
    tornado.ioloop.IOLoop.current().start()

启动服务器后,在自己浏览器上测试:

image.png  OK可以播放了。

二、打开CDK,下载web_play例程到本地:

image.png

修一个地方,让RVB2601可以自己上网:

 大家注意一定要指定ssd 跟pwd的长度,要不死活连不上网,我因为这个弄了好久。

netmgr_config_wifi(app_netmgr_hdl, "you ssid", strlen("you ssid"), "you passwd", strlen("youpasswd"));

image.png   然后编译下载就OK了!

重启后看到连到wifi是否连上网:

image.png  然后输入播放命令:

player play http://192.168.3.192:8888/2.mp3,就可以播放音乐了:

# 
# player play http://192.168.3.192:8888/2.mp3
[  30.750]<I>player player_play, 569 enter. player = 20009E00
[  30.750]<I>player player_play, 589 leave. player = 20009E00

# [  30.770]<E>w800_api domain to ip: 192.168.3.192
[  30.780]<D>sals remote_port -- : 8888
[  30.830]<D>WEB http request: 
GET /2.mp3 HTTP/1.0
Host: 192.168.3.192
User-Agent: CSKY/YOC



[  30.850]<D>w800_api w800 start send(66)(time:9990)

[  30.900]<D>w800_api w800 end send(ret:0)

[  30.940]<D>WEB http response: 
HTTP/1.1 200 OK
Server: TornadoServer/6.1
Content-Type: audio/mpeg
Date: Mon, 07 Mar 2022 06:11:03 GMT
Etag: "3e06b56eb9eb7b72ea7e393f069e6e17e48d968e"
Content-Length: 3906290


[  30.980]<D>stream upto cache threshold1, pos =          0, cache_pos =        256, diff = 256
[  31.410]<D>demux id3v2 size = 45
[  31.420]<D>demux_mp3 mp3 probe, sync_cnt = 0, rc = 0, score = 100
[  31.440]<I>demux find a demux, name = mp3, url = http://192.168.3.192:8888/2.mp3
[  31.460]<D>stream scache task quit
[  31.500]<D>w800_api socket[0] closed

[  31.520]<E>w800_api domain to ip: 192.168.3.192
[  31.530]<D>sals remote_port -- : 8888
[  31.570]<D>WEB http request: 
GET /2.mp3 HTTP/1.0
Host: 192.168.3.192
User-Agent: CSKY/YOC
Range: bytes=45-



[  31.590]<D>w800_api w800 start send(84)(time:9990)

[  31.640]<D>w800_api w800 end send(ret:0)

[  31.700]<D>WEB http response: 
HTTP/1.1 200 OK
Server: TornadoServer/6.1
Content-Type: audio/mpeg
Date: Mon, 07 Mar 2022 06:11:04 GMT
Etag: "3e06b56eb9eb7b72ea7e393f069e6e17e48d968e"
Content-Length: 3906290


[  31.750]<D>stream upto cache threshold2, pos =         45, cache_pos =        301, diff = 256
[  32.180]<D>avparser find a parser, name = mp3, id = 1
[  32.190]<I>ad find a decode, name = pvmp3dec, id = 1
[  32.210]<D>filter_swr open a avfilter, name = swr
[  32.210]<D>filter_vol open a avfilter, name = vol
[  32.230]<D>ao_alsa  ao open
[  32.230]<D>ao ao ref: openref =  1, startref =  0, fun = __ao_open
[  32.250]<D>ao ori sf ==> sf = 90317074, rate = 44100, ch = 2, bits = 16, siged = 1, float = 0, endian = 0
[  32.270]<D>ao ao  sf ==> sf = 90316946, rate = 44100, ch = 1, bits = 16, siged = 1, float = 0, endian = 0
[  32.550]<D>ao ao ref: openref =  1, startref =  1, fun = __ao_start
[  32.550]<D>player_demo =====_player_event, 24, type = 2
[  32.560]<D>player player_get_media_info, 809 enter. player = 20009E00
[  32.560]<D>player player_get_media_info, 821 leave. player = 20009E00
[  32.570]<D>player_demo =====rc = 0, duration = 244143ms, bps = 128000, size = 3906290
[  32.580]<I>player first frame output
[  60.090]<D>stream upto cache threshold2, pos =     427053, cache_pos =     427221, diff = 168
[  60.100]<D>player_demo =====_player_event, 24, type = 4
[  61.420]<D>player_demo =====_player_event, 24, type = 5

重新输入另一首歌:

# player play http://192.168.3.192:8888/adibaba.mp3
[ 340.400]<I>player player_play, 569 enter. player = 20009E00
[ 340.400]<I>player player_play, 589 leave. player = 20009E00

# [ 340.420]<E>w800_api domain to ip: 192.168.3.192
[ 340.430]<D>sals remote_port -- : 8888
[ 340.490]<D>WEB http request: 
GET /adibaba.mp3 HTTP/1.0
Host: 192.168.3.192
User-Agent: CSKY/YOC



[ 340.510]<D>w800_api w800 start send(72)(time:9990)

[ 340.560]<D>w800_api w800 end send(ret:0)

[ 340.590]<D>WEB http response: 
HTTP/1.1 200 OK
Server: TornadoServer/6.1
Content-Type: audio/mpeg
Date: Mon, 07 Mar 2022 06:16:13 GMT
Etag: "1838326b7dc752f8d66521975cd58ab8eed6b5bf"
Content-Length: 2817069


[ 340.620]<D>stream upto cache threshold1, pos =          0, cache_pos =        256, diff = 256
[ 341.150]<D>demux id3v2 size = 45
[ 341.160]<D>demux_mp3 mp3 probe, sync_cnt = 0, rc = 0, score = 100
[ 341.180]<I>demux find a demux, name = mp3, url = http://192.168.3.192:8888/adibaba.mp3
[ 341.190]<D>stream cache task break. wlen = 0, status = 0, reof = 1
[ 341.200]<D>stream scache task quit
[ 341.260]<D>w800_api socket[0] closed

[ 341.280]<E>w800_api domain to ip: 192.168.3.192
[ 341.290]<D>sals remote_port -- : 8888
[ 341.330]<D>WEB http request: 
GET /adibaba.mp3 HTTP/1.0
Host: 192.168.3.192
User-Agent: CSKY/YOC
Range: bytes=45-



[ 341.350]<D>w800_api w800 start send(90)(time:9990)

[ 341.410]<D>w800_api w800 end send(ret:0)

[ 341.450]<D>WEB http response: 
HTTP/1.1 200 OK
Server: TornadoServer/6.1
Content-Type: audio/mpeg
Date: Mon, 07 Mar 2022 06:16:14 GMT
Etag: "1838326b7dc752f8d66521975cd58ab8eed6b5bf"
Content-Length: 2817069


[ 341.490]<D>stream upto cache threshold2, pos =         45, cache_pos =        301, diff = 256
[ 341.910]<D>avparser find a parser, name = mp3, id = 1
[ 341.920]<I>ad find a decode, name = pvmp3dec, id = 1
[ 341.940]<D>filter_swr open a avfilter, name = swr
[ 341.950]<D>filter_vol open a avfilter, name = vol
[ 341.960]<D>ao_alsa  ao open
[ 341.970]<D>ao ao ref: openref =  1, startref =  0, fun = __ao_open
[ 341.980]<D>ao ori sf ==> sf = 98304274, rate = 48000, ch = 2, bits = 16, siged = 1, float = 0, endian = 0
[ 341.990]<D>ao ao  sf ==> sf = 98304146, rate = 48000, ch = 1, bits = 16, siged = 1, float = 0, endian = 0
[ 342.280]<D>ao ao ref: openref =  1, startref =  1, fun = __ao_start
[ 342.280]<D>player_demo =====_player_event, 24, type = 2
[ 342.290]<D>player player_get_media_info, 809 enter. player = 20009E00
[ 342.290]<D>player player_get_media_info, 821 leave. player = 20009E00
[ 342.300]<D>player_demo =====rc = 0, duration = 176066ms, bps = 128000, size = 2817069
[ 342.310]<I>player first frame output

如果加上几个按键,就可以实现播放、停止、下一首了。

但是就是这喇叭的功率太了,大家要用缓冲的垫一下,把翻过来听,要不如果正面放,到低音时会有杂音。

总的来说,RVB是功能是非常强大的,还有很多的东西需要不断的去学习,在这里非常感谢坛友们,我是从他们的作品中学习到如何使用RVB2601。期待大家共同进步。


 

 


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

随便看看
查找数据手册?

EEWorld Datasheet 技术支持

相关文章 更多>>
推荐帖子
路由器内存技术深度解密

 在今天发达的网络世界里,每个路由器就好像一个邮局,对网络上的信息进行分类与整合,将它们按照地址传输到目的地。路由器已经 ...

空调风扇控制板

功能特点: 操作面板上共有6个轻触(功能)开关,分别为"开关"(电源)、"定时"、"风速"、"制冷""加热"、"摆叶"、等。在工作状态 ...

一个ARM7的手册,全部的语言格式和用法

一个ARM7的手册,全部的语言格式和用法

移植好的ucos2工程(基于LPC2000和Keil MDK)

欢迎大家提意见,谢谢!!

洗牌的时刻

社会的发展总是曲折和跳跃性的,商业社会也一样,跳跃之前的情形如同一堆于没洗的牌,在此时刻,多数人都不能把握,甚至意识到这 ...

阅读打卡终点站: 可伸缩矢量、虚拟化扩展——《RISC-V体系结构编程与实践 》

活动详情:一起围读《RISC-V体系结构编程与实践 》 本次是《RISC-V体系结构编程与实践 》阅读打卡终点站,跟帖回复作者提出以 ...

影响电源寿命器件,还是要知道一下

电源寿命是衡量电源系统可靠性和耐久性的重要指标。在电源中,有几个关键的元件直接影响着电源的寿命。了解这些元件及其影响因素 ...

变频器的电流源模式?

无意中看到的国产某变频器的一项功能,电流源模式,可以分别针对异步电机和同步电机的空载电流和额定电流按照设定输出设定的电流 ...

通过物联网管理多台MQTT设备-基于米尔T527开发板

本篇测评由电子工程世界的优秀测评者“JerryZhen”提供。 本文将介绍基于米尔电子MYD-LT527开发板的网关方案测试 ...

【收藏学习】人工智能入门必读经典,适合新手!

如果你对人工智能感兴趣,亦或打算从事人工智能方面的工作,掌握一门新技术,却不知如何快速入门,EEWorld热心网友特此收集整理 ...

关闭
站长推荐上一条 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
快速回复 返回顶部 返回列表