A method and system for implementing a video plug-in service
By utilizing JS bridging and WebSocket channels to obtain the handle of the embedded browser window and the size of the non-webpage display area in the embedded browser environment, the adaptation problem of the video plugin service in the embedded browser environment is solved, and the correct display and dynamic adjustment of the video playback window are realized, improving the user experience and system stability.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- E SURFING VISION TECHNOLOGY CO LTD
- Filing Date
- 2024-11-26
- Publication Date
- 2026-04-14
AI Technical Summary
Existing technologies cannot effectively adapt to video plugin services in embedded browser environments, resulting in the inability to obtain window handles, the inability to actively start services, and the inability to accurately obtain the size of the browser window's non-webpage content display area, leading to video playback window offset.
By calling the JS bridging module in the web page's JS, the video plugin service is started, and a connection is established with the video plugin service using the WebSocket channel. The window handle of the embedded browser is obtained and its state changes are monitored. Combined with the size of the non-web page content display area of the client application, the layout of the video playback window is determined.
It achieves correct embedding and dynamic adjustment of the video playback window within the embedded browser environment, adapting to different screen sizes and resolutions, providing a better user experience, and ensuring system stability and resource management.
Smart Images

Figure CN119562108B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of computer technology, and in particular relates to a method and system for implementing video plugin services. Background Technology
[0002] In related technologies, due to the increasing popularity and wide range of use cases of Web front-end applications, and the fact that plugin-free video playback implemented using JS in Web front-ends does not perform as well as native video applications in terms of performance and protocol support, it is insufficient to meet the video playback needs of Web front-end applications. Therefore, there is an urgent need for a cross-browser video plugin service to provide high-quality video playback functionality for Web front-end applications.
[0003] Current plugin technologies typically involve installing a native video plugin program into the operating system. After installation, the plugin's background service runs automatically. Simultaneously, the browser's web page interacts with the plugin via JavaScript. Once the browser web page loads, the JavaScript establishes a connection with the plugin using communication methods such as WebSocket, and sends the title of the current web page tab to the plugin. The plugin then locates the browser window from the top-level window based on the tab title. Upon successful location, the JavaScript sends video playback commands and the coordinates of the video's intended display position. After receiving the playback command, the plugin creates a video playback window at the specified location and sets its Z-order to be above the browser window, thus enabling plugin-based video playback within the web page. However, these methods are only implemented based on traditional desktop browsers and do not consider adaptation for embedded browsers. Nowadays, application developers are paying more and more attention to the multi-channel access characteristics of their products. This means that whether users access the webpage directly through a browser or through a client application, they can consistently access the product's functions and content. In client applications, the method of loading webpages with an embedded browser is often used to achieve the same functions and content as direct browser access. Therefore, how to better implement video plugin services that are compatible with embedded browsers has become an urgent problem to be solved. Summary of the Invention
[0004] In view of the shortcomings of the prior art, the purpose of the invention is to provide a method and system for implementing video plugin services.
[0005] A first aspect of the present invention provides a method for implementing a video plugin service, comprising: S1, determining the access environment of the web page JS when a JS script is introduced into a web page; S2, when the access environment is an embedded browser, the web page JS starts the video plugin service by calling a JS bridge, and when the web page JS establishes a WebSocket channel with the video plugin service, sending the window handle of the embedded browser to the video plugin service; S3, the video plugin service locates the embedded browser window according to the window handle and listens for its window state change events; S4, when the video plugin service receives a video playback instruction and layout data of the video playback area, determining the layout of the video playback window according to the window state of the embedded browser and the layout data.
[0006] Furthermore, when the access environment is an embedded browser, it is determined that the client application has been launched, and the client application saves the window handle of the embedded browser and registers an address change listener and a JS bridging module with the web page; wherein, the conditions for the web page JS to call the JS bridge include: the client application dynamically listens to the domain name of the web page; upon receiving an address change event, the client application provides the JS bridge to the web page JS based on the domain name of the web page.
[0007] Furthermore, the Web page JS starts the video plugin service by calling the JS bridge, including: the client application starts the video plugin JS bridge method being called, wherein the client application starts the video plugin JS bridge method being called, including: the client application starts the video plugin service based on startup parameters, wherein the startup parameters include the target port number, a unique identifier, and a log path.
[0008] Furthermore, it also includes: when the video plugin service is started, the Web page JS obtains the port number and the window handle of the embedded browser from the client application; wherein, the Web page JS establishes a WebSocket channel with the video plugin service based on the port number.
[0009] Furthermore, it also includes: the Web page JS obtaining the size of the non-web page content display area of the client application; the Web page JS determining the layout data of the video playback area based on the size of the non-web page content display area of the client application, and sending the layout data of the video playback area to the video plugin service, wherein the layout data includes screen coordinates and size.
[0010] Furthermore, it also includes: when the client application is detected to have exited, the video plugin service executes an exit method; when the video plugin service is detected to have exited abnormally, the client application is triggered and canceled, and the web page is notified to display a user prompt page indicating that the video plugin service has exited based on the JS bridge.
[0011] Furthermore, it also includes: when the access environment is a non-embedded browser, the Web page JS establishes a WebSocket channel with the video plugin service; the Web page JS sends the webpage title to the video plugin service; the video plugin service locates the window of the non-embedded browser based on the webpage title; when the video plugin service receives the video playback instruction and the layout data of the video playback area, it determines the layout of the video playback window according to the window state of the non-embedded browser and the layout data.
[0012] A second aspect of the present invention provides a system for implementing a video plugin service, comprising: a first determining module, configured to determine the access environment of a JavaScript script introduced on a web page; a starting and sending module, configured to, when the access environment is an embedded browser, start the video plugin service by calling a JavaScript bridge on the web page, and when the web page JavaScript establishes a WebSocket channel with the video plugin service, send the window handle of the embedded browser to the video plugin service; a listening module, configured for the video plugin service to locate the embedded browser window based on the window handle and listen for changes in its window state; and a second determining module, configured to, when the video plugin service receives a video playback instruction and layout data of the video playback area, determine the layout of the video playback window based on the window state of the embedded browser and the layout data.
[0013] A third aspect of the present invention provides an electronic device comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method described in any one aspect of the present invention.
[0014] A fourth aspect of the present invention provides a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to cause the computer to perform the method described in any one of the first aspects of the present invention.
[0015] The beneficial effects of this invention are as follows:
[0016] The method and system for implementing a video plugin service as described in this invention determine the access environment of the JavaScript script on the web page when it is introduced into the web page. When the access environment is an embedded browser, the web page JavaScript starts the video plugin service by calling a JavaScript bridge. When the web page JavaScript establishes a WebSocket channel with the video plugin service, the window handle of the embedded browser is sent to the video plugin service. The video plugin service locates the embedded browser window based on the window handle and listens for changes in its window state. Upon receiving video playback instructions and layout data for the video playback area, the video plugin service determines the layout of the video playback window based on the window state and layout data of the embedded browser. This method ensures that the video playback window is correctly embedded into the web page by having the video plugin service listen for window state change events such as showing, hiding, minimizing, and maximizing of the embedded browser, based on the window handle of the embedded browser, thus maintaining the same showing and hiding window states as the embedded browser window. Furthermore, by obtaining the layout information of the non-webpage display area of the client application through JavaScript, and calculating the screen coordinates and other layout information of the video playback area to be displayed, the method ensures that the video playback window is correctly displayed in the desired position, achieving real-time adjustment of the video window layout. This dynamic adjustment capability allows the video plugin to adapt to different screen sizes and resolutions, providing a better user experience. Attached Figure Description
[0017] The accompanying drawings are for illustrative purposes only and are not intended to limit the invention. Throughout the drawings, the same reference numerals denote the same parts. It is obvious that the drawings described below are merely some embodiments of the present invention, and those skilled in the art can obtain other drawings based on these drawings.
[0018] Figure 1 This is a flowchart of a method for implementing a video plugin service according to an embodiment of the present invention;
[0019] Figure 2 This is a flowchart of a method for implementing a video plugin service according to a specific embodiment of the present invention;
[0020] Figure 3 This is a schematic diagram of a system for implementing video plugin services according to an embodiment of the present invention;
[0021] Figure 4 This is a structural block diagram of an electronic device according to an embodiment of the present invention. Detailed Implementation
[0022] To enable those skilled in the art to better understand the technical solutions in the embodiments of the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. It should be understood that these descriptions are merely exemplary and are not intended to limit the scope of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.
[0023] Furthermore, descriptions of well-known structures and techniques are omitted in the following description to avoid unnecessarily obscuring the concepts disclosed in this invention.
[0024] In the description of this invention, it should be noted that, unless otherwise explicitly specified and limited, the terms "center," "upper," "lower," "left," "right," "vertical," "horizontal," "inner," and "outer," etc., indicating orientation or positional relationships based on the orientation or positional relationships shown in the accompanying drawings, are only for the convenience of describing the invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as a limitation of the invention. Furthermore, the terms "first," "second," and "third" are used for descriptive purposes only and should not be construed as indicating or implying relative importance. The terms "installed," "connected," and "linked" should be interpreted broadly; for example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; and they can refer to the internal communication of two components. Those skilled in the art can understand the specific meaning of the above terms in this invention based on the specific circumstances.
[0025] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numerals in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present invention. Rather, they are merely examples of methods and systems consistent with some aspects of the invention as detailed in the appended claims.
[0026] As web front-end applications become increasingly popular and widely used, and given that plugin-free video playback implemented using JavaScript in web front-ends performs worse than native video service programs in terms of performance and protocol support, there is an urgent need for a cross-browser video plugin service to provide high-quality video playback functionality for web front-end applications.
[0027] Current plugin technology typically involves installing a native video plugin program into the operating system. After installation, the plugin's background service runs automatically. Simultaneously, the browser's web page interacts with the plugin via JavaScript. Once the browser web page loads, the JavaScript establishes a connection with the plugin using communication methods such as WebSocket, and sends the title of the current web page tab to the plugin. The plugin then locates the browser window from the top-level window based on the tab title. Upon successful location, the JavaScript sends video playback commands and the coordinates of the video's intended display position. After receiving the playback command, the plugin creates a video playback window at the specified location and sets its Z-order above the browser window, thus enabling plugin-based video playback within the web page.
[0028] However, these methods are all based on traditional desktop browsers and do not take into account the adaptation for embedded browsers. When applied in embedded browsers, they have at least the following shortcomings:
[0029] Unable to obtain the handle to the embedded browser window. Because the page title of a webpage in an embedded browser is not the title of the client application's window, modifying the tab title using JavaScript cannot change the title of the application window (i.e., the top-level window). Therefore, the video plugin service cannot obtain the handle to the embedded browser window based on the tab title.
[0030] Unable to actively start the video plugin service. In traditional browsers, a custom URL scheme can usually be used to actively start the video plugin service. However, since most embedded browsers do not support custom URL schemes by default, users will be unable to actively start the video plugin service. Using a custom URL scheme will instead cause abnormal web page rendering, resulting in a blank screen.
[0031] The inability to accurately determine the size of the browser window's non-webpage content display area can cause the video playback window to shift. Since JavaScript cannot directly obtain the screen coordinates of page elements, approximate screen coordinates are typically obtained by subtracting the browser window size from the browser's visible area, thus estimating the size of the browser's non-webpage content display area and converting the relative coordinates to approximate screen coordinates. Because the browser's non-webpage content display area can be located vertically, horizontally, or vertically, JavaScript cannot determine the size in each direction. Therefore, incorrect directional estimations can lead to the video playback window shifting.
[0032] Therefore, the present invention proposes a method, system and related equipment for implementing video plugin services. Specifically, the method, system and related equipment for implementing video plugin services according to embodiments of the present invention are described below with reference to the accompanying drawings.
[0033] Figure 1 This is a flowchart illustrating a method for implementing a video plugin service according to an embodiment of the present invention. It should be noted that the method for implementing a video plugin service according to this embodiment can be applied to a system for implementing a video plugin service according to this embodiment. This system for implementing a video plugin service can be configured on an electronic device or in a server. This application does not limit the scope of this application.
[0034] like Figure 1 As shown, the method for implementing the video plugin service includes:
[0035] S110, when a JS script is included in a web page, determine the access environment of the JS script in the web page.
[0036] In embodiments of the present invention, the access environment of the JavaScript on the web page can be determined based on the presence of the JavaScript bridging module.
[0037] S120: When the access environment is an embedded browser, the Web page JS starts the video plugin service by calling the JS bridge, and when the Web page JS establishes a WebSocket channel with the video plugin service, the window handle of the embedded browser is sent to the video plugin service.
[0038] In an embodiment of the present invention, when the access environment is an embedded browser, it is determined that the client application has been started, and the client application saves the window handle of the embedded browser, and registers the address change listener and JS bridging module with the Web page.
[0039] In an embodiment of the present invention, the client application dynamically monitors the domain name of a web page; upon receiving an address change event, it provides a JS bridge to the web page's JS based on the web page's domain name. That is, based on the web page's domain name, a JS bridge is provided to the web page of that domain, and the web page's JS then starts the video plugin service by calling the JS bridge.
[0040] In embodiments of the present invention, the video plugin JS bridge method can be invoked via a client application to enable the web page JS to start the video plugin service by calling the JS bridge. The client application starts the video plugin service based on startup parameters, including a target port number, a unique identifier, and a log path. That is, starting the video plugin service process based on the target port number directly defines the listening port number of the video plugin service, confirms port availability, and eliminates the need for port probing in the web page JS script.
[0041] This can be understood as follows: the client application obtains all TCP and UDP listening programs on the local computer through the network connection interface, acquires relevant connection information, and thus excludes already occupied port numbers to obtain confirmed available port numbers. Next, it uses registry manipulation methods to open the registry, obtains the installation path of the video plugin service, and then uses a command-line method, passing the application's unique identifier, port number, log path, etc., as command-line parameters to start the video plugin service. After the video plugin service starts, it parses the command-line parameters, runs the WebSocket service to listen on the specified port number, and simultaneously checks whether a log path has been entered. If not, it sets the log path to a directory generated based on the unique identifier within the application's cache directory; otherwise, it sets it to the specified path.
[0042] It's important to note that when the client application initializes the embedded browser, it intercepts navigation requests through the embedded browser's custom request handling interface. When a navigation request is triggered, it checks if the URL address requested by the page matches the custom URL scheme. If it does, and it's determined that no video plugin service is currently running, it starts the video plugin service using the default port number. This allows the web page's JavaScript to start the video plugin service using the URL scheme, just like in a traditional browser, avoiding page rendering errors caused by the embedded browser not supporting the custom URL scheme. Secondly, when the embedded browser is created, the client application injects its implemented JavaScript bridging module into the web page, providing it for use by the web page's JavaScript. A whitelist of domains can also be defined. When a change in the embedded browser's page address is detected, if the domain is not on the whitelist, the JavaScript bridging method registration is canceled, thus providing customized video plugin services only to certain pages.
[0043] In an embodiment of the present invention, the video plugin service writes custom URL scheme information to the registry during installation. The client application supports the use of the custom URL scheme to invoke the video service plugin by listening to the internal events of the embedded browser.
[0044] In an embodiment of the present invention, when the video plugin service is started, the Web page JS obtains the port number and the window handle of the embedded browser from the client application; then, the Web page JS establishes a WebSocket channel with the video plugin service based on the port number. The Web page JS obtains the window handle of the embedded browser from the client application, enabling direct access to the embedded browser window handle without modifying the browser tab title. This solves the problem in existing methods where the Web page JS script cannot modify the embedded browser tab title, causing the video plugin service to be unable to locate the browser window and thus fail to display the video playback window correctly.
[0045] S130, the video plugin service locates the embedded browser window and listens for changes in its window state based on the window handle.
[0046] In embodiments of the present invention, upon receiving a window handle, the video plugin service can locate the embedded browser window and monitor its window state changes based on the window handle. For example, it can monitor events such as the embedded browser window being shown, hidden, minimized, or maximized.
[0047] S140: Upon receiving the video playback instruction and the layout data of the video playback area from the video plugin service, the layout of the video playback window is determined based on the window state and layout data of the embedded browser.
[0048] In an embodiment of the present invention, the Web page JavaScript obtains the size of the non-web page content display area of the client application; the Web page JavaScript determines the layout data of the video playback area based on the size of the non-web page content display area of the client application, and sends the layout data of the video playback area to the video plugin service, wherein the layout data includes screen coordinates and size. Then, when the video plugin service receives the video playback command and the layout data of the video playback area, it determines the layout of the video playback window according to the window state and layout data of the embedded browser. This eliminates the need for the Web page to estimate the size of the non-web page content display area by subtracting the browser size from the visible area size, avoiding calculation errors that could lead to video playback window offset.
[0049] It's important to clarify that the non-webpage display area of a client application can be understood as the non-working area of the client application, or the UI display area within the client application's working area excluding the embedded browser. This non-working area typically includes the client application window's borders, title bar, etc. Since the client application can accurately obtain information such as the position and size of these areas, it can directly pass this information to the web page's JavaScript to accurately calculate the layout data for the video playback area. However, in traditional desktop browsers, the web page's JavaScript lacks the relevant interfaces to obtain the size of the non-webpage display area in various directions (including the bookmarks bar, sidebar, download prompts, etc.). It can only obtain the relative coordinates of page elements within the visible area. The web page's JavaScript typically uses these relative coordinates, the size of the browser's outer window, and the size of the browser's visible area to approximate the screen coordinates of page elements relative to the top-left corner of the screen. Therefore, if components outside the top area, such as sidebars or download prompts, appear, the web page's JavaScript will make incorrect judgments, leading to incorrect screen coordinate calculations and a shift in the video playback window.
[0050] In an embodiment of the present invention, the video plugin service program exits upon detecting that the client application has exited. This can be understood as follows: after the client application starts the video plugin service process via command line, it can obtain a local handle to the video plugin service. The client application uses this handle to create a job object. Therefore, when the client application exits, the video plugin service process also exits, avoiding the occupation of system resources.
[0051] In an embodiment of the present invention, upon detecting an abnormal exit of the video plugin service, the client application's listening event is canceled after being triggered, and a user notification page indicating the video plugin service's exit is displayed on the web page via a JS bridge. That is, the client application no longer listens for the listening event, and the web page displays the user notification page indicating the video plugin service's exit based on the JS bridge.
[0052] According to an embodiment of the present invention, a method for implementing a video plugin service includes the following steps: When a JavaScript script is introduced into a web page, the access environment of the web page's JavaScript is determined; when the access environment is an embedded browser, the web page's JavaScript starts the video plugin service by calling a JavaScript bridge; and when the web page's JavaScript establishes a WebSocket channel with the video plugin service, the window handle of the embedded browser is sent to the video plugin service. The video plugin service locates the embedded browser window based on the window handle and listens for changes in its window state. When the video plugin service receives a video playback command and layout data for the video playback area, it determines the layout of the video playback window based on the window state and layout data of the embedded browser. This method ensures that the video playback window is correctly embedded into the web page by having the video plugin service listen for window state change events such as showing, hiding, minimizing, and maximizing of the embedded browser based on the window handle, thus maintaining the same showing and hiding window states as the embedded browser window. Furthermore, by obtaining the layout information of the non-webpage display area of the client application through JavaScript and calculating the screen coordinates and other layout information of the video playback area to be displayed, the method ensures that the video playback window is correctly displayed in the desired position, achieving real-time adjustment of the video window's layout. This dynamic adjustment capability allows the video plugin to adapt to different screen sizes and resolutions, providing a better user experience.
[0053] To enable those skilled in the art to more readily understand the present invention, Figure 2 This is a method for implementing a video plugin service according to a specific embodiment of the present invention, such as... Figure 2 As shown, the method for implementing the video plugin service includes:
[0054] S210, when a JS script is included in a web page, determine the access environment of the JS script in the web page.
[0055] S220: When the access environment is an embedded browser, the Web page JS starts the video plugin service by calling the JS bridge, and when the Web page JS establishes a WebSocket channel with the video plugin service, the window handle of the embedded browser is sent to the video plugin service.
[0056] S230, the video plugin service locates the embedded browser window and listens for changes in its window state based on the window handle.
[0057] S240: Upon receiving the video playback instruction and the layout data of the video playback area from the video plugin service, the layout of the video playback window is determined based on the window state and layout data of the embedded browser.
[0058] In the embodiments of the present invention, the implementation of steps S210-S240 can refer to the implementation of steps S110-S140 described above, and the present invention will not repeat the details.
[0059] S250: In the case of a non-embedded browser access environment, the web page JS establishes a WebSocket channel with the video plugin service.
[0060] In an embodiment of the present invention, when the access environment is a non-embedded browser, the Web page JS can establish a WebSocket channel with the video plugin service by probing sequentially starting from a specified port number.
[0061] S260, the web page's JavaScript sends the webpage title to the video plugin service.
[0062] In an embodiment of the present invention, the Web page JS adds a unique identifier suffix to the web page title in order to send the web page title to the video plugin service.
[0063] S270, the video plugin service locates non-embedded browser windows based on the webpage title.
[0064] S280: Upon receiving video playback instructions and layout data of the video playback area from the video plugin service, determine the layout of the video playback window based on the state and layout data of the non-embedded browser window.
[0065] In embodiments of the present invention, native: refers to software, applications or code optimized for a specific platform that can directly access and utilize the hardware functions of the device, and generally provides better performance.
[0066] Client applications: In this article, it refers to desktop applications as opposed to web applications. They need to be downloaded and installed, and web page content can only be displayed using embedded browser components. They can directly access and utilize the hardware functions of the device.
[0067] JS bridging: A technique that allows JavaScript code in a web application to call functions in the client application. JS bridging enables web applications to interact with the hardware features of a device (such as camera, geolocation, etc.), thus providing a more native application experience.
[0068] WebSocket is a network communication protocol that provides a full-duplex communication channel, allowing servers to proactively send messages to clients without requiring client requests. Compared to the traditional HTTP request / response model, WebSocket reduces communication overhead and enables real-time, persistent connections. It is widely used in applications requiring real-time interaction, such as online chat, real-time gaming, and stock trading.
[0069] Embedded browser: A browser component embedded in a client application that allows the application to display and interact with web page content.
[0070] URL Scheme: A custom URL scheme allows a webpage or application to invoke a local application via a specific protocol. For example, in Windows systems, you can write custom URL scheme information to the registry to launch a local program when a specific link is clicked in a browser.
[0071] According to embodiments of the present invention, a method for implementing a video plugin service can intelligently identify the JS access environment of a web page, distinguish between embedded browser and non-embedded browser environments, and thus adopt different strategies to start and interact with the video plugin service. This environment adaptability enables the method to run seamlessly in various browser and application environments. In the embedded browser environment, efficient communication between the web page JS and the video plugin service is achieved through a JS bridging module and a WebSocket channel. Furthermore, by dynamically listening to the domain name of the web page and providing a JS bridging mechanism through the client application, the rapid startup and stable connection of the video plugin service are ensured. Simultaneously, by directly agreeing on the listening port number of the video plugin service, the cumbersome process of port probing by the web page JS script is avoided. The video plugin service can accurately locate the embedded browser window and listen to its window state changes (such as showing, hiding, minimizing, maximizing, etc.) based on the window handle of the embedded browser. This helps determine the layout of the video playback window while ensuring synchronization with the window state of the embedded browser, improving the user experience. By obtaining the size of the non-web page content display area from the client application, the web page JS can accurately determine the layout data of the video playback area and send it to the video plugin service. This avoids the video playback window layout error caused by the web page's JavaScript failing to obtain the size of the browser's non-webpage content display area. The method also considers resource management issues for both the client application and the video plugin service. By associating the video plugin service process with the client application through a job object, it ensures that the video plugin service process exits along with the client application, avoiding system resource consumption. Simultaneously, when an abnormal exit of the video plugin service is detected, the listener event in the client application is canceled after being triggered, and a JavaScript bridge notifies the web page's JavaScript to display a user prompt page indicating the video plugin service's exit, ensuring system stability and reliability. For non-embedded browser environments, this method establishes a WebSocket channel with the video plugin service by sequentially probing from a specified port number and locates the non-embedded browser window based on the webpage title (with a unique identifier suffix). This ensures that the method works correctly in non-embedded browser environments, improving its versatility and compatibility.
[0072] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods according to the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods of the various embodiments of this application.
[0073] According to one aspect of the present invention, a system for implementing video plugin services is also proposed. Figure 3 This is a structural block diagram of a system for implementing a video plugin service according to an embodiment of the present invention; as shown below. Figure 3 As shown, it includes:
[0074] The first determining module 310 is used to determine the access environment of the JS in the Web page when the JS script is introduced in the Web page;
[0075] The startup and sending module 320 is used to start the video plugin service by calling the JS based on the method of calling the JS bridge when the access environment is an embedded browser, and to send the window handle of the embedded browser to the video plugin service when the Web page JS establishes a WebSocket channel with the video plugin service.
[0076] The listening module 330 is used by the video plugin service to locate the embedded browser window based on the window handle and listen for its window state change events;
[0077] The second determining module 340 is used to determine the layout of the video playback window based on the window state of the embedded browser and the layout data when the video plugin service receives the video playback instruction and the layout data of the video playback area.
[0078] According to an embodiment of the present invention, a system for implementing a video plugin service determines the access environment of the web page's JavaScript when a JavaScript script is introduced into a web page. When the access environment is an embedded browser, the web page's JavaScript starts the video plugin service by calling a JavaScript bridge. Furthermore, when the web page's JavaScript establishes a WebSocket channel with the video plugin service, it sends the window handle of the embedded browser to the video plugin service. The video plugin service locates the embedded browser window based on the window handle and listens for changes in its window state. Upon receiving a video playback command and layout data for the video playback area, the video plugin service determines the layout of the video playback window based on the embedded browser's window state and layout data. Thus, by listening to window state change events such as showing, hiding, minimizing, and maximizing of the embedded browser based on its window handle, the video plugin service ensures that the video playback window maintains the same showing and hiding states as the embedded browser window, guaranteeing that the video playback window can be correctly embedded into the web page. By obtaining the layout information of the non-webpage display area of the client application through JavaScript and calculating the screen coordinates and other layout information of the video playback area to be displayed, the system ensures that the video playback window is correctly displayed in the desired position, achieving real-time adjustment of the video window's layout. This dynamic adjustment capability allows the video plugin to adapt to different screen sizes and resolutions, providing a better user experience.
[0079] Optionally, when the access environment is an embedded browser, it is determined that the client application has been started, and the client application saves the window handle of the embedded browser and registers an address change listener and a JS bridging module with the web page; wherein, the conditions for the web page JS to call the JS bridge include: the client application dynamically listens to the domain name of the web page; and upon receiving an address change event, it provides the JS bridge to the web page JS based on the domain name of the web page.
[0080] Optionally, the startup and sending module 320 is specifically used for the client application to start the video plugin JS bridge method being called, wherein the client application starting the video plugin JS bridge method being called includes: the client application starting the video plugin service based on startup parameters, wherein the startup parameters include the target port number, a unique identifier, and a log path.
[0081] Optionally, it also includes an acquisition module, used to obtain the port number and the window handle of the embedded browser from the client application when the video plugin service is started; wherein, the startup and sending module 320 is specifically used for the web page JS to establish a WebSocket channel with the video plugin service based on the port number.
[0082] Optionally, a third determining module is also included. This module is used by the Web page JavaScript to obtain the size of the non-web page content display area of the client application; the Web page JavaScript determines the layout data of the video playback area based on the size of the non-web page content display area of the client application, and sends the layout data of the video playback area to the video plugin service, wherein the layout data includes screen coordinates and size.
[0083] Optionally, it also includes a detection module, used to execute a program exit method when the client application is detected to have exited; and to cancel the listening event triggered in the client application and, based on the JS bridge, notify the web page JS to display a user prompt page indicating that the video plugin service has exited when the client application is detected to have exited abnormally.
[0084] Optionally, it also includes a fourth determining module, used to establish a WebSocket channel between the Web page JS and the video plugin service when the access environment is a non-embedded browser; the Web page JS sends the web page title to the video plugin service; the video plugin service locates the window of the non-embedded browser based on the web page title; and when the video plugin service receives the video playback instruction and the layout data of the video playback area, it determines the layout of the video playback window according to the window state of the non-embedded browser and the layout data.
[0085] According to one aspect of the present invention, an electronic device is provided.
[0086] Figure 4 This is a schematic diagram of the structure of an electronic device according to an embodiment of the present invention. Figure 4 As shown, an electronic device may include one or more ( Figure 4 Only one is shown in the image. A processor 102 (which may include, but is not limited to, a microprocessor unit (MPU) or a programmable logic device (PLD)) and a memory 104 for storing data are also shown. In one exemplary embodiment, the electronic device may further include a transmission device 106 for communication functions and an input / output device 108. Those skilled in the art will understand that... Figure 4 The structure shown is for illustrative purposes only and does not limit the structure of the terminal device described above. For example, the terminal device may also include components that are more... Figure 4 The more or fewer components shown, or having the same Figure 4 Equivalent functions or ratios shown Figure 4 The functions shown have more different configurations.
[0087] The memory 104 can be used to store computer programs, such as application software programs and modules, like the computer program corresponding to the method for implementing video plugin services in this embodiment of the invention. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, thereby implementing the aforementioned method. The memory 104 may include high-speed random access memory and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include memory remotely located relative to the processor 102, and these remote memories can be connected to terminal devices via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0088] The transmission device 106 is used to receive or send data via a network. Specific examples of the network described above may include a wireless network provided by the communication provider of the switching device. In one example, the transmission device 106 includes a Network Interface Controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, the transmission device 106 may be a Radio Frequency (RF) module used for wireless communication with the Internet.
[0089] This invention proposes a non-transitory computer-readable storage medium storing computer instructions for causing the computer to execute a method for implementing a video plugin service.
[0090] The applicant of this invention has provided a detailed description of the embodiments of the invention in conjunction with the accompanying drawings. However, those skilled in the art should understand that the above embodiments are merely preferred embodiments of the invention. The detailed description is only intended to help readers better understand the spirit of the invention and is not intended to limit the scope of protection of the invention. On the contrary, any improvements or modifications made based on the inventive spirit of the invention should fall within the scope of protection of the invention.
[0091] Furthermore, the functional units in the various embodiments of the present invention can be integrated into a processing module, or each unit can exist physically separately, or two or more units can be integrated into a module. The integrated module can be implemented in hardware or as a software functional module. If the integrated module is implemented as a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium.
[0092] The storage medium mentioned above can be a read-only memory, a disk, or an optical disk, etc. Although embodiments of the present invention have been shown and described above, it is to be understood that the above embodiments are exemplary and should not be construed as limiting the present invention. Those skilled in the art can make changes, modifications, substitutions, and variations to the above embodiments within the scope of the present invention.
[0093] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the embodiments of the present invention, and are not intended to limit them. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in the present invention should be included within the protection scope of the present invention.
Claims
1. A method for implementing a video plugin service, characterized in that, include: S1, when a JS script is included in a web page, determine the access environment of the JS script in the web page; S2, when the access environment is an embedded browser, the Web page JS starts the video plugin service by calling the JS bridge, and when the Web page JS establishes a WebSocket channel with the video plugin service, the window handle of the embedded browser is sent to the video plugin service. S3, the video plugin service locates the embedded browser window based on the window handle and listens for its window state change events; S4, when the video plugin service receives the video playback instruction and the layout data of the video playback area, the layout of the video playback window is determined according to the window state of the embedded browser and the layout data; In the case where the access environment is an embedded browser, it is determined that the client application has been started, and the client application saves the window handle of the embedded browser and registers an address change listener and a JS bridging module with the web page. The conditions for the Web page JS to call the JS bridge include: The client application dynamically listens to the domain name of the web page; Upon receiving an address change event, the JS bridge is provided to the JS of the web page based on the domain name of the web page; The web page JS starts the video plugin service by calling a JS bridge, including: the client application's JS bridge method for starting the video plugin is called, wherein... The client application's JS bridge method for launching the video plugin is invoked, including: The client application starts the video plugin service based on startup parameters, including the target port number, a unique identifier, and a log path.
2. The method for implementing video plugin services according to claim 1, characterized in that, Also includes: When the video plugin service is started, the web page JS obtains the port number and the window handle of the embedded browser from the client application; The web page JS establishes a WebSocket channel with the video plugin service based on the port number.
3. The method for implementing video plugin services according to claim 1, characterized in that, Also includes: The JavaScript on the web page obtains the size of the non-web page content display area of the client application; The Web page JS determines the layout data of the video playback area based on the size of the non-web page content display area of the client application, and sends the layout data of the video playback area to the video plugin service, wherein the layout data includes screen coordinates and size.
4. The method for implementing video plugin services according to claim 1, characterized in that, Also includes: The video plugin service executes an exit method upon detecting that the client application has exited. If the video plugin service is detected to have exited abnormally, the listening event in the client application is canceled after being triggered, and the web page is notified to display a user prompt page indicating that the video plugin service has exited based on the JS bridge.
5. The method for implementing video plugin services according to claim 1, characterized in that, Also includes: When the access environment is a non-embedded browser, the Web page JS establishes a WebSocket channel with the video plugin service; The web page JS sends the webpage title to the video plugin service; The video plugin service locates the non-embedded browser window based on the webpage title; Upon receiving a video playback instruction and layout data for the video playback area, the video plugin service determines the layout of the video playback window based on the window state of the non-embedded browser and the layout data.
6. A system for implementing video plugin services, characterized in that, include: The first determination module is used to determine the access environment of the JS script on the web page when the JS script is introduced on the web page; The startup and sending module is used to start the video plugin service by calling the JS of the Web page when the access environment is an embedded browser, and to send the window handle of the embedded browser to the video plugin service when the Web page JS establishes a WebSocket channel with the video plugin service. The monitoring module is used by the video plugin service to locate the embedded browser window based on the window handle and to monitor its window state change events. The second determining module is used to determine the layout of the video playback window based on the window state of the embedded browser and the layout data when the video plugin service receives the video playback instruction and the layout data of the video playback area. In the case where the access environment is an embedded browser, it is determined that the client application has been started, and the client application saves the window handle of the embedded browser and registers an address change listener and a JS bridging module with the web page. The conditions for the Web page JS to call the JS bridge include: The client application dynamically listens to the domain name of the web page; Upon receiving an address change event, the JS bridge is provided to the JS of the web page based on the domain name of the web page; The web page JS starts the video plugin service by calling a JS bridge, including: the client application's JS bridge method for starting the video plugin is called, wherein... The client application's JS bridge method for launching the video plugin is invoked, including: The client application starts the video plugin service based on startup parameters, including the target port number, a unique identifier, and a log path.
7. An electronic device, characterized in that, include: At least one processor; And a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of any one of claims 1 to 5.
8. A non-transitory computer-readable storage medium storing computer instructions, characterized in that, The computer instructions are used to cause the computer to perform the method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Method and system for embedding local application program window into browser in Linux
CN103064738A
Method for embedding external video plug-in window into browser
CN113886110A