Audio playing method, storage medium, device and program product
By obtaining audio clip playback requests and dynamically adjusting the download content range, the problem of long waiting time for users in traditional karaoke software is solved, fast response and traffic saving are achieved, and user experience is improved.
Patent Information
- Application Number
- CN202411373751.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-29
- Publication Date
- 2025-01-07
AI Technical Summary
When the clip singing function in traditional karaoke software downloads the accompaniment file of the entire song, it causes the user to wait for a long time and poor user experience.
By obtaining audio clip playback requests, determining the clip time range and the accompaniment file, obtaining accompaniment audio head information, dynamically adjusting the download content range, and downloading only the required target data range to achieve fast response and reduce the load cache time.
It effectively reduces the time-consuming user download waiting time, improves the speed of entering the clip playback scene, avoids the waste of traffic caused by non-essential data downloads, and realizes multiple reuse of local cached files.
Smart Images

Figure CN119271840A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of audio data processing, and in particular to an audio playback method, storage medium, device and program product. Background Art
[0002] The fragment singing function in traditional karaoke software supports users to customize the singing range. It usually locates the user-defined singing range for singing and recording after downloading the accompaniment file of the entire song, resulting in a longer waiting time before the user enters the singing and a poor user experience.
[0003] Therefore, how to improve the loading efficiency of audio is a technical problem that technical personnel in this field need to solve urgently. Summary of the invention
[0004] The purpose of the present application is to provide an audio playback method, a computer-readable storage medium, an electronic device and a computer program product, which can quickly respond to a user's audio clip playback request and reduce the loading and caching time of the accompaniment file.
[0005] In order to solve the above technical problems, the present application provides an audio playback method, and the specific technical solution is as follows:
[0006] Get the audio clip playback request;
[0007] Determine a time range of the requested audio segment contained in the audio segment playback request, and an accompaniment file to which the requested audio segment belongs;
[0008] Obtaining the accompaniment audio header information of the accompaniment file;
[0009] determining a target data range corresponding to the segment time range from the audio data content of the accompaniment file according to the accompaniment audio header information;
[0010] The data content corresponding to the target data range in the audio data content of the accompaniment file is obtained, the requested audio segment is obtained, and the requested audio segment is played.
[0011] Optionally, obtaining the accompaniment audio header information of the accompaniment file includes:
[0012] If the local device has an accompaniment cache file, obtain the accompaniment audio header information of the accompaniment file from the accompaniment cache file;
[0013] If the local device does not have the accompaniment cache file, download the accompaniment audio header information of the accompaniment file.
[0014] Optionally, determining the target data range corresponding to the segment time range from the audio data content of the accompaniment file according to the accompaniment audio header information includes:
[0015] Calculate the start audio packet position according to the audio sampling rate, the number of audio packet frames in the accompaniment audio header information, and the start time of the segment time range;
[0016] Determine the file offset at the beginning of the segment time range according to the offset value of the streaming media data segment in the accompaniment audio header information in the accompaniment file, the function of the audio streaming media to obtain the offset position of the specified audio package in the data segment and the starting audio package position;
[0017] Calculate the end audio packet position according to the audio sampling rate, the number of audio packet frames, and the end time of the segment time range;
[0018] Determine the file offset at the end of the segment time range according to the offset value of the streaming media data segment in the accompaniment audio header information in the accompaniment file, the function of the audio streaming media to obtain the offset position of the specified audio package in the data segment, and the end audio package position;
[0019] The target data range is determined according to the offset value, the start file offset position and the end file offset position.
[0020] Optionally, acquiring data content corresponding to the target data range in the audio data content of the accompaniment file to obtain the requested audio segment includes:
[0021] If the accompaniment cache file contains the target data range corresponding to all the time ranges of the clips, obtain the data content corresponding to the target data range in the audio data content of the accompaniment file from the accompaniment cache file to obtain the requested audio clip;
[0022] If the accompaniment cache file contains a partial data range in the target data range corresponding to the segment time range, determining an additional time range according to the cached time range contained in the accompaniment cache file and the segment time range, downloading additional data content corresponding to the additional time range, and integrating the partial data range and the additional data content to obtain the requested audio segment;
[0023] If the accompaniment file does not include the target data range corresponding to the segment time range, the data content corresponding to the target data range in the audio data content of the accompaniment file is downloaded to obtain the requested audio segment.
[0024] Optionally, after obtaining the data content corresponding to the target data range in the audio data content of the accompaniment file and obtaining the requested audio segment, the method further includes:
[0025] The requested audio segment is recorded in units of data blocks, and a block cache information table is used to maintain the start and end time of each data block; the block cache information table is used to perform audio segment multiplexing according to the start and end time of the data block.
[0026] Optionally, if a secondary audio clip play request belonging to the accompaniment file is obtained after the audio clip play request is obtained, the method further includes:
[0027] Determining a second segment time range corresponding to the secondary audio segment playback request;
[0028] Comparing the start and end times of the data blocks maintained in the block cache information table, and obtaining a secondary requested audio segment corresponding to the second segment time range according to a target data block whose start and end times satisfy the second segment time range;
[0029] The second requested audio segment is played in response to the second audio segment playing request.
[0030] Optionally, if there is a data block to be processed whose start and end time partially overlaps with the second segment time range, the method further includes:
[0031] Determine the time processing type included in the data block to be processed; the time processing type includes the start time and the end time;
[0032] The to-be-processed data block is cropped according to the time point corresponding to the time processing type to obtain a cropped data block belonging to the time range of the second segment; the cropped data block is used to constitute the second requested audio segment.
[0033] Optionally, if the second segment time range is a true subset of the time range corresponding to all data blocks contained in the block cache information table, obtaining the second requested audio segment corresponding to the second segment time range according to the start and end time of each data block recorded in the block cache information table includes:
[0034] Determine the minimum target data blocks covering the second segment time range according to the start and end times of the data blocks maintained in the block cache information table;
[0035] The second requested audio segment corresponding to the second segment time range is obtained according to the minimum target data block.
[0036] Optionally, if the second segment time range and the time range corresponding to all data blocks contained in the block cache information table have an intersection, or the time range corresponding to all data blocks contained in the block cache information table is a true subset of the second segment time range, obtaining the second requested audio segment corresponding to the second segment time range according to the start and end time of each data block recorded in the block cache information table includes:
[0037] Determine, according to the start and end time of each of the data blocks maintained in the block cache information table, a target data block that meets the second segment time range and an additional data block that does not meet the second segment time range;
[0038] After the download of the additional data block is completed, the target data block and the additional data block are rearranged in a play order to obtain a secondary requested audio segment.
[0039] The present application also provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps of the audio playback method described above are implemented.
[0040] The present application also provides an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the audio playback method as described above when calling the computer program in the memory.
[0041] The present application also provides a computer program product, including a computer program, which implements the steps of the audio playback method described above when executed.
[0042] The present application provides an audio playback method, comprising: obtaining an audio clip playback request; determining a clip time range of a requested audio clip contained in the audio clip playback request, and an accompaniment file to which the requested audio clip belongs; obtaining accompaniment audio header information of the accompaniment file; determining a target data range corresponding to the clip time range from audio data content of the accompaniment file according to the accompaniment audio header information; obtaining data content corresponding to the target data range in the audio data content of the accompaniment file, obtaining the requested audio clip, and playing the requested audio clip.
[0043] When obtaining an audio clip playback request, this application first determines the clip time range of the requested audio clip, and by obtaining the accompaniment audio header information, the corresponding target data range can be determined according to the accompaniment audio header information, and the download content range can be dynamically adjusted. Only the target data range actually required for playback needs to be downloaded, and there is no need to download the complete accompaniment file, which effectively reduces the user's download waiting time, improves the speed of entering the clip playback scene, and avoids the waste of traffic caused by unnecessary data downloads. On this basis, it is also possible to further reuse the local cached files multiple times from the data content corresponding to the target data range of the cached audio clips of the local device.
[0044] The present application also provides a computer-readable storage medium and an electronic device, which have the above-mentioned beneficial effects, which will not be described in detail here. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.
[0046] Figure 1 A flowchart of an audio playback method provided in an embodiment of the present application;
[0047] Figure 2 A schematic diagram of the download range provided in the embodiment of the present application;
[0048] Figure 3 A schematic diagram of the structure of a block cache information table provided in an embodiment of the present application;
[0049] Figure 4 A comparison chart of the present application and prior art data download contents provided for the embodiments of the present application;
[0050] Figure 5 A flowchart of the audio clip multiplexing method provided in an embodiment of the present application;
[0051] Figure 6 A schematic diagram of an audio clip multiplexing process provided in an embodiment of the present application;
[0052] Figure 7 This is a structural diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0053] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0054] See also Figure 1 , Figure 1 A flowchart of an audio playback method provided in an embodiment of the present application, the method comprising:
[0055] S101: Obtaining an audio clip playback request;
[0056] S102: Determine a time range of the requested audio segment contained in the audio segment playing request, and an accompaniment file to which the requested audio segment belongs;
[0057] S103: Acquire the accompaniment audio header information of the accompaniment file;
[0058] S104: determining a target data range corresponding to the segment time range from the audio data content of the accompaniment file according to the accompaniment audio header information;
[0059] S105: Acquire the data content corresponding to the target data range in the audio data content of the accompaniment file, obtain the requested audio segment, and play the requested audio segment.
[0060] This embodiment can download only the required content in the accompaniment when the user uses the fragment singing function, effectively reducing the time the user waits for downloading the accompaniment and improving the speed of entering the fragment playing link. At the same time, the file block caching solution is used to support the reuse of the downloaded cached content in the next fragment singing or complete singing, avoiding repeated downloading of resources.
[0061] There is no limitation on how to obtain the audio clip playback request, which can be a voice command issued by the user, or a text command directly input through an input device, etc. There is no limitation on the specific request format and request content of the audio clip playback request, and the request format can be set accordingly by the specific application device of this application.
[0062] After obtaining the audio clip playback request, first determine the segment time range of the requested audio clip contained in the audio clip playback request. The audio clip playback request must at least contain the name of the accompaniment file to which the requested audio clip belongs, as specified by the user, so as to determine the accompaniment file of the requested audio clip and the segment time range of the requested audio clip. The segment time range of the requested audio clip can be determined by pre-set prompt information indications, such as the chorus part or the prelude part of the accompaniment file to which the requested audio clip belongs, or it can be determined according to the playback time period specified in the audio clip playback request. It is easy to understand that the end time of the playback time period should not exceed the total duration of the accompaniment file to which the requested audio clip belongs.
[0063] Thereafter, the accompaniment audio header information of the accompaniment file is obtained. There is no limitation on how to obtain the accompaniment audio header information. If the local device has an accompaniment cache file, the accompaniment audio header information of the accompaniment file can be obtained from the accompaniment cache file. If the local device does not have an accompaniment cache file, download the accompaniment audio header information of the accompaniment file. The local device refers to a device used to play the accompaniment file, or an electronic device that can control the speaker to play. For example, a mobile phone connected to a Bluetooth speaker, in which case the mobile phone acts as a local device. If the local device does not have a cache file for the accompaniment file or the cache file exists but the accompaniment audio header information cannot be obtained, the accompaniment audio header information of the accompaniment file can be downloaded from the cloud or server.
[0064] After obtaining the accompaniment audio header information of the accompaniment file, the target data range corresponding to the segment time range can be determined according to the accompaniment audio header information. The segment time range can be a fuzzy concept, such as the chorus part or the prelude part of the accompaniment file to which the requested audio segment belongs. The determined target data range refers to the data resources required to play the segment time range, which is usually represented by the data start address and end address.
[0065] In a feasible implementation manner, the actual file download range can be determined based on the offset value of the streaming media data segment in the accompaniment audio header information in the file, the file offset position at the beginning, and the file offset position at the end.
[0066] The following describes the process of determining the file offset position at the beginning and the file offset position at the end:
[0067] The first step is to calculate the starting audio packet position according to the audio sampling rate, the number of audio packet frames in the accompaniment audio header information, and the start time of the segment time range;
[0068] The second step is to determine the file offset at the beginning of the segment time range according to the offset value of the streaming media data segment in the accompaniment file in the accompaniment audio header information, the offset position function of the audio streaming media in obtaining the specified audio package in the data segment, and the starting audio package position;
[0069] Step 3: Calculate the end audio packet position according to the audio sampling rate, the number of audio packet frames, and the end time of the segment time range;
[0070] Step 4: Determine the file offset at the end of the segment time range according to the offset value of the streaming media data segment in the accompaniment file in the accompaniment audio header information, the offset position function of the audio streaming media in obtaining the specified audio package in the data segment, and the end audio package position;
[0071] Step 5: Determine the target data range based on the offset value, the file offset at the start, and the file offset at the end.
[0072] Specifically, the audio sampling rate sampleRate, the number of audio packet frames framesPerPacket in the accompaniment audio header information, and the start time startTime and end time endTime of the corresponding segment time range of the audio segment playback request initiated by the user can be used to calculate the start audio packet position (startPacket). The formula is as follows:
[0073] startPacket = startTime * sampleRate / framesPerPacket;
[0074] The ending audio packet position corresponding to the ending time is:
[0075] endPacket = endTime * sampleRate / framesPerPacket;
[0076] Combining the offset value mdatOffset of the streaming media data segment in the file in the accompaniment audio header information and the function outDataByteOffset() used by the audio streaming media to obtain the offset position of the specified audio package in the data segment, the starting file offset position startFilePos can be obtained. The formula is as follows:
[0077] startFilePos = mdatOffset * outDataByteOffset(startPacket);
[0078] Similarly, the file offset position at the end can be obtained, the formula is as follows:
[0079] endFilePos = mdatOffset * outDataByteOffset(endPacket);
[0080] At this point, the target data range, that is, the actual file download range, can be calculated based on the offset value of the streaming media data segment in the accompaniment audio header information, the file offset position at the beginning, and the file offset position at the end. Figure 2 , Figure 2 A schematic diagram of the download range provided in the embodiment of the present application, Figure 2 The header information is the accompaniment audio header information, and the target data range can be calculated based on the header information. At this time:
[0081] Actual file download range = [0, mdatOffset] + [startFilePos, endFilePos];
[0082] After determining the target data range, the data content corresponding to the target data range can be obtained, the requested audio segment can be obtained, and the requested audio segment can be played.
[0083] When obtaining an audio clip playback request, the embodiment of the present application first determines the clip time range of the requested audio clip, obtains the accompaniment audio header information, and determines the corresponding target data range according to the accompaniment audio header information. The download content range can be dynamically adjusted, and only the target data range actually required for playback needs to be downloaded, without downloading the complete accompaniment file, which effectively reduces the user's download waiting time, improves the speed of entering the clip playback scene, and avoids the waste of traffic caused by unnecessary data downloads. On this basis, the data content corresponding to the target data range of the cached audio clips of the local device can be further used to realize multiple reuse of local cache files.
[0084] In other embodiments of the present application, how to obtain the data content corresponding to the target data range in the audio data content of the accompaniment file and obtain the requested audio clip is further described:
[0085] If the accompaniment cache file contains the target data range corresponding to the time range of all the segments, the data content corresponding to the target data range in the audio data content of the accompaniment file is obtained from the accompaniment cache file to obtain the requested audio segment.
[0086] If the accompaniment cache file contains a partial data range in the target data range corresponding to the fragment time range, determine the additional time range according to the cached time range and the fragment time range contained in the accompaniment cache file, download the additional data content corresponding to the additional time range, and integrate the partial data range and the additional data content to obtain the requested audio fragment.
[0087] If the accompaniment file does not contain the target data range corresponding to the segment time range, the data content corresponding to the target data range in the audio data content of the accompaniment file is downloaded to obtain the requested audio segment.
[0088] When an accompaniment cache file is stored locally, it is necessary to compare the time range corresponding to the accompaniment cache file with the time range of the requested audio segment included in the audio segment playback request, and reuse the accompaniment cache file stored in the local device as much as possible to ensure that the data content that needs to be downloaded is minimized, so as to improve the response efficiency to the audio segment playback request.
[0089] There is no limitation on how to determine the additional data range. In a feasible implementation, the block cache information table can be used for comparison and determination. The requested audio segment can be recorded in units of data blocks in advance, and the start and end times of each data block can be maintained using the block cache information table. Then, when a request to play an audio segment is detected, it is determined whether there is a combination of one or more data blocks in the block cache information table that can satisfy the segment time range. If any data block, or any combination of several data blocks, cannot satisfy the segment time range, it can be determined that the accompaniment file cannot satisfy the segment time range. At this time, one or more data blocks closest to the segment time range can be further determined based on the start and end times of the existing data blocks in the block cache information table, and the missing time period can be obtained by comparison. The missing time period is downloaded as an additional data range, thereby realizing the reuse of audio segments of the local accompaniment cache file.
[0090] See also Figure 3 , Figure 3 A schematic diagram of the structure of a block cache information table provided in an embodiment of the present application, Figure 3 The block cache information table shown records basic information such as duration, file size, file MD5 (Message-Digest Algorithm 5) information, file type, file path, and time range of downloaded data blocks.
[0091] It can be seen that in the actual application process of this application, after obtaining the audio clip playback request, it can be divided into two situations:
[0092] In the first case, if the local device does not have the accompaniment cache file, the download process of the accompaniment file will be triggered, and the downloaded audio data will be parsed and cached. When the accompaniment audio header information is parsed, the download process will be paused first, and the target data range corresponding to the segment time range will be calculated based on the segment time range of the requested audio segment in the audio segment playback request. The data download range of the downloader will be set to download on demand, that is, download the target data range. When the content of the target data range is downloaded, the playback can be started without waiting for the entire accompaniment file to be downloaded.
[0093] In the second case, if the local device has an accompaniment cache file, it can be determined whether the accompaniment cache file meets the target data range corresponding to the clip time range. If it does, the requested audio clip can be obtained and played. If it does not, it is necessary to calculate the additional data content corresponding to the additional time range that needs to be downloaded, and download the additional data content through the downloader. After downloading and integrating, the playback can be started. Integration usually refers to aggregating the audio clips within the target data range in the order of playback time.
[0094] See also Figure 4 , Figure 4 Comparison chart of the download contents of this application and prior art data provided by the embodiments of this application. Figure 4 It can be clearly seen that in the prior art, the original clip download accompaniment needs to completely download the entire content of the accompaniment file, including the header information and all the audio data content; and the application of this application obtains the accompaniment audio header information, that is, Figure 4 After the header information is shown, the target data range corresponding to the segment time range can be determined directly according to the accompaniment audio header information, that is, Figure 4 The "header information calculates the data content of the singing range" shown in the figure, so that only the required content is downloaded without downloading all the accompaniment files, which effectively reduces the user's download waiting time, increases the speed of entering the clip playback scene, and avoids the waste of traffic caused by unnecessary data downloads.
[0095] Based on the above embodiment, if a secondary audio clip playback request belonging to the accompaniment file is obtained after obtaining the audio clip playback request, the audio clip multiplexing can be performed. The following is an explanation of the audio clip multiplexing that can be implemented in this application. Figure 5 , Figure 5 This is a flowchart of the audio clip multiplexing method provided in an embodiment of the present application. The specific process is as follows:
[0096] S501: Determine a second segment time range corresponding to a secondary audio segment play request;
[0097] S502: Compare the start and end times of each data block maintained in the block cache information table, and obtain a secondary requested audio segment corresponding to the second segment time range according to the target data block whose start and end times meet the second segment time range;
[0098] S503: Play the second requested audio segment to respond to the second audio segment play request.
[0099] It should be noted that when the block cache information table is used to record audio segments in units of data blocks, the lengths of the data blocks may be the same, or there may be data blocks of different lengths. At this time, there may be data blocks to be processed whose start and end times partially overlap with the time range of the second segment. At this time, the time processing type contained in the data block to be processed is first determined, and then the data block to be processed is cropped according to the time point corresponding to the time processing type to obtain a cropped data block within the time range of the second segment. The time processing type includes the start time and the end time, that is, it is determined that the data block to be processed includes the start time and / or the end time. If the start time is included, the audio segment before the start time is cut off. If the end time is included, the audio segment after the end time is cut off. It should be emphasized that the start time and end time of this embodiment refer to the start time and end time of the second segment time range. The obtained cropped data block is used to constitute a secondary requested audio segment.
[0100] In addition, if the second segment time range is a true subset of the time range corresponding to all data blocks contained in the block cache information table, the minimum target data blocks covering the second segment time range can be determined based on the start and end times of the data blocks maintained in the block cache information table, so as to obtain the secondary requested audio segment corresponding to the second segment time range based on the minimum target data blocks.
[0101] The so-called true subset means that the time range of the second segment completely belongs to and is smaller than the time range corresponding to all data blocks included in the block cache information table.
[0102] Specifically, when responding to the secondary audio segment play request, the additional data blocks and the downloaded data blocks are first rearranged in the play order to obtain the current audio data combination, and the current audio data combination is played as a response to the secondary audio segment play request.
[0103] See also Figure 6 , Figure 6 A schematic diagram of an audio clip multiplexing process provided in an embodiment of the present application, Figure 6 The first clip singing content is the audio data content downloaded in response to the first audio clip playback request, including the accompaniment audio header information, i.e. Figure 6 The "header information" shown in the figure, as well as the data content of the singing range calculated by the header information, namely the target data range. In different playback ranges, the yellow-marked content is the audio data content that needs to be downloaded in addition to the audio data content downloaded when the first audio clip playback request is made. At this time, only the required resources can be downloaded, the existing cache can be reused, and the audio data combination can be combined as a response to the second audio clip playback request.
[0104] The above description shows that the local accompaniment file completely covers the secondary requested audio segment corresponding to the secondary audio segment playback request. If the secondary audio segment playback request and the audio segment playback request have partial audio segment overlap, that is, if the second segment time range and the time range corresponding to all data blocks contained in the block cache information table have an intersection, or the time range corresponding to all data blocks contained in the block cache information table is a true subset of the second segment time range, then the target data block that meets the second segment time range and the additional data block that does not meet the second segment time range can be determined according to the start and end time of each data block maintained in the block cache information table. After the additional data blocks are downloaded, the target data blocks and the additional data blocks are rearranged in the playback order to obtain the secondary requested audio segment. The so-called intersection refers to the partial overlap between the second segment time range and the time range corresponding to all data blocks contained in the block cache information table.
[0105] It can be seen that when a subsequent playback request for the same music is received, if the audio clip corresponding to the playback request exists locally, the cached part does not need to be downloaded repeatedly, which can significantly reduce the waiting time for downloading accompaniment resources for the fragment singing scene, effectively increase the speed of entering the singing, and improve the user experience. At the same time, it can save the user's traffic and avoid unnecessary waste. For example, if a 5-minute accompaniment is selected for fragment singing, if the user only needs to sing a one-minute popular fragment, the download waiting time can be reduced by about 80%, and about 80% of the traffic can be saved. Even when the local device has an accompaniment cache file containing the one-minute popular fragment, it only needs to trim the accompaniment cache file, or trim the corresponding data block according to the block cache information table, and the playback can be quickly started without downloading.
[0106] Secondly, by applying this application, when recommending popular song clips, the server does not need to cut and save the song clips, but only needs to save a complete accompaniment. Users can control the client to apply the audio playback method provided by this application to request audio clips for playback on demand, thereby reducing server storage costs.
[0107] The audio playback method provided in the embodiment of the present application realizes the block caching and reuse of audio resource files, which can be used not only for fragment singing scenes, but also for all streaming media resources.
[0108] In the actual application process of the present application, the server can also generate popular clips of the accompaniment, and when the user selects the clip, the file can be directly downloaded, which can significantly improve the user experience of selecting audio clips for playback.
[0109] The present application also provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed, the steps provided in the above embodiment can be implemented. The storage medium may include: a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and other media that can store program codes.
[0110] The present application also provides a computer program product, including a computer program, which implements the steps of the above audio playback method when the computer program is executed.
[0111] The present application also provides an electronic device, see Figure 7 , a structural diagram of an electronic device provided in an embodiment of the present application, such as Figure 7 As shown, a processor 710 and a memory 720 may be included.
[0112] Among them, the processor 710 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 710 can be implemented in at least one hardware form of DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), and PLA (Programmable Logic Array). The processor 710 may also include a main processor and a coprocessor. The main processor is a processor for processing data in the awake state, also known as a CPU (Central Processing Unit); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 710 may be integrated with a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 710 may also include an AI (Artificial Intelligence) processor, which is used to process computing operations related to machine learning.
[0113] The memory 720 may include one or more computer-readable storage media, which may be non-transitory. The memory 720 may also include a high-speed random access memory, and a non-volatile memory, such as one or more disk storage devices, flash memory storage devices. In this embodiment, the memory 720 is at least used to store the following computer program 721, wherein, after the computer program is loaded and executed by the processor 710, it can implement the relevant steps in the method performed by the electronic device side disclosed in any of the aforementioned embodiments. In addition, the resources stored in the memory 720 may also include an operating system 722 and data 723, etc., and the storage method may be temporary storage or permanent storage. Among them, the operating system 722 may include Windows, Linux, Android, etc.
[0114] In some embodiments, the electronic device may further include a display screen 730 , an input / output interface 740 , a communication interface 750 , a sensor 760 , a power source 770 , and a communication bus 780 .
[0115] certainly, Figure 7 The structure of the electronic device shown does not constitute a limitation on the electronic device in the embodiments of the present application. In actual applications, the electronic device may include Figure 7 More or fewer components than shown, or combinations of certain components.
[0116] The various embodiments in the specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other. For the system provided in the embodiment, since it corresponds to the method provided in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part description.
[0117] Specific examples are used herein to illustrate the principles and implementation methods of the present application, and the description of the above embodiments is only used to help understand the method and core ideas of the present application. It should be pointed out that for ordinary technicians in this technical field, without departing from the principles of the present application, several improvements and modifications can be made to the present application, and these improvements and modifications also fall within the scope of protection of the present application.
[0118] It should also be noted that, in this specification, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "comprise", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the statement "comprises a ..." does not exclude the presence of other identical elements in the process, method, article or device including the element.
Claims
1. An audio playback method, characterized in that: include: Get the audio clip playback request; Determine a time range of the requested audio segment contained in the audio segment playback request, and an accompaniment file to which the requested audio segment belongs; Obtaining the accompaniment audio header information of the accompaniment file; determining a target data range corresponding to the segment time range from the audio data content of the accompaniment file according to the accompaniment audio header information; The data content corresponding to the target data range in the audio data content of the accompaniment file is obtained, the requested audio segment is obtained, and the requested audio segment is played.
2. The audio playback method according to claim 1, characterized in that: Obtaining the accompaniment audio header information of the accompaniment file includes: If the local device has an accompaniment cache file, obtain the accompaniment audio header information of the accompaniment file from the accompaniment cache file; If the local device does not have the accompaniment cache file, download the accompaniment audio header information of the accompaniment file.
3. The audio playback method according to claim 1, characterized in that: Determining the target data range corresponding to the segment time range from the audio data content of the accompaniment file according to the accompaniment audio header information comprises: Calculate the start audio packet position according to the audio sampling rate, the number of audio packet frames in the accompaniment audio header information, and the start time of the segment time range; Determine the file offset at the beginning of the segment time range according to the offset value of the streaming media data segment in the accompaniment audio header information in the accompaniment file, the function of the audio streaming media to obtain the offset position of the specified audio package in the data segment and the starting audio package position; Calculate the end audio packet position according to the audio sampling rate, the number of audio packet frames, and the end time of the segment time range; Determine the file offset at the end of the segment time range according to the offset value of the streaming media data segment in the accompaniment audio header information in the accompaniment file, the function of the audio streaming media to obtain the offset position of the specified audio package in the data segment, and the end audio package position; The target data range is determined according to the offset value, the start file offset position and the end file offset position.
4. The audio playback method according to claim 2, characterized in that: Acquiring data content corresponding to the target data range in the audio data content of the accompaniment file to obtain the requested audio segment includes: If the accompaniment cache file contains the target data range corresponding to all the time ranges of the clips, obtain the data content corresponding to the target data range in the audio data content of the accompaniment file from the accompaniment cache file to obtain the requested audio clip; If the accompaniment cache file contains a partial data range in the target data range corresponding to the segment time range, determining an additional time range according to the cached time range contained in the accompaniment cache file and the segment time range, downloading additional data content corresponding to the additional time range, and integrating the partial data range and the additional data content to obtain the requested audio segment; If the accompaniment file does not include the target data range corresponding to the segment time range, the data content corresponding to the target data range in the audio data content of the accompaniment file is downloaded to obtain the requested audio segment.
5. The audio playback method according to claim 1, characterized in that: After obtaining the data content corresponding to the target data range in the audio data content of the accompaniment file and obtaining the requested audio segment, the method further includes: The requested audio segment is recorded in units of data blocks, and a block cache information table is used to maintain the start and end time of each data block; the block cache information table is used to perform audio segment multiplexing according to the start and end time of the data block.
6. The audio playback method according to claim 5, characterized in that: If a secondary audio clip play request belonging to the accompaniment file is obtained after the audio clip play request is obtained, the method further includes: Determining a second segment time range corresponding to the secondary audio segment playback request; Comparing the start and end times of the data blocks maintained in the block cache information table, and obtaining a secondary requested audio segment corresponding to the second segment time range according to a target data block whose start and end times satisfy the second segment time range; The second requested audio segment is played in response to the second audio segment playing request.
7. The audio playback method according to claim 6, characterized in that: If there is a data block to be processed whose start and end time partially overlaps with the second segment time range, the method further includes: Determine the time processing type included in the data block to be processed; the time processing type includes a start time and an end time; The to-be-processed data block is cropped according to the time point corresponding to the time processing type to obtain a cropped data block belonging to the second segment time range; the cropped data block is used to constitute the second requested audio segment.
8. The audio playing method according to claim 7, characterized in that: If the second segment time range is a true subset of the time range corresponding to all data blocks in the block cache information table, obtaining the second requested audio segment corresponding to the second segment time range according to the start and end time of each data block recorded in the block cache information table includes: Determine the minimum target data blocks covering the second segment time range according to the start and end times of the data blocks maintained in the block cache information table; The second requested audio segment corresponding to the second segment time range is obtained according to the minimum target data block.
9. The audio playback method according to claim 7, characterized in that: If the second segment time range and the time range corresponding to all data blocks included in the block cache information table have an intersection, or the time range corresponding to all data blocks included in the block cache information table is a true subset of the second segment time range, obtaining the second requested audio segment corresponding to the second segment time range according to the start and end time of each data block recorded in the block cache information table includes: Determine, according to the start and end time of each of the data blocks maintained in the block cache information table, a target data block that meets the second segment time range and an additional data block that does not meet the second segment time range; After the download of the additional data block is completed, the target data block and the additional data block are rearranged in a play order to obtain a secondary requested audio segment.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the audio playing method according to any one of claims 1 to 9 are implemented.
11. An electronic device, characterized in that: The method comprises a memory and a processor, wherein a computer program is stored in the memory, and when the processor calls the computer program in the memory, the steps of the audio playing method according to any one of claims 1 to 9 are implemented.
12. A computer program product, characterized in that It comprises a computer program, which, when executed, implements the steps of the audio playing method according to any one of claims 1 to 9.