CN111222004A - Audio playing method, terminal equipment and vehicle - Google Patents

Audio playing method, terminal equipment and vehicle Download PDF

Info

Publication number
CN111222004A
CN111222004A CN202010019318.XA CN202010019318A CN111222004A CN 111222004 A CN111222004 A CN 111222004A CN 202010019318 A CN202010019318 A CN 202010019318A CN 111222004 A CN111222004 A CN 111222004A
Authority
CN
China
Prior art keywords
local
song
cache
audio file
target song
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202010019318.XA
Other languages
Chinese (zh)
Other versions
CN111222004B (en
Inventor
雷海波
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guangzhou Xiaopeng Motors Technology Co Ltd
Original Assignee
Guangzhou Xiaopeng Motors Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Guangzhou Xiaopeng Motors Technology Co Ltd filed Critical Guangzhou Xiaopeng Motors Technology Co Ltd
Priority to CN202010019318.XA priority Critical patent/CN111222004B/en
Publication of CN111222004A publication Critical patent/CN111222004A/en
Application granted granted Critical
Publication of CN111222004B publication Critical patent/CN111222004B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/60Information retrieval; Database structures therefor; File system structures therefor of audio data
    • G06F16/63Querying
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/955Retrieval from the web using information identifiers, e.g. uniform resource locators [URL]
    • G06F16/9566URL specific, e.g. using aliases, detecting broken or misspelled links
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/957Browsing optimisation, e.g. caching or content distillation
    • G06F16/9574Browsing optimisation, e.g. caching or content distillation of access to content, e.g. by caching

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Multimedia (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

An audio playing method, terminal equipment and a vehicle are provided, and the method comprises the following steps: when a target song is played, inquiring a local audio file of the target song in a local cache; the local audio file comprises a plurality of cache blocks, and the cache blocks comprise audio data downloaded from a server when the target song is played last time; if the local audio file has the missing cache block, downloading audio data corresponding to the missing cache block from the server; storing the audio data corresponding to the missing cache block into a local audio file of the target song; and playing a local audio file of the target song. By implementing the embodiment of the invention, the flow consumption during music playing can be reduced.

Description

Audio playing method, terminal equipment and vehicle
Technical Field
The invention relates to the technical field of audio playing, in particular to an audio playing method, terminal equipment and a vehicle.
Background
Currently, there may be two types of songs played by an audio player: the audio files of the songs are stored in local songs; alternatively, the audio files of the songs are stored on-line songs at the server.
When a certain online song is played, whether a local audio file of the song is stored in a local cache is generally inquired firstly; if the online song is stored, the local audio file of the online song stored in the local cache is directly used, and the audio data does not need to be requested from the server again, so that the flow can be saved. Referring to fig. 1, fig. 1 is a diagram illustrating an example of a playing process of audio playing. As shown in fig. 1, in the local cache, a Uniform Resource Locator (URL) link of a song is generally used as a cache Key (Key). When a certain song is played, firstly, whether a local audio file of the song is stored in a local cache is searched through the URL of the song; if yes, directly playing the local audio file; if not, the audio data is requested to the server through the network based on the URL link.
However, in practice it has been found that the granularity of multiplexing of local audio files stored in a local cache is typically the entire song. If a song only downloads a part of the song when being cached at a certain time, when the song needs to be played again, the audio player can request the audio data from the server again, which causes repeated downloading of part of the audio data and wastes traffic resources.
Disclosure of Invention
The embodiment of the invention discloses an audio playing method, terminal equipment and a vehicle, which can reduce the flow consumption when music is played.
The first aspect of the embodiments of the present invention discloses an audio playing method, where the method includes:
when a target song is played, inquiring a local audio file of the target song in a local cache; the local audio file comprises a plurality of cache blocks, and the cache blocks comprise audio data downloaded from a server when the target song is played last time;
if the local audio file has the missing cache block, downloading audio data corresponding to the missing cache block from the server;
storing the audio data corresponding to the missing cache block into a local audio file of the target song;
and playing a local audio file of the target song.
As an optional implementation manner, in the first aspect of the embodiment of the present invention, when a target song is played, querying a local audio file of the target song in a local cache includes:
when a target song is played, searching a local audio file of the target song stored in the local cache by taking the song number of the target song as a cache key;
wherein the song number is identified from a first URL of the target song; the first URL is provided by the server.
As an optional implementation manner, in the first aspect of the embodiment of the present invention, if there is a missing cache block in the local audio file, the requesting, from the server, to download audio data corresponding to the missing cache block includes:
and if the local audio file has the missing cache block, constructing a second URL of the target song according to the song number, and requesting the server to download the audio data corresponding to the missing cache block by taking the second URL as a basis.
As an optional implementation manner, in the first aspect of the embodiment of the present invention, a data amount of a single cache block is smaller than a preset data amount threshold.
As an optional implementation manner, in the first aspect of this embodiment of the present invention, the method further includes:
when the local cache is cleaned, determining the song with the least number of accessed times from a plurality of songs stored in the local cache, and deleting the local audio file corresponding to the song with the least number of accessed times from the local cache.
A second aspect of an embodiment of the present invention discloses a terminal device, including: the query unit is used for querying a local audio file of a target song in a local cache when the target song is played; the local audio file comprises a plurality of cache blocks, and the cache blocks comprise audio data downloaded from a server when the target song is played last time;
the downloading unit is used for downloading the audio data corresponding to the missing cache blocks from the server when the local audio file has the missing cache blocks;
the storage unit is used for storing the audio data corresponding to the missing cache block into a local audio file of the target song;
and the playing unit is used for playing the local audio file of the target song.
As an alternative implementation, in the second aspect of the embodiment of the present invention:
the query unit is specifically configured to search a local audio file of a target song stored in the local cache by using a song number of the target song as a cache key when the target song is played;
wherein the song number is identified from a first URL of the target song; the first URL is provided by the server.
As an alternative implementation, in the second aspect of the embodiment of the present invention:
the downloading unit is specifically configured to, when the local audio file has the missing cache block, construct a second URL of the target song according to the song number, and request the server to download the audio data corresponding to the missing cache block according to the second URL.
As an optional implementation manner, in a second aspect of the embodiment of the present invention, the terminal device further includes:
and the cleaning unit is used for determining the song with the least accessed times from a plurality of songs stored in the local cache when the local cache is cleaned, and deleting the local audio file corresponding to the song with the least accessed times from the local cache.
A third aspect of the embodiments of the present invention discloses a vehicle including any one of the terminal devices disclosed in the second aspect of the embodiments of the present invention.
A fourth aspect of the present embodiments discloses a computer-readable storage medium storing a computer program, where the computer program causes a computer to execute any one of the methods disclosed in the first aspect of the present embodiments.
A fifth aspect of the embodiments of the present invention discloses a computer program product, which, when running on a computer, causes the computer to execute any one of the methods disclosed in the first aspect of the embodiments of the present invention.
Compared with the prior art, the embodiment of the invention has the following beneficial effects:
and storing the audio data of the target song in a blocking cache mode when the target song is played. When the target song is played again, even if the target song is not completely cached, the downloaded part stored in the form of the cache block can be multiplexed, and only the part which is not downloaded is requested to be downloaded to the server, so that the flow consumption when the music is played can be reduced.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the embodiments will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art that other drawings can be obtained according to these drawings without creative efforts.
Fig. 1 is a diagram illustrating an example of a playing process of audio playing according to an embodiment of the present invention;
FIG. 2 is a diagram illustrating an exemplary data structure of a local audio file according to an embodiment of the present invention;
fig. 3 is a schematic flowchart of an audio playing method according to an embodiment of the present invention;
FIG. 4 is a diagram illustrating another example of playing audio according to an embodiment of the present invention;
FIG. 5 is a diagram illustrating an exemplary LRU eviction mechanism according to an embodiment of the disclosure;
fig. 6 is a schematic structural diagram of a terminal device disclosed in the embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
It is to be noted that the terms "comprises" and "comprising" and any variations thereof in the embodiments and drawings of the present invention are intended to cover non-exclusive inclusions. For example, a process, method, system, article, or apparatus that comprises a list of steps or elements is not limited to only those steps or elements listed, but may alternatively include other steps or elements not listed, or inherent to such process, method, article, or apparatus.
The embodiment of the invention discloses an audio playing method, terminal equipment and a vehicle, which can reduce the flow consumption during music playing. The following are detailed below.
In order to better describe the audio playing method disclosed in the embodiment of the present invention, first, a data structure of a local audio file stored in a local cache in the embodiment of the present invention is described below. Referring to fig. 2, fig. 2 is a diagram illustrating an example of a data structure of a local audio file according to an embodiment of the present invention. As shown in fig. 2, each song may correspond to a local audio file, each local audio file may include a plurality of cache blocks, each cache block includes audio data downloaded from the server when the song was played last time, and each cache block corresponds to an offset of the cache block in the local cache, length information of the cache block, and a playing order of the audio data corresponding to the cache block in the whole song.
Alternatively, these cache blocks may be managed by unifying a song number (ID) provided by an operator of the song, that is, the song ID may be set as a cache Key (Key). Optionally, the offset corresponding to each cache block may be used to represent a playing order, and the storage locations of the cache blocks in the local cache may be arranged according to the playing order. Furthermore, the data size of a single cache block may be limited. For example, the data amount of a single cache block may be limited to 2M or less.
In an embodiment of the present invention, the song ID may be read from a Uniform Resource Locator (URL) provided by a server. Illustratively, link "http:// music.163. com/#/song? in ID 1461754 ", the song ID is" 1461754 ". Most operators will set a hash value of an online audio file in which an online song is stored in a server as a song ID, and attach the song ID to a suffix of a URL. The validity period of such song ID is long compared to URL links that change frequently for copyright reasons. Therefore, if the song ID is used as the cache Key, even if the URL link of the song changes due to copyright problem, the cache Key is relatively stable, so that the query of the local audio file stored in the local cache can be free from the influence of URL link failure, the local audio file can still be accessed and used, and the validity period of the local audio file can be further prolonged.
It can be understood that the plurality of cache blocks included in the local audio file may completely cover the whole song, or may be missing; alternatively, the local audio file may include several cache blocks that are contiguous or non-contiguous. Missing cache blocks or non-contiguous cache blocks may be the result of a user changing the playing progress. For example, as shown in FIG. 2, the song with ID1 includes buffer blocks that are complete and contiguous, whereas the songs with ID2 and ID3 include buffer blocks that are missing, and the song with ID2 includes buffer blocks that are not contiguous. When the song with the ID2 lacks the buffer block p2, which may be caused by dragging the playing progress from the playing time point corresponding to the buffer block of p1 to the time point corresponding to the buffer block of p3 when the song with the ID2 is played before. The song with ID2 missing the buffer block p3 may be caused by the user stopping playing or switching to play another song if the song with ID3 is not played out when the song with ID3 was played before.
In addition, several cache blocks included in the local audio file may be cached in the same play operation or may be cached in different play operations.
Based on the data structure of the local audio file as shown in fig. 2, the following describes in detail the audio playing method, the terminal device, and the vehicle disclosed in the embodiment of the present invention.
Example one
Referring to fig. 3, fig. 3 is a schematic flowchart illustrating an audio playing method according to an embodiment of the present invention. As shown in fig. 3, the audio playing method may include the steps of:
301. when the target song is played for the first time, downloading the audio data of the target song from the server, and storing the downloaded audio data of the target song to a local cache in the form of a plurality of cache blocks to obtain a local audio file of the target song.
In the embodiment of the present invention, the URL link of the target song or the song ID of the target song may be used as the cache Key.
If the song ID of the target song is adopted, the data structure of the local audio file of the target song may be as shown in fig. 2, and the embodiment of saving the downloaded audio data of the target song to the local cache in the form of a plurality of cache blocks to obtain the local audio file of the target song may include:
a song ID contained in a first URL of the target song; the first URL may be a URL address corresponding to a playing page of the target song provided by the server;
the method comprises the steps of obtaining audio data of a downloaded target song, packing the currently downloaded audio data into a cache block if the data size of the currently downloaded audio data exceeds a preset data size threshold, recording the offset of the cache block in a local cache, the length of the cache block and the playing sequence of the audio data corresponding to the cache block in the whole song, and registering the corresponding relation between the cache block and the song ID of the target song. By implementing the implementation mode, the block cache of the audio data can be realized, and the song ID is used as the cache Key, so that the multiplexing rate of the audio data in the local cache can be improved, and the validity period of the local audio file can be prolonged.
Further alternatively, the correspondence of the cache block and the song ID may be registered in an encrypted file to prevent the correspondence from being broken.
302. When the target song is played again, the local audio file of the target song is queried in the local cache.
In this embodiment of the present invention, if the song ID is the cache Key of the local cache, as an optional implementation, the implementation of querying the local audio file of the target song in the local cache may include:
and searching the local audio file of the target song stored in the local cache by taking the song ID of the target song as a cache key.
Wherein the song ID of the target song may be identified from the first URL described above.
303. Judging whether the local audio file has missing cache blocks; if yes, go to step 304; if not, go to step 305.
In the embodiment of the invention, when the target song is played again, the audio data range requested to be played at this time is provided. Whether a plurality of cache blocks included in the local audio file completely cover the audio data range requested to be played can be judged according to the offset and the length information corresponding to each cache block included in the local audio file, if yes, it can be determined that the local audio file does not have a missing cache block, and step 305 is executed; if not, it may be determined that the local audio file has missing cache blocks, step 306 is performed, and an audio data range corresponding to the missing cache blocks may be determined.
304. And downloading the audio data corresponding to the missing cache block from the server, and storing the audio data corresponding to the missing cache block into a local audio file of the target song.
In the embodiment of the present invention, if the cache Key is the song ID, when audio data corresponding to a missing cache block is downloaded, a downloaded URL address needs to be acquired first. Accordingly, embodiments of step 304 may include, but are not limited to:
and constructing a second URL of the target song according to the song ID of the target song, requesting to download the audio data corresponding to the missing cache block from the server by taking the second URL as a basis, and storing the audio data corresponding to the missing cache block into a local audio file of the target song.
In the embodiment of the present invention, the second URL is constructed according to the song ID of the target song, and the second URL may be constructed as a resource download address of the audio data according to the URL naming rule of the song operator. For example, the first URL is "http:// music.163. com/#/song? And id 1461754 ", the second URL constructed may be" http:// music.163. com/song/media/outer/URL? id 1461754.mp3 ". By implementing the implementation mode, the download address of the audio data can be directly reached, the jumping times are reduced, and the constructed URL link is relatively stable. It is understood that the first URL and the second URL may be different or the same.
In the embodiment of the present invention, when requesting the server for downloading resources of a target song, an audio data range corresponding to a missing cache block may be sent to the server.
Referring to fig. 4, fig. 4 is a diagram illustrating another example of an audio playing process according to an embodiment of the present invention. As shown in fig. 4, if the target song is a song with ID2, the local music file stored in the local cache can be accessed as the cache Key through ID3, and the song with ID3 has cache block p1 (data range: 000 and 199) and cache block p2(200 and 499) in the local cache. And the audio data range of the target song requested to be played at this time is 0-799, then the server is requested to download the audio data of the target song, and the downloaded data range is 500-799. When the downloading of the audio data of the target song is requested to the server, a second URL link (URL1) is generated according to the ID3, and the downloading of the audio data of the server is requested according to the URL 1. As can be seen, for the playing operation, the data sources may include the following:
local cache data 1: 000-; local cache data 2: 200-; network resource data 3: 500-799.
The above-described network resource data 3 may be stored in the local cache as a new cache block p3, and the cache Key of the cache block p3 is ID 2. That is, the buffer block p3 is stored into the local audio file of the song of ID 3.
305. A local audio file of the target song is played.
In the embodiment of the present invention, the audio data corresponding to the plurality of cache blocks included in the local audio file of the target song may be read in the playing order, so as to play the target song. It will be appreciated that step 305 need not necessarily be performed after the missing audio data has been downloaded. For example, when a play operation for a target song is detected, the cache block p1 and the cache block p2 are queried according to the song ID (ID3) of the target song, then the cache blocks p1 and p2 are loaded to a play process, and a play operation is first performed on data corresponding to the cache block p 1; in the process of playing the audio data corresponding to the buffer block p1, the audio data of the buffer block p3 is requested to be downloaded to the server based on the second URL. That is, embodiments of step 306 may include, but are not limited to:
when a plurality of cache blocks included in a local audio file of a target song are inquired, loading audio data corresponding to the cache blocks included in the local audio file into a playing process according to a playing sequence;
when audio data corresponding to the missing cache blocks are downloaded, loading the audio data corresponding to the missing cache blocks into a playing process according to a playing sequence;
and playing the audio data in the playing process according to the playing sequence.
By implementing the embodiment, the operation of caching while broadcasting can be realized.
306. When the local cache needs to be cleaned, determining the song with the least number of accessed times from a plurality of songs stored in the local cache, and deleting the local audio file corresponding to the song with the least number of accessed times from the local cache.
In the embodiment of the invention, the local cache can be cleaned regularly due to the limited space of the local cache. When the local cache needs to be cleaned, the local audio file corresponding to the song with the Least number of accesses can be deleted from the local cache, that is, a Least Recently Used (LRU) elimination mechanism is adopted:
establishing a linked list containing song IDs of all songs; optionally, the capacity of the linked list may correspond to the maximum space that the local cache may occupy, that is, when the linked list is full, the local cache may be cleaned;
when a new song which is not contained in a chain table is cached, inserting the song ID of the new song into the head of the chain table;
moving the song ID of the played song to the head of the linked list when the local audio file corresponding to the song contained in the linked list is accessed (namely the song is played);
and when the space of the linked list is full, deleting the local audio file corresponding to the song ID at the tail part of the linked list from the local cache, and deleting the song ID at the tail part of the linked list from the linked list.
For example, referring to fig. 5, fig. 5 is a diagram illustrating an LRU eviction mechanism according to an embodiment of the present invention.
By implementing the LRU eviction mechanism, the local cache can be cleaned up in a limited disk space, and popular songs played frequently by the user can be stored in the local cache as long as possible. Compared with a local cache cleaning mode for deleting the earliest cached song, the LRU elimination mechanism can reduce the frequency of requesting the server to download the audio data, thereby further saving the flow.
Illustratively, the method described in fig. 3 may be implemented on a smart car machine of a vehicle and the song ID is used as a cache key for the local cache. Through practical statistics, after the method described in fig. 3 is implemented, the daily average consumption traffic of music played by the smart car machine can be reduced from 110M to 28M, and the traffic consumption can be greatly reduced.
It can be seen that, in the method described in fig. 3, when a target song is played, first, whether a cache block of the target song is stored in a local cache is queried, and the existing cache block is preferentially called to play; and requesting the server to download the audio data according to the missing cache block in the local cache, so that the data volume of the audio data downloaded from the server can be reduced, and even if the complete audio data of the target song is not stored in the local cache, part of the audio data stored in the local cache can be multiplexed. Furthermore, the song ID is used as the cache Key, so that the validity period of the local audio file can be prolonged, and the flow is further saved. In addition, the local cache is cleaned by adopting an LRU elimination mechanism, so that popular songs frequently played by a user can be stored in the local cache as long as possible, the repeated downloading times of the popular songs are reduced, and the flow can be further saved.
Example two
Referring to fig. 6, fig. 6 is a schematic structural diagram of a terminal device according to an embodiment of the present invention. As shown in fig. 6, the terminal device may include:
the query unit 601 is configured to query a local audio file of a target song in a local cache when the target song is played; the local audio file comprises a plurality of cache blocks, and each cache block comprises audio data downloaded from the server when the target song is played last time;
in the embodiment of the present invention, the data structure of the local audio file of the target song may be as shown in fig. 2, and details are not described below.
As an optional implementation manner, the querying unit 601 may be specifically configured to, when a target song is played, look up a local audio file of the target song stored in a local cache by using a song ID of the target song as a cache key; wherein the song ID is identified from a first URL of the target song; the first URL is provided by the server.
In addition, further optionally, the query unit 601 may determine, according to the offset and the length information corresponding to each cache block of the target song, whether a plurality of cache blocks included in the local audio file completely cover the audio data range of the target song requested to be played this time; if yes, determining that the local audio file has no missing cache block; if not, determining that the local audio file has missing cache blocks, and determining an audio data range corresponding to the missing cache blocks.
A downloading unit 602, configured to download, when a local audio file has a missing cache block, audio data corresponding to the missing cache block from a server;
as an optional implementation manner, the downloading unit 602 may be specifically configured to, when there is a missing cache block in the local audio file, construct a second URL of the target song according to the song ID, and request the server to download the audio data corresponding to the missing cache block according to the second URL. It is understood that the downloading unit 602 may send the audio data range corresponding to the missing cache block to the server when requesting the downloading resource of the target song from the server.
A storage unit 603, configured to store audio data corresponding to the missing cache block into a local audio file of the target song;
a playing unit 604, configured to play a local audio file of the target song. The playing unit 604 may be specifically configured to, when a plurality of cache blocks included in a local audio file of a target song are found, load audio data corresponding to the cache blocks included in the local audio file into a playing process according to a playing sequence; when the audio data corresponding to the missing cache blocks are downloaded, loading the audio data corresponding to the missing cache blocks into a playing process according to a playing sequence; and playing the audio data in the playing process according to the playing sequence, thereby realizing playing while caching.
Optionally, the terminal device shown in fig. 6 may further include:
a cleaning unit 605, configured to determine, when cleaning the local cache, a song with the fewest number of accesses from among the songs stored in the local cache, and delete, from the local cache, a local audio file corresponding to the song with the fewest number of accesses.
As an optional implementation manner, the cleaning unit 605 may be specifically configured to establish a linked list including song IDs of each song; when a new song which is not contained in a chain table is cached, inserting the song ID of the new song into the head of the chain table; every time the playing unit 604 plays a certain song contained in the linked list, the song ID of the played song is moved to the head of the linked list; and when the space of the linked list is full, deleting the local audio file corresponding to the song ID at the tail part of the linked list from the local cache, and deleting the song ID at the tail part of the linked list from the linked list. By implementing the implementation mode, the songs with the least playing times can be deleted through the LRU elimination mechanism, and the popular songs played frequently by the user are reserved.
It is understood that, in the embodiment of the present invention, the terminal device shown in fig. 6 may include, but is not limited to, a smart car machine, an on-board computer, a smart phone, and a smart tablet.
Implementing the terminal device shown in fig. 6, the song ID can be identified from the URL as the cache Key of the local cache, so as to extend the validity period of the local audio file; the local audio file can be divided into a plurality of cache blocks, so that the reuse degree of cache is improved, and the flow consumption is reduced; furthermore, the local cache can be cleaned through an LRU elimination mechanism, so that popular songs can be stored in the local cache as long as possible, and the flow is further saved.
An embodiment of the present invention discloses a computer-readable storage medium storing a computer program, wherein the computer program enables a computer to execute the audio playing method shown in fig. 3.
An embodiment of the present invention discloses a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program, and the computer program is operable to cause a computer to execute the audio playing method shown in fig. 3.
It should be appreciated that reference throughout this specification to "one embodiment" or "an embodiment" means that a particular feature, structure or characteristic described in connection with the embodiment is included in at least one embodiment of the present invention. Thus, the appearances of the phrases "in one embodiment" or "in an embodiment" in various places throughout this specification are not necessarily all referring to the same embodiment. Furthermore, the particular features, structures, or characteristics may be combined in any suitable manner in one or more embodiments. Those skilled in the art should also appreciate that the embodiments described in this specification are exemplary and alternative embodiments, and that the acts and modules illustrated are not required in order to practice the invention.
In various embodiments of the present invention, it should be understood that the sequence numbers of the above-mentioned processes do not imply an inevitable order of execution, and the execution order of the processes should be determined by their functions and inherent logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated units, if implemented as software functional units and sold or used as a stand-alone product, may be stored in a computer accessible memory. Based on such understanding, the technical solution of the present invention, which is a part of or contributes to the prior art in essence, or all or part of the technical solution, can be embodied in the form of a software product, which is stored in a memory and includes several requests for causing a computer device (which may be a personal computer, a server, a network device, or the like, and may specifically be a processor in the computer device) to execute part or all of the steps of the above-described method of each embodiment of the present invention.
It will be understood by those skilled in the art that all or part of the steps in the methods of the embodiments described above may be implemented by instructions associated with a program, which may be stored in a computer-readable storage medium, where the storage medium includes Read-Only Memory (ROM), Random Access Memory (RAM), Programmable Read-Only Memory (PROM), Erasable Programmable Read-Only Memory (EPROM), One-time Programmable Read-Only Memory (OTPROM), Electrically Erasable Programmable Read-Only Memory (EEPROM), compact disc-Read-Only Memory (CD-ROM), or other Memory, magnetic disk, magnetic tape, or magnetic tape, Or any other medium which can be used to carry or store data and which can be read by a computer.
The audio playing method, the terminal device and the vehicle disclosed in the embodiments of the present invention are described in detail above, and specific examples are applied herein to explain the principles and embodiments of the present invention, and the description of the embodiments above is only used to help understand the method and the core idea of the present invention. Meanwhile, for a person skilled in the art, according to the idea of the present invention, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present invention.

Claims (11)

1. An audio playing method, the method comprising:
when a target song is played, inquiring a local audio file of the target song in a local cache; the local audio file comprises a plurality of cache blocks, and the cache blocks comprise audio data downloaded from a server when the target song is played last time;
if the local audio file has the missing cache block, downloading audio data corresponding to the missing cache block from the server;
storing the audio data corresponding to the missing cache block into a local audio file of the target song;
and playing a local audio file of the target song.
2. The method of claim 1, wherein querying a local audio file of a target song in a local cache while playing the target song comprises:
when a target song is played, searching a local audio file of the target song stored in the local cache by taking the song number of the target song as a cache key;
wherein the song number is identified from a first URL of the target song; the first URL is provided by the server.
3. The method according to claim 2, wherein if there is a missing cache block in the local audio file, requesting the server to download audio data corresponding to the missing cache block, comprising:
and if the local audio file has the missing cache block, constructing a second URL of the target song according to the song number, and requesting the server to download the audio data corresponding to the missing cache block by taking the second URL as a basis.
4. The method according to any of claims 1-3, wherein the amount of data of a single cache block is less than a preset threshold amount of data.
5. The method according to any one of claims 1-3, further comprising:
when the local cache is cleaned, determining the song with the least number of accessed times from a plurality of songs stored in the local cache, and deleting the local audio file corresponding to the song with the least number of accessed times from the local cache.
6. A terminal device, comprising:
the query unit is used for querying a local audio file of a target song in a local cache when the target song is played; the local audio file comprises a plurality of cache blocks, and the cache blocks comprise audio data downloaded from a server when the target song is played last time;
the downloading unit is used for downloading the audio data corresponding to the missing cache blocks from the server when the local audio file has the missing cache blocks;
the storage unit is used for storing the audio data corresponding to the missing cache block into a local audio file of the target song;
and the playing unit is used for playing the local audio file of the target song.
7. The terminal device of claim 6, wherein:
the query unit is specifically configured to search a local audio file of a target song stored in the local cache by using a song number of the target song as a cache key when the target song is played;
wherein the song number is identified from a first URL of the target song; the first URL is provided by the server.
8. The terminal device of claim 7, wherein:
the downloading unit is specifically configured to, when the local audio file has the missing cache block, construct a second URL of the target song according to the song number, and request the server to download the audio data corresponding to the missing cache block according to the second URL.
9. The terminal device according to any of claims 6-8, wherein the terminal device further comprises:
and the cleaning unit is used for determining the song with the least accessed times from a plurality of songs stored in the local cache when the local cache is cleaned, and deleting the local audio file corresponding to the song with the least accessed times from the local cache.
10. A vehicle, characterized in that it comprises a terminal device according to any one of claims 6-9.
11. A storage medium, characterized by: the storage medium stores a computer program, wherein the computer program causes a computer to execute the audio playback method according to any one of claims 1 to 5.
CN202010019318.XA 2020-01-08 2020-01-08 Audio playing method, terminal equipment and vehicle Active CN111222004B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010019318.XA CN111222004B (en) 2020-01-08 2020-01-08 Audio playing method, terminal equipment and vehicle

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010019318.XA CN111222004B (en) 2020-01-08 2020-01-08 Audio playing method, terminal equipment and vehicle

Publications (2)

Publication Number Publication Date
CN111222004A true CN111222004A (en) 2020-06-02
CN111222004B CN111222004B (en) 2023-03-31

Family

ID=70828178

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010019318.XA Active CN111222004B (en) 2020-01-08 2020-01-08 Audio playing method, terminal equipment and vehicle

Country Status (1)

Country Link
CN (1) CN111222004B (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112131844A (en) * 2020-10-10 2020-12-25 北京字跳网络技术有限公司 Online document editing method and device and electronic equipment
CN113315810A (en) * 2021-04-29 2021-08-27 上海探寻信息技术有限公司 Online audio playing method and equipment
CN113421542A (en) * 2021-06-22 2021-09-21 广州小鹏汽车科技有限公司 Voice interaction method, server, voice interaction system and storage medium

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107273453A (en) * 2017-05-31 2017-10-20 广东欧珀移动通信有限公司 Method, terminal and the storage medium of music
CN109769136A (en) * 2018-12-07 2019-05-17 北京交通大学 Online Video buffer memory management method and system based on instantaneous access rate value

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107273453A (en) * 2017-05-31 2017-10-20 广东欧珀移动通信有限公司 Method, terminal and the storage medium of music
CN109769136A (en) * 2018-12-07 2019-05-17 北京交通大学 Online Video buffer memory management method and system based on instantaneous access rate value

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112131844A (en) * 2020-10-10 2020-12-25 北京字跳网络技术有限公司 Online document editing method and device and electronic equipment
CN113315810A (en) * 2021-04-29 2021-08-27 上海探寻信息技术有限公司 Online audio playing method and equipment
CN113315810B (en) * 2021-04-29 2023-04-07 上海探寻信息技术有限公司 Online audio playing method and equipment
CN113421542A (en) * 2021-06-22 2021-09-21 广州小鹏汽车科技有限公司 Voice interaction method, server, voice interaction system and storage medium

Also Published As

Publication number Publication date
CN111222004B (en) 2023-03-31

Similar Documents

Publication Publication Date Title
CN111222004B (en) Audio playing method, terminal equipment and vehicle
JP5814436B2 (en) Caching information system and method
CN109600437B (en) Downloading method of streaming media resource and cache server
US20120016916A1 (en) Method and Apparatus for Processing and Updating Service Contents in a Distributed File System
CN107197359B (en) Video file caching method and device
CN103945259B (en) A kind of Online Video player method and device
JP4317531B2 (en) System and method for balancing multiple memory buffer sizes
CN102164160A (en) Method, device and system for supporting large quantity of concurrent downloading
CN107430551B (en) Data caching method, storage control device and storage equipment
US20080306917A1 (en) File server for performing cache prefetching in cooperation with search ap
CN109471843B (en) Metadata caching method, system and related device
CN110401858B (en) Video playing method and device, electronic equipment and storage medium
CN110647502A (en) File loading method, equipment, device and computer storage medium
CN103051977A (en) Method for processing p2p (peer-to-peer) cache data
CN108197160A (en) A kind of picture loading method and device
US7734874B2 (en) Method and system for caching data using future access request information
EP2436008A2 (en) Method and host device for enforcing a rule associated with a media file
CN111522509B (en) Caching method and equipment for distributed storage system
CN108540569B (en) Software installation package replacement method and device and computer storage medium
CN111031117B (en) Multimedia file downloading method and related device
CN105824820A (en) Media file buffer memory method and device
CN106022161B (en) A kind of data processing method and device
CN105095337A (en) Selection method, method for maintaining data list and electronic device
CN111225248B (en) On-demand content management method and content distribution network on-demand server
CN110020290B (en) Webpage resource caching method and device, storage medium and electronic device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant