Audio file scanning method and related device
By analyzing the playback time of each track in the audio file and selecting the maximum time as the file playback time, the problem of excessive file scanning time in the prior art is solved, and more efficient file playback is achieved.
Patent Information
- Application Number
- CN202510295930.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-12
- Publication Date
- 2025-08-01
AI Technical Summary
When parsing the playback time of Midi files under Android system, the existing technology requires continuous conversion between multiple audio track data, resulting in too long file scanning time and affecting the playback efficiency of audio files.
By obtaining the multi-segment track data of the target audio file, parsing the playback time of each track, and selecting the longest playback time as the playback time of the target audio file, avoiding frequent scanning of the entire file and saving file scanning time.
It improves file scanning speed, reduces the system's I/O interactive data volume, and improves file playback efficiency.
Smart Images

Figure CN120406891A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of file reading, and in particular, to an audio file scanning method and related devices. Background Art
[0002] Under the Android system, when an APP plays an audio file, it usually needs to first parse the audio file to obtain the ID3 information and playing duration of the audio file. The ID3 information is used to store information in an MP3 file, and it is a data format within several bytes at the beginning or end of the MP3 file, which attaches information such as the song name, singer, album name, title, year, style, type, and remarks of the MP3 file. After the APP obtains this information, it adds the audio file to the playlist, and then the user can select the audio file in the playlist for playback.
[0003] An audio file includes a Midi file, and a Midi file is composed of data of multiple tracks. The data of each track is stored continuously. Each track can include multiple frames of data, and each frame of data is composed of time difference data and event data. When obtaining the playing duration of a Midi file, first determine the frame data with the smallest time difference among multiple tracks, and after parsing, determine the frame data with the second smallest time difference from the data of multiple tracks, and repeat until all the frame data is determined, and then calculate the playing duration of the audio file. This method requires continuously determining frame data from the data of each track during parsing and continuously switching between the data of different tracks, which consumes a large amount of time, resulting in too long a time to obtain the playlist and affecting the playing efficiency of the audio file. Summary of the Invention
[0004] The main purpose of this application is to provide an audio file scanning method and related devices, which can improve the file scanning speed and the file playing efficiency.
[0005] The first technical solution adopted by this application is: providing an audio file scanning method. The method includes obtaining a target audio file, where the target audio file includes multiple segments of track data, each segment of track data includes multiple frames of data, and each frame of data is composed of time difference data and event data; parsing the target audio file to obtain the playing duration of each segment of track data; and selecting the longest playing duration from the playing durations of all the track data as the playing duration of the target audio file.
[0006] The second technical solution adopted by this application is: to provide an audio file scanning device. The audio file scanning device includes a file acquisition module for acquiring a target audio file. The target audio file includes multiple track data segments, each track data segment includes multiple frame data, and each frame data is composed of time difference data and event data; a file scanning module for parsing the target audio file to obtain the playing duration of each track data segment, and selecting the longest playing duration from the playing durations of all track data segments as the playing duration of the target audio file.
[0007] The third technical solution adopted by this application is: to provide an audio file playing system. The audio file playing system includes the audio file scanning device described in the second technical solution for scanning the target audio file to obtain the playing duration of the target audio file; a file playing module for playing the target audio file after obtaining the playing duration of the target audio file.
[0008] The fourth technical solution adopted by this application is: to provide an electronic device. The electronic device includes a memory and a processor. The memory is used to store program data, and the program data can be executed by the processor to implement the method described in the first technical solution.
[0009] The fifth technical solution adopted by this application is: to provide a computer-readable storage medium / computer program product. The computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are executed by the processor, they are used to implement the method described in the first technical solution; the computer program product includes program data, and when the computer program is executed by the processor, it implements the method described in the first technical solution.
[0010] The beneficial effects of this application are: after acquiring the target audio file, parsing the target audio file to obtain the playing duration corresponding to each track data segment, and selecting the longest playing duration from the playing durations of all track data segments as the playing duration of the target audio file. By directly obtaining the playing durations of each track file and determining the playing duration of the file therefrom, it avoids the need to frequently scan the entire target audio file when updating the playing duration of the target audio file through a single time difference data, saves file scanning time, improves file scanning speed, and improves file playing efficiency. Description of the Drawings
[0011] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following will briefly introduce the drawings required for the description of the embodiments. Obviously, the following drawings are only some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0012] Figure 1 It is a schematic structural diagram of an audio file;
[0013] Figure 2 It is a schematic flowchart of the first embodiment of the audio file scanning method of the present application;
[0014] Figure 3 It is a schematic flowchart of the second embodiment of the audio file scanning method of the present application;
[0015] Figure 4 It is a schematic flowchart of the third embodiment of the audio file scanning method of the present application;
[0016] Figure 5 It is a schematic flowchart of the fourth embodiment of the audio file scanning method of the present application;
[0017] Figure 6 It is a schematic flowchart of the fifth embodiment of the audio file scanning method of the present application;
[0018] Figure 7 It is a schematic structural diagram of an embodiment of the audio file scanning device of the present application;
[0019] Figure 8 It is a schematic structural diagram of an embodiment of the audio file playing system of the present application;
[0020] Figure 9 It is a schematic structural diagram of an embodiment of the electronic device of the present application;
[0021] Figure 10 It is a schematic structural diagram of an embodiment of the computer-readable storage medium of the present application;
[0022] Figure 11 It is a schematic structural diagram of an embodiment of the computer program product of the present application. Detailed Embodiments
[0023] Next, embodiments of the technical solution of the present application will be described in detail with reference to the accompanying drawings. The following embodiments are only used to illustrate the technical solution of the present application more clearly, so they are only examples and cannot be used to limit the protection scope of the present application.
[0024] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the technical field to which the present application belongs; the terms used herein are only for the purpose of describing specific embodiments and are not intended to limit the present application; the terms "including" and "having" and any variations thereof in the specification and claims of the present application and the above accompanying drawings are intended to cover non-exclusive inclusion.
[0025] References to "embodiments" in this specification mean that the particular features, structures, or characteristics described in connection with the embodiments can be included in at least one embodiment of the present application. The phrase may occur in various places in the specification and is not necessarily referring to the same embodiment, nor is it an independent or alternative embodiment mutually exclusive of other embodiments. Those skilled in the art will explicitly and implicitly understand that the embodiments described herein can be combined with other embodiments.
[0026] In the description of the embodiments of the present application, technical terms such as "first" and "second" are only used to distinguish different objects, and cannot be construed as indicating or implying relative importance or implicitly specifying the quantity, specific order, or primary and secondary relationship of the indicated technical features. In the description of the embodiments of the present application, the meaning of "a plurality" is two or more, unless otherwise specifically and clearly defined.
[0027] In the description of the embodiments of the present application, the term "and / or" is merely a description of the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B may represent: A exists alone, A and B exist simultaneously, and B exists alone. In addition, the character " / " in this document generally represents an "or" relationship between the associated objects before and after.
[0028] In the description of the embodiments of the present application, the term "a plurality" refers to two or more (including two). Similarly, "multiple groups" refers to two or more groups (including two groups), and "multiple pieces" refers to two or more pieces (including two pieces).
[0029] In the description of the embodiments of the present application, unless otherwise clearly specified and limited, technical terms such as "installation", "connection", "connection", and "fixation" should be understood in a broad sense. For example, it may be a fixed connection, a detachable connection, or integrated; it may also be a mechanical connection or an electrical connection; it may be directly connected or indirectly connected through an intermediate medium, and it may be the communication inside two components or the interaction relationship between two components. For those of ordinary skill in the art, the specific meanings of the above terms in the embodiments of the present application can be understood according to specific circumstances.
[0030] Before introducing the technical solution of the present application, a brief introduction to the related technology is given first.
[0031] Refer to Figure 1 , Figure 1 is a schematic structural diagram of an audio file.
[0032] In a Midi file, its structure consists of a file header and multiple segments of track data. The file header includes the number of track data segments contained in the Midi file and the storage location of each track data segment in the file. Each segment of track data is composed of a lot of time difference data and event data, and each time difference data corresponds to an event data. The time difference is defined as the time difference between the time when the current event occurs and the time when the previous event occurred in the current track data. An event is defined as a data element including pitch, loudness, etc.
[0033] When parsing a Midi file under the Android system, first parse the file header of the Midi file to find each segment of track data, and then parse it according to the following steps.
[0034] Step 1, parse the first time difference data of each track, update the time difference to the time axis of the corresponding track, and find the track with the smallest time as the first track to be parsed.
[0035] Step 2, start parsing from the track found above, and parse the event data corresponding to the first time difference data. After the parsing of this event data is completed, parse the next time difference data and event data. And the current time position is the starting position of the next time difference data. Only after parsing the current time difference data and event data can the next time difference data and event data be parsed. Although the event data is not used in this process, the parsing process of the event data is inevitable.
[0036] Step 3, when the parsing of the first event data of these tracks is completed, update the time axis of the track using the time difference. Assume that the time axis of the current track is T1 and the time difference is t1, then the updated time of the current track is T2, and T2 = T1 + t1.
[0037] Step 4, continue to determine the track with the smallest time from the time axes of all updated tracks, and obtain the time T3 of this track. Then the playing time of the first event is T3 - T1. Then the playing duration of the entire file is updated to: file playing duration = file playing duration + (T3 - T1).
[0038] Step 5, parse the time difference data and event data of this track, update the time axis of the track according to the time difference, and update the file playing duration using the method of Step 4.
[0039] Step 6, repeat the operations of Step 4 and 5 until the entire file is parsed, and then obtain the playing duration of the entire file.
[0040] Specifically, taking a Midi file with a size of 5MB as an example, this file has 10 tracks. The data size of each track is 500KB. Assuming that each time difference and event occupy 20 bytes, and the time differences of each track increase in the order of the tracks, each parsing starts with parsing the first track, then the second track, and so on until the tenth track, and then the first track again, repeating the parsing until the entire file is parsed.
[0041] If parsing is performed according to the above steps, assuming that the system cache is 32KB, which is smaller than the data volume of each track, then when parsing data each time, other data in the 32KB of data containing the current time difference and event cannot be utilized during the next parsing because the next time difference and event to be parsed are in the next track, with a difference of 500KB from the current position data. Therefore, the system needs to re-acquire 32KB of cache data. It is equivalent to the number of times of reading the cache required to complete the parsing of the entire file being 6144 (5MB / 20B), and the total amount of cache data to be read is 192MB (6144 x 32KB).
[0042] In the above steps, the data obtained during each caching is not utilized. Therefore, when parsing the entire file to obtain its playback duration, the amount of cache data required far exceeds the original data volume of the file, increasing the time-consuming of parsing the file and reducing the file playback efficiency. Therefore, this application proposes a file scanning method and related device, specifically referring to the following embodiments.
[0043] Refer to Figure 2 , Figure 2 which is a schematic flowchart of the first embodiment of the audio file scanning method of this application. It includes but is not limited to the following steps.
[0044] S11: Obtain a target audio file, where the target audio file includes multiple segments of track data, and each segment of track data includes multiple frame data, and each frame data is composed of time difference data and event data.
[0045] The target audio file may include a Midi file. Refer to Figure 1 ,the target audio file is composed of multiple segments of track data, each segment of track data includes multiple frame data, each frame data includes an event data and a corresponding time difference data. The time difference is defined as the time difference between the occurrence time of the current event and the occurrence time of the previous event in the current track data. The event is defined as a data element including pitch, loudness, etc.
[0046] S12: Parse the target audio file to obtain the playback duration of each segment of track data.
[0047] Parse each segment of track data in the target audio file according to the data storage order of the track data to obtain the playback duration of each segment of track data.
[0048] S13: Select the longest playing duration from the playing durations of all track data as the playing duration of the target audio file.
[0049] In this application, after obtaining the target audio file, parse the target audio file to obtain the playing duration corresponding to each track data, and select the longest playing duration from the playing durations of all track data as the playing duration of the target audio file. By directly obtaining the playing durations of each track file and determining the playing duration of the file therefrom, it avoids the need to frequently scan the entire target audio file when updating the playing duration of the target audio file through a single time difference data, saves the file scanning time, improves the file scanning speed, and improves the file playing efficiency.
[0050] Refer to Figure 3 , Figure 3 is a schematic flowchart of the second embodiment of the audio file scanning method of this application. This method is a further expansion of step S12 and includes but is not limited to the following steps.
[0051] S21: Obtain the target segment track data from the target audio file.
[0052] When parsing the target audio file to obtain the playing duration of each segment of track data, first obtain the target segment track data from the target audio file.
[0053] Specifically, the target audio file can be obtained according to the data storage order of the target audio file. The first segment of track data in the target audio file is used as the first target audio file. After parsing is completed, obtain the next segment of track data as the new target audio file, and so on after parsing is completed to obtain subsequent target audio files.
[0054] S22: Parse the target segment track data to obtain the playing duration of the target segment track data.
[0055] After obtaining the target track data, parse it and obtain its corresponding playing duration based on the time difference data it includes.
[0056] S23: Continue to obtain new target segment track data from the target audio file and obtain the corresponding playing duration until the playing duration of each segment of track data is obtained.
[0057] Repeat the above operations for each track data to obtain their respective corresponding playing durations.
[0058] The parsing process of each track data can be carried out sequentially or synchronously. For example, first parse the first track data, then parse the second track data, and so on, parsing one track data each time. Or, parse multiple track data synchronously.
[0059] In this application, instead of parsing the file in the order of the time differences in the entire file and updating and obtaining the playback duration of the file, each track data is regarded as a whole for parsing, its playback duration is obtained, and then the longest duration is determined from all the playback durations as the playback duration of the target audio file, thereby saving the file scanning time, improving the file scanning speed, and improving the file playback efficiency.
[0060] Refer to Figure 4 , Figure 4 which is a schematic flowchart of the third embodiment of the audio file scanning method of this application. This method is a further expansion of step S22 and includes but is not limited to the following steps.
[0061] S31: Update the initial timeline time according to the time difference data in all frame data of the target track data.
[0062] When parsing the target track data to obtain the playback duration of the target track data, obtain the playback duration according to the time difference data of each frame data in the target track data.
[0063] S32: Use the updated timeline time as the playback duration of the target track data.
[0064] The initial timeline time can be set to start from zero, and the finally updated timeline time is the playback duration of this track.
[0065] In one embodiment, if it does not start from zero, then the finally updated timeline time minus the initially set timeline time is the playback duration of this track.
[0066] Refer to Figure 5 , Figure 5 which is a schematic flowchart of the fourth embodiment of the audio file scanning method of this application. This method is a further expansion of step S31 and includes but is not limited to the following steps.
[0067] S41: Read frame data from the target track data according to the data storage order.
[0068] When updating the initial timeline time according to the time difference data in all frame data of the target track data, parse the frame data according to the data storage data of the target track data.
[0069] S42: Update the timeline time according to the time difference data in the current frame data.
[0070] S43: After updating the timeline time, continue to update the timeline time according to the time difference data in the next frame data until the timeline time has been updated for all frame data.
[0071] After obtaining the time difference data of the first frame data, update the initial timeline time according to the time difference data. After parsing the first time difference data and the corresponding event data, obtain the time difference data in the next frame data of the target segment audio track data to continue updating the timeline time until the current segment audio track data has been parsed. The updated timeline time is used as the playing duration of the segment audio track data.
[0072] In one embodiment, updating the timeline time according to the time difference data in the current frame data includes: adding the time difference corresponding to the time difference data to the timeline time to complete the update of the timeline time.
[0073] Refer to Figure 6 , Figure 6 is a schematic flowchart of the fifth embodiment of the audio file scanning method of the present application. This method is a further expansion of step S13, and it includes but is not limited to the following steps.
[0074] S51: Use the playing duration of the target segment audio track data as the playing duration of the target audio file.
[0075] When selecting the longest playing duration from the playing durations of all audio track data as the playing duration of the target audio file, after obtaining the playing duration of the target segment audio track data according to the above steps, first use it as the playing duration of the target audio file.
[0076] Then, after obtaining the playing duration of the new target segment audio track data, compare it with the current playing duration of the target audio file and update the playing duration of the target audio file. When the playing duration of the new target segment audio track data is greater than the playing duration of the target audio file, execute step S52. When the playing duration of the new target segment audio track data is less than or equal to the playing duration of the target audio file, execute step S53.
[0077] S52: Use the playing duration of the new target segment audio track data as the playing duration of the target audio file.
[0078] S53: Keep the playing duration of the target audio file unchanged.
[0079] S54: Obtain the new target segment audio track data and continue to compare the playing durations of the new target segment audio track data until the playing durations of all audio track data have been compared to obtain the playing duration of the target audio file.
[0080] Repeat the above comparison steps until the playback durations of all track data are compared, and finally update the playback duration of the obtained target audio file, which corresponds to the playback duration of the target segment track data with the longest duration.
[0081] If the above steps of the present application are followed for parsing, taking a Midi file of 5MB in size as an example, the file has 10 tracks, and the data size of each track is 500KB. Assuming that each time difference and event occupy 20 bytes and the system cache is 32KB, since the track data is parsed in the order of data storage, the number of times of reading the cache required for parsing the entire file is 160 (5MB / 32KB), and the total amount of data to be read from the cache is 5MB.
[0082] By the above method of the present application, the file scanning time is saved, the file scanning speed is increased, the I / O interaction data volume of the system can also be reduced, and the file playback efficiency is improved.
[0083] Refer to Figure 7 , Figure 7 which is a schematic structural diagram of an embodiment of the audio file scanning device of the present application.
[0084] The audio file scanning device includes a file acquisition module 110 and a file scanning module 120.
[0085] The file acquisition module 110 is used to acquire a target audio file, the target audio file includes multiple segments of track data, each segment of track data includes multiple frame data, and each frame data is composed of time difference data and event data.
[0086] The file scanning module 120 is used to parse the target audio file to obtain the playback duration of each segment of track data, and select the longest playback duration from the playback durations of all track data as the playback duration of the target audio file.
[0087] When the file scanning module 120 executes the step of parsing the target audio file to obtain the playback duration of each segment of track data, it includes obtaining target segment track data from the target audio file; parsing the target segment track data to obtain the playback duration of the target segment track data; continuing to obtain new target segment track data from the target audio file and obtaining the corresponding playback duration until the playback duration of each segment of track data is obtained.
[0088] When the file scanning module 120 executes the step of parsing the target segment track data to obtain the playback duration of the target segment track data, it includes updating the initial time axis time according to the time difference data in all frame data of the target segment track data; using the updated time axis time as the playback duration of the target segment track data.
[0089] When the file scanning module 120 executes the step of updating the initial timeline time according to the time difference data in all frame data of the target segment audio track data, it includes reading the frame data from the target segment audio track data according to the data storage order; updating the timeline time according to the time difference data in the current frame data; after updating the timeline time, continuing to update the timeline time according to the time difference data in the next frame data until all frame data have completed the update of the timeline time.
[0090] When the file scanning module 120 executes the step of updating the timeline time according to the time difference data in the current frame data, it includes adding the time difference corresponding to the time difference data to the timeline time to complete the update of the timeline time.
[0091] When the file scanning module 120 executes the step of selecting the longest playing duration from the playing durations of all audio track data as the playing duration of the target audio file, it includes taking the playing duration of the target segment audio track data as the playing duration of the target audio file; when the playing duration of the new target segment audio track data is greater than the playing duration of the target audio file, taking the playing duration of the new target segment audio track data as the playing duration of the target audio file; when the playing duration of the new target segment audio track data is less than or equal to the playing duration of the target audio file, keeping the playing duration of the target audio file unchanged; obtaining the new target segment audio track data and continuing to compare the playing durations of the new target segment audio track data until the playing durations of all audio track data have been compared to obtain the playing duration of the target audio file.
[0092] For similar descriptions in the above steps, reference can be made to the descriptions in the above embodiments.
[0093] The file scanning module 120 can implement the methods provided by any embodiment and possible combinations in the file scanning method of the present application.
[0094] Refer to Figure 8 , Figure 8 which is a schematic structural diagram of an embodiment of the audio file playing system of the present application.
[0095] The audio file playing system includes an audio file scanning device 210 and a file playing module 220 as provided in the embodiment of the audio file scanning device of the present application.
[0096] The audio file scanning device 210 is used to scan the target audio file to obtain the playing duration of the target audio file.
[0097] The audio file scanning device 210 is used to obtain the target audio file, parse the target audio file to obtain the playing duration of each segment of audio track data, and select the longest playing duration from the playing durations of all audio track data as the playing duration of the target audio file.
[0098] When the audio file scanning device 210 executes the step of parsing the target audio file to obtain the playing duration of each track data segment, it includes obtaining the target track data segment from the target audio file; parsing the target track data segment to obtain the playing duration of the target track data segment; continuing to obtain a new target track data segment from the target audio file and obtaining the corresponding playing duration until the playing duration of each track data segment is obtained.
[0099] When the audio file scanning device 210 executes the step of parsing the target track data segment to obtain the playing duration of the target track data segment, it includes updating the initial time axis time according to the time difference data in all frame data of the target track data segment; using the updated time axis time as the playing duration of the target track data segment.
[0100] When the audio file scanning device 210 executes the step of updating the initial time axis time according to the time difference data in all frame data of the target track data segment, it includes reading frame data from the target track data segment according to the data storage order; updating the time axis time according to the time difference data in the current frame data; after updating the time axis time, continuing to update the time axis time according to the time difference data in the next frame data until all frame data have completed the update of the time axis time.
[0101] When the audio file scanning device 210 executes the step of updating the time axis time according to the time difference data in the current frame data, it includes adding the time difference corresponding to the time difference data to the time axis time to complete the update of the time axis time.
[0102] When the audio file scanning device 210 executes the step of selecting the longest playing duration from the playing durations of all track data segments as the playing duration of the target audio file, it includes using the playing duration of the target track data segment as the playing duration of the target audio file; when the playing duration of the new target track data segment is greater than the playing duration of the target audio file, using the playing duration of the new target track data segment as the playing duration of the target audio file; when the playing duration of the new target track data segment is less than or equal to the playing duration of the target audio file, keeping the playing duration of the target audio file unchanged; obtaining a new target track data segment and continuing to compare the playing durations of the new target track data segments until the playing durations of all track data segments have been compared to obtain the playing duration of the target audio file.
[0103] For similar descriptions in the above steps, reference can be made to the descriptions in the above embodiments.
[0104] The file playback module 220 is used to play the target audio file after obtaining the playback duration of the target audio file. The playback duration of the target audio file can be obtained from the audio file scanning device 210.
[0105] As Figure 9 shown, Figure 9 This is a schematic structural diagram of an embodiment of the electronic device of the present application.
[0106] The electronic device includes a processor 310 and a memory 320.
[0107] The processor 310 controls the operation of the electronic device. The processor 310 can also be referred to as a CPU (Central Processing Unit, central processing unit). The processor 310 may be an integrated circuit chip with the ability to process signal sequences. The processor 310 can also be a general-purpose processor, a digital signal sequence processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc.
[0108] The memory 320 stores the instructions and program data required for the operation of the processor 310.
[0109] The processor 310 is used to execute instructions to implement the method provided by any embodiment and possible combinations in the aforementioned file scanning method of the present application.
[0110] As Figure 10 shown, Figure 10 This is a schematic structural diagram of an embodiment of the computer-readable storage medium of the present application.
[0111] An embodiment of the readable storage medium of the present application includes a memory 410. The memory 410 stores computer-executable instructions. When the computer-executable instructions are executed, the method provided by any embodiment and possible combinations in the file scanning method of the present application is implemented.
[0112] The memory 410 can include media such as a USB flash drive, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a magnetic disk, or an optical disc that can store program instructions. Or it can also be a server storing the program instructions. The server can send the stored program instructions to other devices for running, or it can also run the stored program instructions by itself.
[0113] As Figure 11 shown, Figure 11This is a schematic structural diagram of an embodiment of the computer program product of the present application.
[0114] One embodiment of the computer program product of the present application includes a memory 510, which stores a computer program. When the computer program is executed, it implements the methods provided by any one of the embodiments and possible combinations in the file scanning method of the present application document.
[0115] The memory 510 may include media such as USB flash drives, external hard drives, read-only memories (ROMs), random access memories (RAMs), magnetic disks, or optical discs that can store program instructions. Or it may also be a server storing the program instructions, which can send the stored program instructions to other devices for running, or can also run the stored program instructions by itself.
[0116] In summary, after obtaining the target audio file, parse the target audio file to obtain the playback duration corresponding to each audio track data, select the one with the longest playback duration from the playback durations of all audio track data as the playback duration of the target audio file. By directly obtaining the playback durations of each audio track file and determining the playback duration of the file therefrom, it avoids the need to frequently scan the entire target audio file when updating the playback duration of the target audio file through a single time difference data, saves the file scanning time, improves the file scanning speed, and improves the file playback efficiency.
[0117] In several implementation manners provided by the present application, it should be understood that the disclosed methods and devices can be implemented in other ways. For example, the device implementation manners described above are only illustrative. For example, the division of the modules or units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed.
[0118] The units described as separate components may or may not be physically separated. The components shown as units may or may not be physical units, that is, they can be located in one place or distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this implementation manner.
[0119] In addition, each functional unit in various implementation manners of the present application can be integrated in a processing unit, or each unit can exist physically alone, or two or more units can be integrated in one unit. The above integrated units can be implemented in the form of hardware or in the form of software functional units.
[0120] If the integrated units in the above-mentioned other embodiments are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) or a processor to execute all or part of the steps of the methods described in various embodiments of this application. The foregoing storage medium includes: various media that can store program codes, such as USB flash drives, mobile hard disks, read-only memories (ROMs), random access memories (RAMs), magnetic disks, or optical discs.
[0121] The above are only the embodiments of this application, and do not limit the patent scope of this application accordingly. Any equivalent structural or equivalent process transformation made by using the content of the specification and drawings of this application, or directly or indirectly applied in other related technical fields, shall be equally included in the patent protection scope of this application.
Claims
1. An audio file scanning method, characterized in that, The method includes: Obtaining a target audio file, where the target audio file includes multiple tracks of audio data, each track of audio data includes multiple frame data, and each frame data is composed of time difference data and event data; Parsing the target audio file to obtain the playing duration of each track of audio data; Selecting the longest playing duration from the playing durations of all the tracks of audio data as the playing duration of the target audio file.
2. The method according to claim 1, characterized in that The parsing the target audio file to obtain the playing duration of each track of audio data includes: Obtaining target track audio data from the target audio file; Parsing the target track audio data to obtain the playing duration of the target track audio data; Continuing to obtain new target track audio data from the target audio file and obtaining the corresponding playing duration until the playing duration of each track of audio data is obtained.
3. The method according to claim 2, characterized in that, The parsing the target track audio data to obtain the playing duration of the target track audio data includes: Updating the initial time axis time according to the time difference data in all the frame data in the target track audio data; Taking the updated time axis time as the playing duration of the target track audio data.
4. The method according to claim 3, characterized in that, The updating the initial time axis time according to the time difference data in all the frame data in the target track audio data includes: Reading the frame data from the target track audio data according to the data storage order; Updating the time axis time according to the time difference data in the current frame data; After updating the time axis time, continue to update the time axis time according to the time difference data in the next frame data until all the frame data have completed the update of the time axis time.
5. The method according to claim 4, wherein The updating the time axis time according to the time difference data in the current frame data includes: Adding the time difference corresponding to the time difference data to the time axis time to complete the update of the time axis time.
6. The method according to claim 2, wherein The selecting the longest playing duration from the playing durations of all the tracks of audio data as the playing duration of the target audio file includes: Taking the playing duration of the target track audio data as the playing duration of the target audio file; When the playing duration of the new target track audio data is greater than the playing duration of the target audio file, taking the playing duration of the new target track audio data as the playing duration of the target audio file; when the playing duration of the new target track audio data is less than or equal to the playing duration of the target audio file, keeping the playing duration of the target audio file unchanged; Obtaining the new target track audio data and continuing to compare the playing durations of the new target track audio data until the playing durations of all the tracks of audio data have been compared to obtain the playing duration of the target audio file.
7. An audio file scanning device, characterized in that, including: A file acquisition module for obtaining a target audio file, where the target audio file includes multiple tracks of audio data, each track of audio data includes multiple frame data, and each frame data is composed of time difference data and event data; A file scanning module, configured to parse the target audio file to obtain the playing duration of each piece of the track data, and select the longest playing duration from the playing durations of all the track data as the playing duration of the target audio file.
8. An audio file playback system, characterized in that, Comprising: The audio file scanning device according to claim 7, configured to scan a target audio file to obtain the playing duration of the target audio file; A file playing module, configured to play the target audio file after obtaining the playing duration of the target audio file.
9. An electronic device, characterized in that, Comprising a memory and a processor, the memory is configured to store program data, and the program data can be executed by the processor to implement the method according to any one of claims 1-6.
10. A computer-readable storage medium / computer program product, characterized in that, The computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are executed by a processor, they are used to implement the method according to any one of claims 1-6; The computer program product includes a computer program, and when the computer program is executed by a processor, it implements the method according to any one of claims 1-6.