The method for playing music and system of intelligent sound box based on content delivery network service
Technical field
The present invention relates to intelligent sound box technical fields, and in particular to be the intelligent sound box based on content delivery network service
Method for playing music and system.
Background technique
The most important function of intelligent sound box is to play music, and intelligent sound box plays the performance (buffer speed of music at present
And stability) depend entirely on centralized server.But simple when carrying out music using centralized server,
It evitable must can suffer from the drawback that
One, the performance bottleneck as present in centralized server itself, after the quantity of intelligent sound box sharply increases, clothes
The service performance of business device is up to bottleneck, and efficiency of service is low and server load is overweight.Although can be by increasing centralization
The quantity of server improves performance bottleneck, shares the load of server.But server is more, between each server
Be in communication with each other and dispatch also more complicated, and its higher cost;
Two, centralized server may break down for some reason in the process of running.Intelligent sound box plays
If the function heavy dependence centralized server of music, all intelligence will be easily led to when centralized server occurs abnormal
Can speaker all can not normal use, and user volume is bigger, influences more serious.
CDN (Content Delivery Network) is the content distributing network constructed on network, by deployment
Node server in various regions is made user nearby or is taken by functions such as the load balance of central platform, content distribution, scheduling
Required content reduces network congestion, improves response speed and hit rate that user obtains resource.
Currently, CDN acceleration technique is mainly used in video website and webcast website, user is allowed to obtain access speed faster
Degree, and intelligent sound box is while playing music, is all to provide to support by centralized server, such as: application No. is
The Chinese invention patent of CN201510293058.4 discloses a kind of method for playing music based on intelligent sound box, this method packet
Include: intelligent sound box sends K channel tag to the terminal device connecting with intelligent sound box, and K is the integer more than or equal to 1;If
Intelligent sound box receives the music request in the broadcasting channel corresponding with channel tag W of terminal device transmission, the intelligence
Energy speaker will be sent to server obtains the music acquisition request comprising channel tag W, and channel tag W is K channel tag
Middle one selected by terminal device;The intelligent sound box receives music links address transmitted by server;Intelligent sound box root
Music is carried out according to music links address.
Above-mentioned existing patent is still simple to use a server to provide music links address for intelligent sound box to realize sound
Happy buffered play is not directed to the dependence how reduced when intelligent sound box carries out music to centralized server
And its server load, and how fast cache play the problem of.
Summary of the invention
In view of the above-mentioned problems, the invention discloses a kind of musics of intelligent sound box based on content delivery network service
Method, the method for playing music include the following steps:
S1: the id information for the song to be broadcast that intelligent sound box is uploaded based on content delivery network service is received;
S2: the id information based on above-mentioned song to be broadcast obtains the node server for being stored with song resource data to be broadcast
IP address;
S3: the IP address of above-mentioned node server is sent to intelligent sound box so that intelligent sound box is based on the node server
IP address obtains above-mentioned song resource data to be broadcast.
Further, above-mentioned steps S2 includes:
S21: the id information of song to be broadcast on judges whether there is the node serve for storing song resource data to be broadcast
Device;If so, thening follow the steps S22;If it is not, thening follow the steps S23;
S22: the IP address of the above-mentioned node server for storing song resource data to be broadcast is obtained;
S23: send chain connects the song link that acquisition request obtains song to be broadcast to centralized server;Send the song
Intelligent sound box is linked to so that intelligent sound box obtains song resource data to be broadcast by above-mentioned song link.
Further, above-mentioned steps S22 includes:
S221: obtain the network of each node server and intelligent sound box that store above-mentioned song resource data to be broadcast away from
From;
S222: the IP address of the node server nearest with the network distance of above-mentioned intelligent sound box is obtained.
Further, before above-mentioned steps S1 further include:
S01: the resource status data that each node server is reported are received and saved;
S02: according to above-mentioned resource status data, judgement in the above-mentioned closer node server of intelligent sound box network distance
Whether it is stored with and the mutually duplicate song resource data of intelligent sound box;
S03: the instruction for repeating song resource data is deleted to intelligent sound box to delete duplicate song money if so, sending
Source data.
Further, above-mentioned resource status data include: the list of songs of caching, the id information of each song and song text
Part MD5 value.
Based on a kind of method for playing music of the intelligent sound box based on content delivery network service provided by the present invention, phase
Corresponding, the present invention also provides a kind of music playing system of intelligent sound box based on content delivery network service, the music
Play system includes:
First receiving module, for receiving the ID for the song to be broadcast that intelligent sound box is uploaded based on content delivery network service
Information;
First obtains module, and for the id information based on above-mentioned song to be broadcast, acquisition is stored with song resource data to be broadcast
Node server IP address;
First sending module, for sending the IP address of above-mentioned node server to intelligent sound box so that above-mentioned intelligent sound box
IP address based on the node server obtains above-mentioned song resource data to be broadcast.
Further, above-mentioned first acquisition module includes:
First judgment module, for the id information according to above-mentioned song to be broadcast, judging whether there is storage should song be broadcast
The node server of resource data;
Second obtains module, for obtaining the IP address of the above-mentioned node server for storing song resource data to be broadcast;
Second sending module connects the song that acquisition request obtains to centralized server the song to be broadcast for send chain
Link;It is also used to send the song link to intelligent sound box so that intelligent sound box obtains song number of resources to be broadcast by song link
According to.
Further, above-mentioned second acquisition module includes:
Third obtains module, for obtaining each node server and intelligent sound that store above-mentioned song resource data to be broadcast
The network distance of case;
4th obtains module, for obtaining with the IP of the nearest node server of the network distance of above-mentioned intelligent sound box
Location.
Further, above-mentioned music playing system further include:
Second receiving module, the resource status data reported for receiving and saving each node server;
Second judgment module, for judging closer with above-mentioned intelligent sound box network distance according to above-mentioned resource status data
Node server in whether be stored with and the mutually duplicate song resource data of the intelligent sound box;
Third sending module, for send delete repeat song resource data instruction it is duplicate to delete to intelligent sound box
Song resource data.
Further, above-mentioned resource status data include: the list of songs of caching, the id information of each song and song text
Part MD5 value.
The method for playing music and system of a kind of intelligent sound box based on content delivery network service provided by the present invention,
It is using CDN acceleration technique by the mutual network associate of multiple intelligent sound boxes, each intelligent sound box that is mutually related can work as
Make a node server, it, can be by being obtained in the nearest node server of network distance in order to while playing music
The resource data of song to be broadcast is got, so as to it can be effectively reduced so that intelligent sound box fast cache plays song to be broadcast in
Property server load and improve the stability of entire music playing system;It can also break down in centralized server
In the case of, make entire music playing system still be able to operate normally, there is preferable practicability.
In addition, the resource status that method for playing music and system of the invention can also be uploaded each node server
Data carry out integration processing, the mutually duplicate song resource data stored in intelligent sound box are deleted to reach integration
The effect of duplicate removal reduces the spatial cache occupancy of intelligent sound box.
Detailed description of the invention
Fig. 1 is the method for playing music process of intelligent sound box of one of the embodiment one based on content delivery network service
Figure;
Fig. 2 is the method flow diagram of the acquisition node server IP address in embodiment one;
Fig. 3 is in embodiment one for obtaining the flow chart of node server IP address according to network distance;
Fig. 4 is the music playing system composition of intelligent sound box of one of the embodiment one based on content delivery network service
Figure;
Fig. 5 is the composition figure of the first acquisition module in embodiment one;
Fig. 6 is the composition figure of the second acquisition module in embodiment one;
Fig. 7 is the method for playing music process of intelligent sound box of one of the embodiment two based on content delivery network service
Figure;
Fig. 8 is the music playing system composition of intelligent sound box of one of the embodiment two based on content delivery network service
Figure.
Specific embodiment
In order to make the invention's purpose, features and advantages of the invention more obvious and easy to understand, below in conjunction with the present invention
Attached drawing in embodiment, technical solution in the embodiment of the present invention are purged, completely describe, it is clear that described reality
Applying example is only a part of the embodiment of the present invention, and not all embodiments.Based on the embodiments of the present invention, the common skill in this field
Art personnel every other embodiment obtained without making creative work, belongs to protection model of the invention
It encloses.
Embodiment one
Referring to Fig.1, the music for present embodiments providing a kind of intelligent sound box based on content distributing network (CDN) service is broadcast
Method is put, which specifically includes:
S1: the id information for the song to be broadcast that intelligent sound box is uploaded based on content delivery network service is received;
S2: the id information based on above-mentioned song to be broadcast obtains the node server for being stored with song resource data to be broadcast
IP address;
S3: the IP address of above-mentioned node server is sent to intelligent sound box so that intelligent sound box is based on the node server
IP address obtains above-mentioned song resource data to be broadcast.That is: intelligent sound box receives node serve transmitted by music playing system
After the IP address of device, it will send a request to that this connects node server and receiving node server fed back based on the IP address
Song resource data to be broadcast, so that buffered play should song be broadcast.
Wherein, content delivery network service (i.e. CDN service) and user cache song number of resources are provided on intelligent sound box
According to buffer area.During user plays music using intelligent sound box, if without should be in the buffer area of intelligent sound box
In the case where broadcasting song resource data, the id information of the song to be broadcast is sent to music by CDN service by intelligent sound box
System (i.e. CDN server), and then the CDN server can receive intelligent sound box and be sung by what CDN service was uploaded wait broadcast
Bent id information.
Wherein, CDN server by according to received song to be broadcast id information, obtain containing should song number of resources be broadcast
According to node server IP address.Referring to Fig. 2, for involved in step S2 " id information based on above-mentioned song to be broadcast,
Obtain be stored with song resource data to be broadcast node server IP address " detailed process include:
S21: the id information of song to be broadcast on judges whether there is the node serve for storing song resource data to be broadcast
Device;If so, thening follow the steps S22;If it is not, thening follow the steps S23;
S22: the IP address of the above-mentioned node server for storing song resource data to be broadcast is obtained;
S23: send chain connects the song link that acquisition request obtains song to be broadcast to centralized server;Send the song
Intelligent sound box is linked to so that intelligent sound box obtains song resource data to be broadcast by song link.
It should be noted that firstly, the present embodiment is by the mutual network associate of multiple intelligent sound boxes using CDN technology with shape
At a kind of distributed network, each of distributed network intelligent sound box can be used as a node server.
Secondly, there are each nodes in the distributed network established using CDN technology for the technical solution of the present embodiment
Server may the not stored situation for needing to be broadcast song data, thus, it is still necessary to be obtained by centralized server
Song resource data to be broadcast, it may be assumed that acquisition request is connect to centralized server by CDN server send chain, and passes through CDN and takes
Song link provided by centralized server is forwarded to intelligent sound box by business device, and in turn, intelligent sound box can pass through song link
The resource data of song to be broadcast is got, so as to buffered play song to be broadcast.Although music playing system (the i.e. CDN clothes
Business device) centralized server can not be replaced completely, still, in the case where node server is enough, it can be effectively reduced
To the dependence of centralized server.
Based on this, the process of above-mentioned steps S2 be can be described as:
Id information of the CDN server according to the song to be broadcast of acquisition, node server of the judgement in distributed network
In whether be stored with should the song resource data to be broadcast that matches of song id information be broadcast;It is somebody's turn to do if so, CDN server obtains
The IP address of node server, and further execute subsequent step S3;If it is not, then send chain is obtained to take and is asked by CDN server
It asks to centralized server, to get the song link of song to be broadcast by centralized server;CDN server forwarding should
To intelligent sound box, intelligent sound box will obtain song resource data to be broadcast row buffering of going forward side by side according to the song link and broadcast song link
It puts, which embodies mutual cooperation between distributed network and centralized server centered on CDN server, mutually
Scheduling, effectively increases the applicability of whole system.
Wherein, due to there may be being stored with the song resource data to be broadcast in multiple node servers, and due to not
Different from the network distance of intelligent sound box with node server, the transmission speed of resource data is not also identical, with intelligent sound
The transmission speed of the closer node server of case network distance is faster, user experience is more preferable.Based on this, referring to Fig. 3, for step
The acquisition methods of the IP address of node server involved in S22 include the following steps:
S221: obtain the network of each node server and intelligent sound box that store above-mentioned song resource data to be broadcast away from
From;
S222: the IP address of the node server nearest with the network distance of above-mentioned intelligent sound box is obtained.
That is: there are be stored in multiple node servers wait broadcast in using distributed network constructed by CDN technology
In the case where song resource data, the network distance of each node server and intelligent sound box will be got respectively;To pass through
The network distance with intelligent sound box is compared, the IP address of the node server nearest with intelligent sound box network distance is got, with
It avoids blocking in resource data transmission process, the buffering efficiency of resource data can be effectively improved.
Corresponding, the present embodiment additionally provides a kind of music playing system of intelligent sound box based on CDN service, the sound
Happy play system is CDN server, and referring to Fig. 4, which includes:
First receiving module, for receiving the ID for the song to be broadcast that intelligent sound box is uploaded based on content delivery network service
Information;
First obtains module, and for the id information based on above-mentioned song to be broadcast, acquisition is stored with song resource data to be broadcast
Node server IP address;
First sending module, for sending the IP address of above-mentioned node server to intelligent sound box so that above-mentioned intelligent sound box
IP address based on the node server obtains above-mentioned song resource data to be broadcast.
Wherein, referring to Fig. 5, which includes:
First judgment module, for the id information according to above-mentioned song to be broadcast, judging whether there is storage should song be broadcast
The node server of resource data;
Second obtains module, for obtaining the IP address of the above-mentioned node server for storing song resource data to be broadcast;
Second sending module connects the song that acquisition request obtains to centralized server the song to be broadcast for send chain
Link;It is also used to send the song link to intelligent sound box so that intelligent sound box obtains song number of resources to be broadcast by song link
According to.
Wherein, referring to Fig. 6, which includes:
Third obtains module, for obtaining each node server and intelligent sound that store above-mentioned song resource data to be broadcast
The network distance of case;
4th obtains module, for obtaining with the IP of the nearest node server of the network distance of above-mentioned intelligent sound box
Location.
The method for playing music and system of a kind of intelligent sound box based on CDN service of the mentioned offer of the present embodiment are benefits
Network associate will be carried out between multiple intelligent sound boxes with CDN technology, each intelligent sound box that is mutually related can be used as one
A node server can be by getting in order to while playing music in the nearest node server of network distance
The resource data of song to be broadcast can be effectively reduced to realize that intelligent sound box fast cache plays the effect of song to be broadcast
Property content server load and improve the stability of entire music playing system;Event can also occur in centralized server
In the case where barrier, entire music playing system is made still to be able to operate normally, there is preferable practicability.
Embodiment two
Referring to Fig. 7, a kind of method for playing music of intelligent sound box based on CDN service, the music are present embodiments provided
Playback method specifically includes:
S1: the id information for the song to be broadcast that intelligent sound box is uploaded based on content delivery network service is received;
S2: the id information based on above-mentioned song to be broadcast obtains the node server for being stored with song resource data to be broadcast
IP address;
S3: the IP address of above-mentioned node server is sent to intelligent sound box so that intelligent sound box is based on the node server
IP address obtains above-mentioned song resource data to be broadcast.That is: intelligent sound box receives node serve transmitted by music playing system
After the IP address of device, it will send a request to that this connects node server and receiving node server fed back based on the IP address
Song resource data to be broadcast, so that buffered play should song be broadcast.
Wherein, content delivery network service (i.e. CDN service) and user cache song number of resources are provided on intelligent sound box
According to buffer area.During user plays music using intelligent sound box, if without should be in the buffer area of intelligent sound box
In the case where broadcasting song resource data, the id information of the song to be broadcast is sent to music by CDN service by intelligent sound box
System (i.e. CDN server), and then the CDN server can receive intelligent sound box and be sung by what CDN service was uploaded wait broadcast
Bent id information.It should be noted that the present embodiment is by the mutual network associate of multiple intelligent sound boxes using CDN technology to be formed
A kind of distributed network, each of distributed network intelligent sound box can be used as a node server.
Wherein, it referring to Fig. 7, is further comprised the steps of: before step S1
S01: the resource status data that each node server is reported are received and saved;
S02: according to above-mentioned resource status data, judgement in the above-mentioned closer node server of intelligent sound box network distance
Whether it is stored with and the mutually duplicate song resource data of intelligent sound box;
S03: the instruction for repeating song resource data is deleted to intelligent sound box to delete duplicate song money if so, sending
Source data;If it is not, then without sending any instruction.
That is: after multiple intelligent sound boxes are carried out mutual network associate using CDN technology, each intelligent sound box
As node server, and each intelligent sound box will upload the resource status data that are stored in respective buffer area extremely
It is saved in CDN server, and the resource status data that can be uploaded according to each intelligent sound box carry out integration duplicate removal,
With find to be stored in intelligent sound box with the mutually duplicate song resource data of the closer node server of its network distance, and
It reminds intelligent sound box to delete duplicate song resource data, to reach the redundancy for reducing buffer area storage resource, it is empty to improve caching
Between availability.
Wherein, resource status data include: the list of songs of caching, the id information of each song and song files MD5 value
Deng.
Wherein, CDN server by according to received song to be broadcast id information, obtain containing should song number of resources be broadcast
According to node server IP address.Similar to implementing in one shown in Fig. 2, for involved in step S2 " based on it is above-mentioned to
Broadcast the id information of song, obtain the IP address for being stored with the node server of song resource data to be broadcast " detailed process include:
S21: the id information of song to be broadcast on judges whether there is the node serve for storing song resource data to be broadcast
Device;If so, thening follow the steps S22;If it is not, thening follow the steps S23;
S22: the IP address of the above-mentioned node server for storing song resource data to be broadcast is obtained;
S23: send chain connects the song link that acquisition request obtains song to be broadcast to centralized server;Then, it sends
The song link is to intelligent sound box so that intelligent sound box obtains song resource data to be broadcast by above-mentioned song link.
There are each node servers in the distributed network established using CDN technology for the technical solution of the present embodiment
May the not stored situation for needing to be broadcast song data, thus, it is still necessary to obtained by centralized server wait broadcast song
Bent resource data, i.e. involved in step S23: acquisition request is connect to centralized server by CDN server send chain, and
Song link provided by centralized server is forwarded to intelligent sound box by CDN server, in turn, intelligent sound box can pass through
Song link gets the resource data of song to be broadcast, so as to buffered play song to be broadcast.Although the music playing system
(i.e. CDN server) can not replace centralized server completely, still, can in the case where node server is enough
The dependence to centralized server is effectively reduced.
Based on this, the process of above-mentioned steps S2 be can be described as:
Id information of the CDN server according to the song to be broadcast of acquisition, node server of the judgement in distributed network
In whether be stored with should the song resource data to be broadcast that matches of song id information be broadcast;It is somebody's turn to do if so, CDN server obtains
The IP address of node server, and further execute subsequent step S3;If it is not, then send chain is obtained to take and is asked by CDN server
It asks to centralized server, to get the song link of song to be broadcast by centralized server;CDN server forwarding should
To intelligent sound box, intelligent sound box will obtain song resource data to be broadcast row buffering of going forward side by side according to the song link and broadcast song link
It puts, which embodies the distributed network centered on CDN server and the mutual cooperation between centralized server, phase intermodulation
Degree, effectively increases the applicability of whole system.
Wherein, due to there may be being stored with the song resource data to be broadcast in multiple node servers, and due to not
Different from the network distance of intelligent sound box with node server, the transmission speed of resource data is not also identical, with intelligent sound
The transmission speed of the closer node server of case network distance is faster, user experience is more preferable.Based on this, similar to implement one in scheme
Shown in 3, the acquisition methods of the IP address of node server involved in step S22 are included the following steps:
S221: obtain the network of each node server and intelligent sound box that store above-mentioned song resource data to be broadcast away from
From;
S222: the IP address of the node server nearest with the network distance of above-mentioned intelligent sound box is obtained.
That is: there are be stored in multiple node servers wait broadcast in using distributed network constructed by CDN technology
In the case where song resource data, the network distance of each node server and intelligent sound box will be got respectively;To pass through
The network distance with intelligent sound box is compared, the IP address of the node server nearest with intelligent sound box network distance is got, with
It avoids blocking in resource data transmission process, the buffering efficiency of resource data can be effectively improved.
Corresponding, the present embodiment additionally provides a kind of music playing system of intelligent sound box based on CDN service, the sound
Happy play system is set on intelligent sound box, and music playing system can be specially CDN server.Referring to Fig. 8, the music
System includes:
Second receiving module, the resource status data reported for receiving and saving each node server;
Second judgment module, for judging closer with above-mentioned intelligent sound box network distance according to above-mentioned resource status data
Node server in whether be stored with and the mutually duplicate song resource data of the intelligent sound box;
Third sending module, for send delete repeat song resource data instruction it is duplicate to delete to intelligent sound box
Song resource data;
First receiving module, for receiving the ID for the song to be broadcast that intelligent sound box is uploaded based on content delivery network service
Information;
First obtains module, and for the id information based on above-mentioned song to be broadcast, acquisition is stored with song resource data to be broadcast
Node server IP address;
First sending module, for sending the IP address of above-mentioned node server to intelligent sound box so that above-mentioned intelligent sound box
IP address based on the node server obtains above-mentioned song resource data to be broadcast.
Wherein, similar to shown in Fig. 5 in embodiment one, it is known that the first acquisition module specifically includes:
First judgment module, for the id information according to above-mentioned song to be broadcast, judging whether there is storage should song be broadcast
The node server of resource data;
Second obtains module, for obtaining the IP address of the above-mentioned node server for storing song resource data to be broadcast;
Second sending module connects the song that acquisition request obtains to centralized server the song to be broadcast for send chain
Link;It is also used to send the song link to intelligent sound box so that intelligent sound box obtains song number of resources to be broadcast by song link
According to.
Wherein, similar to shown in Fig. 6 in embodiment one, it is known that the second acquisition module specifically includes:
Third obtains module, for obtaining each node server and intelligent sound that store above-mentioned song resource data to be broadcast
The network distance of case;
4th obtains module, for obtaining with the IP of the nearest node server of the network distance of above-mentioned intelligent sound box
Location.
The method for playing music and system of a kind of intelligent sound box based on CDN service of the mentioned offer of the present embodiment are benefits
Network associate will be carried out between multiple intelligent sound boxes with CDN technology, each intelligent sound box that is mutually related can be used as one
A node server, in order to while playing music, the node server that intelligent sound box can be nearest by network distance
In get the resource data of song to be broadcast, to realize that fast cache plays the effect of song to be broadcast, can be effectively reduced
Property content server load and improve the stability of entire music playing system;Event can also occur in centralized server
In the case where barrier, entire music playing system is made still to be able to operate normally.
Note that the above is only a better embodiment of the present invention and the applied technical principle.It will be appreciated by those skilled in the art that
The invention is not limited to the specific embodiments described herein, be able to carry out for a person skilled in the art it is various it is apparent variation,
It readjusts and substitutes without departing from protection scope of the present invention.Therefore, although being carried out by above embodiments to the present invention
It is described in further detail, but the present invention is not limited to the above embodiments only, without departing from the inventive concept, also
It may include more other equivalent embodiments, and the scope of the invention is determined by the scope of the appended claims.