Vehicle machine media file reading method and device, electronic equipment and storage medium
By monitoring the mount status of external storage in the on-board central control system of Android system, filtering and scanning, and using multi-threading, the problem of slow reading speed of large-capacity storage devices is solved, and the user experience and system performance are improved.
Patent Information
- Application Number
- CN202411243710.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-05
- Publication Date
- 2024-12-27
AI Technical Summary
In the Android system's on-board central control system, media files are read slowly when processing large-capacity storage devices, especially when inserting USB flash drives, IO-intensive full-scan operation consumes a large amount of system resources, resulting in file reading time Longer.
By monitoring the mount status of external storage, obtaining the root directory path, filtering and scanning to obtain media files that meet the preset format and size, using multi-threaded parallel processing, reducing the time to traverse the media files, and using the extracted media information for use in the extracted media information. The car computer screen displays and writes to the local database.
It realizes browsing media files faster when accessing external memory for the first time, improves user experience, reduces the time for media information extraction, and improves system resource utilization.
Smart Images

Figure CN119202280A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a method, device, electronic device and storage medium for reading vehicle-mounted media files. Background Art
[0002] In the in-vehicle central control system based on the Android system, USB media file browsing and viewing is a common multimedia entertainment function. In the current related technology, the media file browsing function is mainly implemented based on the media file information extraction and query function provided by the MediaProvider module in the Android system.
[0003] However, MediaProvider maintains a database to index media files such as music, videos, and pictures in the system's internal and external storage (including USB devices). However, this design is particularly difficult when dealing with large-capacity storage devices (such as USB flash drives). Whenever a new storage device is connected, MediaProvider needs to perform a comprehensive scan operation, which is IO-intensive and consumes a lot of system resources.
[0004] When the USB flash drive is inserted, if there are many media files in the USB flash drive, the IO operations on a large number of large files will cause the reading speed of the media files to be very slow. After testing, if there are about 20,000 audio and video files, the reading time may even reach more than 10 minutes. Summary of the invention
[0005] In view of the shortcomings of the above-mentioned related technologies, the present application provides a method, device, electronic device and storage medium for reading media files on a vehicle computer to solve the technical problem of slow reading of media files on a vehicle computer.
[0006] The present application provides a method for reading media files on a vehicle computer, and the method comprises: monitoring the external storage mounting status of the vehicle computer, and if the external storage mounting status is mounted, obtaining the root directory path of the mounted external storage; filtering and scanning the external storage based on the root directory path to obtain a filtering and scanning result list, wherein the filtering and scanning result list comprises a plurality of media files whose file formats are preset formats, whose file sizes are greater than a preset memory threshold, and whose hidden status is non-hidden; extracting media information from the external storage according to the filtering and scanning result list, and using the extracted media information for display on the vehicle computer screen and writing into a local database.
[0007] In one embodiment of the present application, the external memory is filtered and scanned based on the root directory path, and a filtered scan result list is obtained, including: obtaining a project list and the number of projects based on the root directory path; obtaining a scan step for each thread based on the number of projects and a preset number of scan threads; assigning a scan task list to each thread based on the scan step and the project list, the scan task list including the start project position and the end project position of each thread scan, and setting a synchronization counter based on the preset number of scan threads to monitor each thread; when a thread completes the scan task, the synchronization counter is reduced by 1 until the synchronization counter counts to completion, and the filtered scan of the external memory is completed.
[0008] In one embodiment of the present application, filtering and scanning the external memory based on the root directory path to obtain a filtering and scanning result list also includes: the thread starts to traverse the scanning task list based on the starting item position to determine the item type of the current traversal item; if the item type of the current traversal item is a file, the file format, file size and hidden state of the file are obtained; if the file format of the file is the preset format, the file size is greater than the preset memory threshold, and the hidden state of the file is non-hidden, the file is taken as a media file and the media file is added to the filtering and scanning result list; if the item type of the current traversal item is a folder, the hidden state of the folder is obtained; if the hidden state of the folder is non-hidden, the folder is taken as a folder to be scanned; the folder to be scanned is traversed, the media files in the folder to be scanned are added to the filtering and scanning result list, and the folder in the folder to be scanned with a hidden state of non-hidden is taken as a new folder to be scanned, until all the folders to be scanned are traversed.
[0009] In one embodiment of the present application, the vehicle computer media file reading method also includes: initializing the mount listener of the vehicle computer, the mount listener is used to listen to and query the external storage mounting status of the vehicle computer; if the mount listener listens to a new external storage mounting message or queries that the external storage has been mounted, the external storage mounting status is set to mounted; the mount listener obtains the device information of the external storage based on the mount broadcast of the external storage, and the device information includes the device type; the external storage is filtered based on the device type, and the external storage with the preset device type is filtered and scanned based on the root directory path of the external storage with the preset device type.
[0010] In one embodiment of the present application, the filtering scan result list includes the media files and file information corresponding to the media files, and the file information at least includes file name, file path, file format, file size, and last modification time.
[0011] In one embodiment of the present application, extracting media information from an external memory according to the filtered scan result list includes: obtaining the number of media according to the filtered scan result list; obtaining the extraction step of each thread based on the number of media and the preset number of extraction threads; allocating an extraction task list to each thread according to the extraction step and the filtered scan result list, the extraction task list including the starting media position and the ending media position extracted by each thread, and setting a synchronization counter based on the preset number of extraction threads to monitor each thread; when a thread completes the extraction task, the synchronization counter is reduced by 1 until the synchronization counter counts to completion, and the extraction of media information from the external memory is completed.
[0012] In one embodiment of the present application, an extraction task list is assigned to each thread, and the extraction task list includes the starting media position and the ending media position extracted by each thread, and also includes: obtaining the current display list of the vehicle screen, assigning an extraction task list to each thread based on the current display list, and assigning the media files in the current display list to each thread; when the number of completed extractions of the multiple threads exceeds a preset number threshold, returning the extracted media information so that the vehicle screen displays the media information of the current display list.
[0013] An embodiment of the present application also provides a vehicle-mounted media file reading device, which includes: a monitoring and reading module, which is used to monitor the external storage mounting status of the vehicle-mounted device, and if the external storage mounting status is mounted, obtain the root directory path of the mounted external storage device; a filtering and scanning module, which is used to filter and scan the external storage device based on the root directory path to obtain a filtering and scanning result list, wherein the filtering and scanning result list includes multiple media files with a preset format, a file size greater than a preset memory threshold, and a hidden status of non-hidden; an information extraction module, which is used to extract media information from the external storage device according to the filtering and scanning result list, and use the extracted media information for vehicle-mounted screen display and writing into a local database.
[0014] An embodiment of the present application also provides an electronic device, comprising: one or more processors; a storage device for storing one or more programs, and when the one or more programs are executed by the one or more processors, the electronic device implements the vehicle-mounted media file reading method as described in any of the above embodiments.
[0015] An embodiment of the present application further provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor of a computer, the computer executes the vehicle-machine media file reading method as described in any of the above embodiments.
[0016] The beneficial effects of the present application include: a method, device, electronic device and storage medium for reading media files on a vehicle computer, the method comprising monitoring the external storage mounting status of the vehicle computer, obtaining the root directory path of the mounted external storage if the external storage mounting status is mounted, filtering and scanning the external storage based on the root directory path to obtain a filtering and scanning result list, the filtering and scanning result list comprising multiple media files with a preset format, a file size greater than a preset memory threshold and a hidden status of non-hidden, extracting media information from the external storage according to the filtering and scanning result list, and using the extracted media information for display on the vehicle computer screen and writing it into a local database, filtering and scanning the external storage based on the root directory path to reduce the time for traversing media files when extracting media information, thereby enabling faster browsing of media files when the external storage is first accessed, thereby improving user experience.
[0017] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] Figure 1 is a schematic diagram of an implementation environment of a vehicle-mounted media file reading method shown in an exemplary embodiment of the present application;
[0019] Figure 2 is a flow chart of a method for reading a vehicle computer media file according to an exemplary embodiment of the present application;
[0020] Figure 3 is a flowchart of vehicle computer media file reading execution shown in an exemplary embodiment of the present application;
[0021] Figure 4 is a filtering scanning flow chart shown in an exemplary embodiment of the present application;
[0022] Figure 5 is a block diagram of a vehicle-mounted media file reading device shown in an exemplary embodiment of the present application;
[0023] Figure 6 It is a structural schematic diagram of an electronic device shown in an exemplary embodiment of the present application. DETAILED DESCRIPTION
[0024] The following describes the embodiments of the present application through specific examples, and those skilled in the art can easily understand other advantages and effects of the present application from the contents disclosed in this specification. The present application can also be implemented or applied through other different specific embodiments, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present application. It should be noted that the following embodiments and features in the embodiments can be combined with each other without conflict.
[0025] It should be noted that the illustrations provided in the following embodiments are only schematic illustrations of the basic concept of the present application, and thus the drawings only show components related to the present application rather than being drawn according to the number, shape and size of components in actual implementation. In actual implementation, the type, quantity and proportion of each component may be changed at will, and the component layout may also be more complicated.
[0026] It should be noted that in this application, "first", "second", etc. are only used to distinguish similar objects, and are not used to limit the order or precedence of similar objects. The variations of "including", "having", etc. described above indicate that the scope covered by the subject of the word is not exclusive except for the examples shown by the word.
[0027] It is understood that the various numbers, step numbers, etc. recorded in this application are distinguished for the convenience of description and are not used to limit the scope of this application. The size of the numbers in this application does not mean the order of execution. The execution order of each process should be determined by its function and internal logic.
[0028] In the following description, a large number of details are discussed to provide a more thorough explanation of the embodiments of the present application. However, it is obvious to those skilled in the art that the embodiments of the present application can be implemented without these specific details. In other embodiments, well-known structures and devices are shown in the form of block diagrams rather than in detail to avoid making the embodiments of the present application difficult to understand.
[0029] The embodiments of the present application respectively propose a vehicle-mounted media file reading method, a vehicle-mounted media file reading device, an electronic device, a computer-readable storage medium, and a computer program product, which will be described in detail below.
[0030] See also Figure 1 , Figure 1 It is a schematic diagram of an implementation environment of a vehicle-mounted media file reading method shown in an exemplary embodiment of the present application.
[0031] like Figure 1As shown, the implementation environment may include a vehicle system 101 and an external memory 102, wherein the mount listener in the vehicle system 101 monitors the external memory, and when the external storage mount status is mounted, that is, when the external memory 102 is connected to the vehicle system 101, the vehicle system 101 performs a filter scan on the external memory 102 to obtain a filter scan result list, and extracts media information from the filter scan result list, thereby achieving a rapid response to extracting media information from the external memory 102.
[0032] See also Figure 2 , Figure 2 is a flowchart of a method for reading a vehicle-mounted media file according to an exemplary embodiment of the present application. The method can be applied to Figure 1 The implementation environment shown is as follows. The method may also be applicable to other exemplary implementation environments and be specifically executed by devices in other implementation environments. This embodiment does not limit the implementation environment to which the method is applicable.
[0033] like Figure 2 As shown, in an exemplary embodiment, the vehicle computer media file reading method at least includes steps S210 to S230, which are described in detail as follows:
[0034] Step S210, monitoring the external storage mounting state of the vehicle computer, if the external storage mounting state is mounted, obtaining the root directory path of the mounted external storage.
[0035] In one embodiment of the present application, an initialization operation is performed on the mount listener of the vehicle computer, and the mount listener is used to listen to and query the external storage mounting status of the vehicle computer; if the mount listener listens to a new external storage mounting message or queries that the external storage has been mounted, the external storage mounting status is set to mounted; the mount listener obtains the device information of the external storage based on the mount broadcast of the external storage, and the device information includes the device type; the external storage is filtered based on the device type, and the external storage with a preset device type is filtered and scanned based on the root directory path of the external storage with a preset device type.
[0036] In one embodiment of the present application, the preset type of external storage can be a USB device, then the initialization operation of the vehicle computer's mount listener includes initializing registration to listen to the external storage mount status, and querying the current external storage mount status. If the external storage mount status is queried or monitored to be mounted, the mount listener listens to the current external storage mount broadcast, and after receiving the mount broadcast, queries the UUID of the external storage through the Uri information in the mount broadcast, and obtains the device type of the external storage through the UUID. If the device type is a USB device, the mount listener defines the IMediaStorageStateListener interface, obtains the USB root directory path through the interface, and continues to filter and scan the USB device. If it is not a USB device, the non-USB device is filtered, and the mount listener does not respond.
[0037] Step S220, filtering and scanning the external memory based on the root directory path to obtain a filtering and scanning result list, wherein the filtering and scanning result list includes a plurality of media files whose file formats are preset formats, whose file sizes are larger than a preset memory threshold, and whose hidden states are non-hidden.
[0038] In one embodiment of the present application, the filtered scan result list includes media files and file information corresponding to the media files, and the file information includes at least file name, file path, file format, file size, and last modification time.
[0039] In one embodiment of the present application, file information is basic information of a file or folder, which can be directly read by scanning, including file name, absolute path, file format (file suffix), file size, last modification time, and folder to which it belongs, etc. Media information is media-specific information of a media file, which needs to be extracted, including image resolution, longitude and latitude, image type, audio duration, minetype, singer, album name, video name, duration, resolution, etc.
[0040] In one embodiment of the present application, a filtered scan is performed on an external memory based on a root directory path to obtain a filtered scan result list including: obtaining an item list and the number of items based on the root directory path; obtaining a scan step for each thread based on the number of items and a preset number of scan threads; assigning a scan task list to each thread based on the scan step and the item list, the scan task list including a starting item position and an ending item position for each thread scan, and setting a synchronization counter based on the preset number of scan threads to monitor each thread; when a thread completes an extraction task, the synchronization counter is reduced by 1 until the synchronization counter counts to completion, and the filtered scan of the external memory is completed.
[0041] In one embodiment of the present application, the starting project position and ending project position of each thread scan are the starting project position and ending project position of the thread in the project list, that is, some projects are selected in the project list as the scanning task list. For example, the scanning task list of a certain thread is the 1st to 1000th items in the project list, where the 1st is the starting project position and the 1000th is the ending project position.
[0042] In one embodiment of the present application, the preset number of scanning threads can be set to the maximum number of threads, which is generally twice the number of CPU cores, that is, the preset number of scanning threads for an 8-core CPU is 16.
[0043] In one embodiment of the present application, when performing multi-threaded tasks, it is necessary to wait for each task to be completed before the task can be finally completed, so a synchronization counter needs to be set to monitor each thread to record the task completion status of each thread. The initial value of the counter can be set to a preset number of scanning threads, which can be set according to different hardware devices. In this embodiment, it can be 16, so the initial value of the synchronization counter can be set to 16. When a thread completes a scanning task or an extraction task, the synchronization counter is notified to decrease by 1 until the value of the synchronization counter becomes 0. At this time, the synchronization counter count is completed, indicating that the tasks of all threads are completed and the next task can be performed.
[0044] In one embodiment of the present application, a scanning task list is assigned to each thread according to a scanning step size, including: if the number of items in the project list is 16,000 and the preset number of scanning threads is 16, the scanning step size of each thread is 1,000, and the project list is assigned according to the scanning step size and the project list to obtain a scanning task list for each thread, the scanning task list including the starting project position and the ending project position of each thread scan. For example, in this embodiment, the scanning task list of the first thread is the 1st to the 1,000th item in the project list, and the scanning task list of the second thread is the 1,001st to the 2,000th item in the project list, until all items in the project list are assigned to the scanning task list of each thread for filtered scanning.
[0045] In one embodiment of the present application, filtering and scanning the external memory based on the root directory path to obtain the filtered scan result list also includes: the thread starts to traverse the scan task list based on the starting project position to determine the project type of the current traversal project; if the project type of the current traversal project is a file, the file format, file size and hidden status of the file are obtained; if the file format of the file is a preset format, the file size is greater than the preset memory threshold, and the hidden status of the file is not hidden, the file is taken as a media file and the media file is added to the filtered scan result list; if the project type of the current traversal project is a folder, the hidden status of the folder is obtained; if the hidden status of the folder is not hidden, the folder is taken as a folder to be scanned; the folder to be scanned is traversed, the media files in the folder to be scanned are added to the filtered scan result list, and the folders in the folder to be scanned with a hidden status of non-hidden are taken as new folders to be scanned, until all folders to be scanned are traversed.
[0046] In one embodiment of the present application, first, the thread traverses the scanning task list from the starting project position. For example, if the starting project position of a thread is the first project in the project list, it traverses from the first project in the project list. If the project type of the current traversal project is a file, the file is filtered and scanned based on the file format, file size and hidden state of the file. If the file format of the file is a preset format, the file size is greater than the preset memory threshold, and the hidden state of the file is not hidden, the file is treated as a media file and the media file is added to the filtered scan result list. If the project type of the current traversal project is a folder, the folder with a hidden state of not hidden is used as the folder to be scanned, and the folder with a hidden state of hidden is directly filtered out and no longer scanned. After completing one traversal of the scanning task list, traverse each folder to be scanned again. If the file in the traversed file to be scanned meets the file format of the preset format, the file size is greater than the preset memory threshold, and the hidden state of the file is not hidden, the file is taken as a media file and added to the filtered scanning result list. If the hidden state of the folder in the traversed file to be scanned is not hidden, the folder in the folder to be scanned with a hidden state of not hidden is taken as a new folder to be scanned, and the traversed folder to be scanned is taken as a scanned folder, until all folders to be scanned are traversed, that is, all folders are scanned folders at this time.
[0047] In one embodiment of the present application, the preset format can be set to common media file formats such as MP3, MP4, JPG, etc., and the preset memory threshold can be set to 500kb. If the file format satisfies the preset format, the file size is greater than the preset memory threshold and the hidden state of the file is non-hidden, the file is treated as a media file and the media file is added to the filter scan result list. If the file format of the file is not the preset format, it means that the file is a non-media file and the file is filtered. If the file format of the file is the preset format but the file size is too small (i.e., less than 500kb), it means that the file is an abnormal media file and the file is filtered. If the hidden state of the file is hidden, the file is also filtered.
[0048] In one embodiment of the present application, determining the hidden state of a folder includes: determining whether the folder begins with a dot. If the folder begins with a dot, the hidden state of the folder is hidden. Determining whether the folder contains a .nomedia file. If the folder contains a .nomedia file, the .nomedia file is a convention in the Android system for expressing that the directory is not scanned. Here, its hidden state is also considered to be hidden, and the folder does not need to be added to the filter scan result list. In this embodiment, the hidden state of the root directory folder is non-hidden.
[0049] In one embodiment of the present application, determining the hidden state of a file includes: determining whether the file begins with a dot; if the file begins with a dot, the hidden state of the file is hidden.
[0050] Step S230 , extracting media information from the external memory according to the filtered scan result list, and using the extracted media information for display on the vehicle screen and writing it into the local database.
[0051] In one embodiment of the present application, extracting media information from an external memory according to a filtered scan result list includes: obtaining the number of media according to the filtered scan result list; obtaining the extraction step of each thread based on the number of media and a preset number of extraction threads; assigning an extraction task list to each thread according to the extraction step and the filtered scan result list, the extraction task list including the starting media position and ending media position extracted by each thread, and setting a synchronization counter based on the preset number of extraction threads to monitor each thread; when a thread completes the extraction task, the synchronization counter is reduced by 1 until the synchronization counter counts to completion, and the extraction of media information from the external memory is completed.
[0052] In one embodiment of the present application, in one embodiment of the present application, the starting media position and the ending media position extracted by each thread are the starting media position and the ending media position of the thread in the filtered scanning result list, that is, some media files are selected in the filtered scanning result list as the scanning task list, for example, the extraction task list of a certain thread is the 1st media file to the 200th media file in the filtered scanning result list, where the 1st is the starting media position and the 1000th is the ending media position.
[0053] In one embodiment of the present application, since media extraction is an IO time-consuming operation, when setting the preset number of extraction threads, half of the maximum number of threads can be selected for media extraction, and then the extraction task list is allocated to each thread according to the extraction step and the filter scan result list. If the number of media is 1600 and the maximum number of threads is 16, then the preset number of extraction threads is set to 8, that is, 8 threads are occupied for media extraction, and the extraction step of each thread is 200. Then, according to the extraction step and the filter scan result list, the filter scan result list is allocated to obtain the extraction task list of each thread, and the extraction task list includes the starting media position and the ending media position extracted by each thread. For example, in this embodiment, the extraction task list of the first thread is the 1st to 200th media files in the filter scan result list, and the extraction task list of the second thread is the 201st to 400th media files in the filter scan result list, until all media files in the filter scan result list are allocated to the extraction task list of each thread for media information extraction.
[0054] In one embodiment of the present application, media information extraction includes extracting media information of a media file through a system API MediaMetadataRetriever, which is a class provided by Android for obtaining metadata of a media file. It can extract various information of audio and video files from local files or network resources, such as duration, resolution, encoding format, artist, title, etc.
[0055] In one embodiment of the present application, an extraction task list is assigned to each thread, and the extraction task list includes the starting media position and the ending media position extracted by each thread and also includes: obtaining the current display list of the vehicle screen, assigning the extraction task list to each thread based on the current display list, and assigning the media files in the current display list to each thread; when the number of completed extractions of multiple threads exceeds a preset number threshold, the extracted media information is returned so that the vehicle screen can display the media information of the current display list.
[0056] In one embodiment of the present application, when the user has viewed media file information on the vehicle screen, in order to ensure that the media information of the media file that the user is viewing is displayed first, the current display list of the vehicle screen is obtained, and the media files in the current display list are preferentially allocated to each thread, so that each thread gives priority to extracting media information from the media files in the current display list, and when the extraction task completion amount of all threads exceeds a preset threshold (which can be set to 50), the extracted media information is first returned to the vehicle screen for display to improve the response speed of the user viewing the media information, and the extracted media information is also written to the local database for easy viewing next time.
[0057] See also Figure 3 , Figure 3 The flowchart of the vehicle-mounted media file reading execution is shown in an exemplary embodiment of the present application. In one embodiment of the present application, the vehicle-mounted media file reading execution flow chart includes an Application module, a USB mount status listener (i.e., a mount listener), a content management module, a media information extraction module, a USB content scanning module, and a data storage module. When the vehicle-mounted media file reading is executed, the Application module first initializes the USB mount status listener. When the USB mount listener detects that a USB device is mounted successfully, the content management module is notified to traverse. When the content management module receives the message of successful USB mounting, the root directory path of the USB device is obtained, and the root directory path is passed to the USB content scanning module, so that the USB content scanning module can A filtering scan is performed on the root directory path. After the USB content scanning module performs the filtering scan, a filtering scan result list is obtained, and the content management module is notified that the scanning is completed, so that the content management module sends the filtering scan result list to the Application module, so that the Application module updates the media file list. At the same time, the content management module sends the filtering scan result list to the media information extraction module, so that the media information extraction module extracts the media information based on the filtering scan result list, and returns the extracted media information to the content management module and stores it in the local database. The content management module sends the received media information to the Application module, so that the Application module updates and displays it based on the extracted media information.
[0058] See also Figure 4 , Figure 4It is a filtering scanning flow chart shown in an exemplary embodiment of the present application. In one embodiment of the present application, first input the folder path (the first input is the root directory path), list all folders and folders under the root directory path (i.e., the project list), calculate the number of threads required to traverse the folder list (i.e., the project list) (which can be set to a preset number of scanning threads), calculate the number of files or folders that each thread needs to process based on the preset number of scanning threads and the number of projects (scanning step length), calculate the starting position and ending position of the part that each thread needs to process in the project list based on the scanning step length, set a synchronization counter for the number of scanning threads, start a corresponding number of threads and start filtering scanning, filtering scanning includes determining the file type, that is, determining whether the project type is a file or folder, if the project type is a file with a preset format or a folder, then determining whether the project is a hidden file or a hidden folder, if it is hidden, filter the project, if it is not hidden, add files with a preset format and a file size greater than 500kb to the filtering scanning result list, and continue to use the non-hidden folder as the input folder path for filtering scanning in the above steps until all folders are filtered and scanned.
[0059] See also Figure 5 , Figure 5 is a block diagram of a vehicle-mounted media file reading device shown in an exemplary embodiment of the present application. The device can be applied to Figure 1 The implementation environment shown is as follows. The device may also be applicable to other exemplary implementation environments and specifically configured in other devices. This embodiment does not limit the implementation environment to which the device is applicable.
[0060] like Figure 5 As shown, the exemplary vehicle-mounted media file reading device includes:
[0061] The monitoring and reading module 501 is used to monitor the external storage mounting state of the vehicle computer, and if the external storage mounting state is mounted, obtain the root directory path of the mounted external storage;
[0062] A filtering scanning module 502 is used to perform filtering scanning on the external memory based on the root directory path to obtain a filtering scanning result list, wherein the filtering scanning result list includes a plurality of media files whose file formats are preset formats, whose file sizes are larger than a preset memory threshold, and whose hidden status is non-hidden;
[0063] The information extraction module 503 is used to extract media information from the external memory according to the filtered scanning result list, and use the extracted media information for display on the vehicle screen and write it into the local database.
[0064] Figure 6The structure diagram of the computer system suitable for implementing the electronic device of the embodiment of the present application is shown. It should be noted that: Figure 6 The computer system 600 of the electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0065] like Figure 6 As shown, the computer system 600 includes a central processing unit (CPU) 601, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 602 or the program loaded from the storage part 608 to the random access memory (RAM) 603, such as executing the method described in the above embodiment. In the RAM 603, various programs and data required for system operation are also stored. The CPU 601, ROM 602 and RAM 603 are connected to each other through a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0066] The following components are connected to the I / O interface 605: an input section 606 including a keyboard, a mouse, etc.; an output section 607 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 608 including a hard disk, etc.; and a communication section 609 including a network interface card such as a LAN (Local Area Network) card, a modem, etc. The communication section 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to the I / O interface 605 as needed. A removable medium 611, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 610 as needed so that a computer program read therefrom is installed into the storage section 608 as needed.
[0067] In particular, according to an embodiment of the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a computer program for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication section 609, and / or installed from a removable medium 611. When the computer program is executed by a central processing unit (CPU) 601, various functions defined in the system of the present application are executed.
[0068] It should be noted that the computer-readable medium shown in the embodiment of the present application can be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium can be, for example, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media can include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a flash memory, an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, wherein a computer-readable computer program is carried. This propagated data signal can take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. A computer program contained on a computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.
[0069] The flowchart and block diagram in the accompanying drawings illustrate the possible architecture, functions and operations of the system, method and computer program product according to various embodiments of the present application. Wherein, each box in the flowchart or block diagram can represent a module, a program segment, or a part of the code, and the above-mentioned module, program segment, or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, and the combination of boxes in the block diagram or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0070] The units involved in the embodiments described in this application may be implemented by software or hardware, and the units described may also be set in a processor. The names of these units do not, in some cases, constitute limitations on the units themselves.
[0071] Another aspect of the present application further provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor of a computer, the computer executes the vehicle-mounted media file reading method as described above. The computer-readable storage medium may be included in the electronic device described in the above embodiment, or may exist independently without being assembled into the electronic device.
[0072] Another aspect of the present application further provides a computer program product or a computer program, which includes a computer instruction stored in a computer-readable storage medium. A processor of a computer device reads the computer instruction from the computer-readable storage medium, and the processor executes the computer instruction, so that the computer device executes the vehicle-machine media file reading method provided in each of the above embodiments.
[0073] The above embodiments are merely illustrative of the principles and effects of the present application, and are not intended to limit the present application. Anyone familiar with the technology may modify or change the above embodiments without violating the spirit and scope of the present application. Therefore, all equivalent modifications or changes made by a person of ordinary skill in the art without departing from the spirit and technical ideas disclosed in the present application shall still be covered by the claims of the present application.
Claims
1. A method for reading a vehicle computer media file, characterized in that: The vehicle computer media file reading method comprises: Monitor the external storage mounting state of the vehicle computer, and if the external storage mounting state is mounted, obtain the root directory path of the mounted external storage; Performing a filtering scan on the external memory based on the root directory path to obtain a filtering scan result list, wherein the filtering scan result list includes a plurality of media files whose file formats are preset formats, whose file sizes are larger than a preset memory threshold, and whose hidden states are non-hidden; The media information is extracted from the external memory according to the filtered scanning result list, and the extracted media information is used for display on the vehicle screen and written into the local database.
2. The vehicle computer media file reading method according to claim 1, characterized in that: The external memory is filtered and scanned based on the root directory path, and a filtering and scanning result list is obtained, including: Obtain a list of items and the number of items according to the root directory path; Obtaining a scanning step length of each thread based on the number of items and a preset number of scanning threads; Allocate a scanning task list to each thread according to the scanning step length and the item list, the scanning task list includes a starting item position and an ending item position scanned by each thread, and set a synchronization counter based on the preset number of scanning threads to monitor each thread; When a thread completes the scanning task, the synchronization counter is reduced by 1 until the synchronization counter completes counting, and the filtering scan of the external memory is completed.
3. The vehicle computer media file reading method according to claim 2, characterized in that: The external memory is filtered and scanned based on the root directory path, and the filtering and scanning result list obtained also includes: The thread starts traversing the scanning task list based on the starting item position, and determines the item type of the currently traversed item; If the item type of the currently traversed item is a file, then obtaining the file format, file size and hidden status of the file; If the file format of the file is the preset format, the file size is greater than the preset memory threshold, and the hidden state of the file is not hidden, the file is regarded as a media file, and the media file is added to the filtering scan result list; If the item type of the currently traversed item is a folder, obtaining the hidden state of the folder; If the hidden state of the folder is not hidden, the folder is used as a folder to be scanned; The folders to be scanned are traversed, media files in the folders to be scanned are added to the filtered scanning result list, and folders in the folders to be scanned whose hidden status is not hidden are used as new folders to be scanned, until all the folders to be scanned are traversed.
4. The vehicle computer media file reading method according to claim 1, characterized in that: The vehicle computer media file reading method further includes: Initializing the mount listener of the vehicle computer, wherein the mount listener is used to monitor and query the external storage mount status of the vehicle computer; If the mount listener monitors a newly added external storage mount message or finds that the external storage has been mounted, the external storage mount state is set to mounted; The mount listener obtains device information of the external storage based on the mount broadcast of the external storage, wherein the device information includes a device type; The external memory is screened based on the device type, and the external memory of the preset device type is filtered and scanned based on the root directory path of the external memory of the preset device type.
5. The vehicle computer media file reading method according to claim 1, characterized in that: The filtering scan result list includes the media files and file information corresponding to the media files, and the file information at least includes file name, file path, file format, file size, and last modification time.
6. The vehicle computer media file reading method according to claim 1, characterized in that: Extracting media information from the external storage device according to the filtered scan result list includes: Obtaining the number of media according to the filtered scanning result list; Obtaining an extraction step length for each thread based on the number of media and a preset number of extraction threads; Allocating an extraction task list to each thread according to the extraction step length and the filtered scan result list, the extraction task list including a start media position and an end media position extracted by each thread, and setting a synchronization counter based on the preset number of extraction threads to monitor each thread; When a thread completes the extraction task, the synchronization counter is reduced by 1 until the synchronization counter completes counting, and the extraction of media information from the external memory is completed.
7. The vehicle computer media file reading method according to claim 6, characterized in that: An extraction task list is assigned to each thread, wherein the extraction task list includes the starting media position and the ending media position extracted by each thread and also includes: Acquire the current display list of the vehicle screen, assign an extraction task list to each thread based on the current display list, and assign the media files in the current display list to each thread; When the number of completed extractions of the multiple threads exceeds a preset number threshold, the extracted media information is returned so that the vehicle screen displays the media information in the current display list.
8. A vehicle computer media file reading device, characterized in that: The vehicle computer media file reading device comprises: A monitoring and reading module is used to monitor the external storage mounting state of the vehicle computer, and if the external storage mounting state is mounted, obtain the root directory path of the mounted external storage; A filtering scanning module, configured to perform a filtering scan on the external memory based on the root directory path to obtain a filtering scanning result list, wherein the filtering scanning result list includes a plurality of media files whose file formats are preset formats, whose file sizes are larger than a preset memory threshold, and whose hidden states are non-hidden; The information extraction module is used to extract media information from the external memory according to the filtered scanning result list, and use the extracted media information for vehicle screen display and write into the local database.
9. An electronic device, characterized in that: The electronic device comprises: one or more processors; A storage device for storing one or more programs, which, when executed by the one or more processors, enables the electronic device to implement the vehicle-mounted media file reading method as described in any one of claims 1-7.
10. A computer-readable storage medium, characterized in that: A computer program is stored thereon, and when the computer program is executed by a processor of a computer, the computer is caused to execute the vehicle computer media file reading method as described in any one of claims 1-7.
