Dynamic background setting method based on VLC or MPV player
By integrating VLC or MPV players in the application window, dynamic background settings are achieved, which solves the problem of lack of dynamicity and poor performance of the window background, improves the attractiveness and personalization of the application, makes full use of the graphics card performance, and reduces the system Resource consumption.
Patent Information
- Application Number
- CN202411332265.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-24
- Publication Date
- 2024-12-17
AI Technical Summary
In the prior art, the window background lacks dynamicity and poor performance, it cannot effectively utilize GPU performance in ordinary application windows, and the system-level operation is complex and resource consumption is high.
Using the dynamic background setting method based on VLC or MPV player, the video is realized as the window background by initializing the window, integrating the video player, loading the video, playing the video, processing playback events and synchronizing the matching, and using the mature player engine to reduce the Impact on the system.
It realizes displaying dynamic backgrounds in ordinary application windows, improves the attractiveness and personalization of the application, makes full use of graphics card performance, reduces the consumption of system resources, and provides a stable and compatible video playback experience.
Smart Images

Figure CN119155499A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of players, and in particular to a dynamic background setting method based on a VLC or MPV player. Background Art
[0002] Currently, window backgrounds are usually filled with static images or colors. Although there are ways to use videos as desktop backgrounds, this method usually involves system-level operations, is not applicable to ordinary application windows, and consumes a lot of system resources.
[0003] Therefore, the prior art has defects and needs to be improved. Summary of the invention
[0004] The technical problem to be solved by the present invention is: to provide a dynamic background setting method based on VLC or MPV player, to solve the problem of lack of dynamics and poor performance of window background in the prior art, without distinguishing window types, and to make full use of GPU performance.
[0005] The technical solution of the present invention is as follows: a dynamic background setting method based on a VLC or MPV player is provided, comprising the following steps.
[0006] S1: Initialize the window: create or search for an application window W, and set basic properties of the application window W, including size and position, and mark the application window W as Wid.
[0007] S2: Integrated video player: Initialize the mpv or vlc player instance, and set the video output rendering viewport to the window handle Wid created or queried in the first step.
[0008] S3: Load Video: Use mpv or vlc player to load and decode video files or video streams.
[0009] S4: Play video: Play the video in the application window W. At this time, the played image has been used as the background of the application window W.
[0010] S5: Process playback events: monitor playback events of the MPV or VLC player so as to perform corresponding window operations when necessary.
[0011] S6: Synchronous matching: The basic properties of the video played by the mpv or vlc player and the application window W are updated synchronously to ensure that the application window W matches the rendering area to achieve seamless integration.
[0012] In step S1, if it is a window to be searched, the desktop handle is searched under Windows, and the desktop handle FindWindowEx (Progman->SHELLDLL_DefView->WorkerW) is searched in sequence to find the valid Wid of the desktop background window; if it is a created window, an independent background window WBackground is generated as the background, and the mask window needs to be transparently laid out in another parallel window WForeground, and then the program's mouse movement and form size attribute change events are processed to ensure that the operation window WForeground always maintains a consistent geometric position and shape with WBackground.
[0013] In step S2, use libvlc_media_player_set_hwnd or mpv_set_option(mpv,"wid",MPV_FORMAT_INT64,&Wid) to set it. At this time, mpv or vlc player will automatically match the appropriate hardware acceleration solution according to machine performance, hardware capabilities, and rendering video capabilities.
[0014] The playback events include: playback start, pause, and stop.
[0015] In step S6, it also includes: adding interactive functions: responding to the user's mouse click events, mouse drag events, and keyboard input events.
[0016] By adopting the above scheme, the present invention provides a method for setting a dynamic background based on a VLC or MPV player, using a mature MPV or VLC player as a video playback engine to ensure the stability and compatibility of video playback. At the same time, by integrating the player with the window object, the function of displaying a dynamic background in a common application window is realized, without modifying the system-level settings, reducing or even not requiring CPU participation, and ensuring that the impact on the user system is minimized.
[0017] The present invention also has the following effects:
[0018] (1) Dynamic backgrounds can attract users’ attention and enhance the attractiveness and fun of applications.
[0019] (2) You can select a suitable video as the background based on the needs and theme of the application to enhance the personalization of the application.
[0020] (3) Background video can interact with other elements of the application to achieve richer visual effects and user experience.
[0021] (4) Make full use of graphics card performance. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] Figure 1 The present invention is a flow chart of the method. DETAILED DESCRIPTION
[0023] The present invention is described in detail below in conjunction with the accompanying drawings and specific embodiments.
[0024] See also Figure 1 The present invention provides a dynamic background setting method based on VLC or MPV player, comprising the following steps.
[0025] S1: Initialize the window: create or search for an application window W, and set basic properties of the application window W, including size and position, and mark the application window W as Wid.
[0026] S2: Integrated video player: Initialize the mpv or vlc player instance, and set the video output rendering viewport to the window handle Wid created or queried in the first step.
[0027] S3: Load Video: Use mpv or vlc player to load and decode video files or video streams.
[0028] S4: Play video: Play the video in the application window W. At this time, the played image has been used as the background of the application window W.
[0029] S5: Process playback events: monitor playback events of the MPV or VLC player so as to perform corresponding window operations when necessary.
[0030] S6: Synchronous matching: The basic properties of the video played by the mpv or vlc player and the application window W are updated synchronously to ensure that the application window W matches the rendering area to achieve seamless integration.
[0031] In step S1, if it is a window to be searched, the desktop handle is searched under Windows, and the desktop handle FindWindowEx (Progman->SHELLDLL_DefView->WorkerW) is searched in sequence to find the valid Wid of the desktop background window; if it is a created window, an independent background window WBackground is generated as the background, and the mask window needs to be transparently laid out in another parallel window WForeground, and then the program's mouse movement and form size attribute change events are processed to ensure that the operation window WForeground always maintains a consistent geometric position and shape with WBackground.
[0032] In step S2, use libvlc_media_player_set_hwnd or mpv_set_option(mpv,"wid",MPV_FORMAT_INT64,&Wid) to set it. At this time, mpv or vlc player will automatically match the appropriate hardware acceleration solution according to machine performance, hardware capabilities, and rendering video capabilities.
[0033] The playback events include: playback start, pause, and stop.
[0034] In step S6, it also includes: adding interactive functions: responding to the user's mouse click events, mouse drag events, and keyboard input events.
[0035] In summary, the present invention provides a method for setting a dynamic background based on a VLC or MPV player, which uses a mature MPV or VLC player as a video playback engine to ensure the stability and compatibility of video playback. At the same time, by integrating the player with the window object, the function of displaying a dynamic background in a common application window is realized, without modifying the system-level settings, reducing or even not requiring CPU participation, and ensuring that the impact on the user system is minimized.
[0036] The present invention also has the following effects:
[0037] (1) Dynamic backgrounds can attract users’ attention and enhance the attractiveness and fun of applications.
[0038] (2) You can select a suitable video as the background based on the needs and theme of the application to enhance the personalization of the application.
[0039] (3) Background video can interact with other elements of the application to achieve richer visual effects and user experience.
[0040] (4) Make full use of graphics card performance.
[0041] The above are only preferred embodiments of the present invention and are not intended to limit the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the present invention.
Claims
1. A dynamic background setting method based on VLC or MPV player, It is characterized in that The following steps are involved: S1: Initialize the window: create or search for an application window W, and set basic properties of the application window W, including size and position, and mark the application window W as Wid. S2: Integrated video player: Initialize the mpv or vlc player instance, and set the video output rendering viewport to the window handle Wid created or queried in the first step; S3: Load video: Use mpv or vlc player to load and decode video files or video streams; S4: Play video: Play the video in the application window W. At this time, the played image has been used as the background of the application window W; S5: Processing playback events: monitoring playback events of the MPV or VLC player so as to perform corresponding window operations when necessary; S6: Synchronous matching: The basic properties of the video played by the mpv or vlc player and the application window W are updated synchronously to ensure that the application window W matches the rendering area to achieve seamless integration.
2. A method for setting a dynamic background based on a VLC or MPV player according to claim 1, It is characterized in that In step S1, If it is a window to be searched, search for the desktop handle under Windows, and search for the desktop handle FindWindowEx (Progman->SHELLDLL_DefView->WorkerW) in turn to find the effective Wid of the desktop background window; If it is a created window, an independent background window WBackground is generated as the background. The mask window needs to be transparently laid out in another parallel window WForeground, and then the program's mouse movement and form size attribute change events are processed to ensure that the operation window WForeground always maintains the same geometric position and shape as WBackground.
3. A method for setting a dynamic background based on a VLC or MPV player according to claim 1, It is characterized in that In step S2, use libvlc_media_player_set_hwnd or mpv_set_option(mpv,"wid",MPV_FORMAT_INT64,&Wid) to set it. At this time, mpv or vlc player will automatically match the appropriate hardware acceleration solution according to machine performance, hardware capabilities, and rendering video capabilities.
4. A method for setting a dynamic background based on a VLC or MPV player according to claim 1, It is characterized in that The playback events include: playback start, pause, and stop.
5. A method for setting a dynamic background based on a VLC or MPV player according to claim 1, It is characterized in that In step S6, it also includes: adding interactive functions: responding to the user's mouse click events, mouse drag events, and keyboard input events.
