1639 views|0 replies

6818

Posts

11

Resources
The OP
 

[RVB2601 Creative Application Development] MP3 Player [Copy link]

 

Project purpose: 1. Establish a music playback server locally.

2. RVB2601 connected to router

3. Play local songs

1. Use Python to build your own server:

This project uses Python's Tornado to build a music playback server:

1. The environment is python3+pycharm. For specific installation instructions, you can find examples online. Because it is not the focus of this post, you can contact me separately if you need it.

The server source code is as follows, which is 23 lines. It's simple:

#!/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()

After starting the server, test it on your browser:

OK, it can be played.

2. Open CDK and download the web_play example to your local computer:

Fix a place so that RVB2601 can access the Internet by itself:

Please note that you must specify the length of ssd and pwd, otherwise you will not be able to connect to the Internet. I struggled with this for a long time.

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

Then compile and download it!

After restarting, check whether the wifi is connected to the Internet:

Then enter the play command:

player play http://192.168.3.192:8888/2.mp3, you can play the music:

# 
# 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

Re-enter another song:

# 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

If you add a few buttons, you can play, stop, and click the next song.

But the power of this speaker is too great, so you need to use a cushion and turn it over to listen. Otherwise, if you put it front-on, there will be noise when the bass is played.

In general, RVB is very powerful, and there are still many things to learn. I would like to thank the forum friends here. I learned how to use RVB2601 from their works. I look forward to everyone's common progress.


image.png (109.97 KB, downloads: 0)

image.png
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Featured Posts
C language uses binary tree to parse polynomials and evaluate

It mainly realizes the analysis of polynomial data calculation. If there is a need to make a simple calculator based on ...

STM8S001J3 uses HalfDuplex mode and uses IO mapping and cannot receive data.

The first time I used STM8S001J3, I mainly used UART and EEPROM. At that time, I saw that UART_TX conflicted with SWIM, ...

The disappearing boundary between MCU and MPU

There was a time when microprocessors (MPUs) and microcontrollers (MCUs) were two completely different devices. Microcon ...

Relationship between PN conduction voltage drop and current and temperature

*) , the E junction is affected by temperature, and the change in on-state voltage drop is related to Is and Ic The cond ...

Free Review - Topmicro Intelligent Display Module (5) Touch Screen

This post was last edited by wenyangzeng on 2021-11-1 16:36 Free Review - Topmicro Intelligent Display Module (5) Touch ...

View circuit - load switch

In many circuits, one power supply may correspond to multiple loads. Sometimes the power supply of the load needs to be ...

[Flower carving DIY] Interesting and fun music visualization series project (24) - infinite LED mirror light

I suddenly had the urge to do a series of topics on music visualization. This topic is a bit difficult and covers a wide ...

Common Problems in RF Circuit Design

666836 Common problems in RF circuit design 1. Interference between digital circuit modules and analog circuit modules ...

M4N-Dock basic usage environment configuration

# M4N-Dock basic usage environment configuration## Login system The default system is Debian system. Plug in the network ...

The price came out and I looked at it for more than an hour.

21.59 Did you guess it right?

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list