Browser video playing method and device, electronic equipment and storage medium

By replacing elements of the specified file format in the browser's document object model, the problem of the browser being unable to play a specific video format when the browser lacks a decoder, the function of playing videos without plug-in is realized, and the applicability and user experience of the browser are improved.

CN120223922APending Publication Date: 2025-06-27BEIJING HONGTENG INTELLIGENT TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311824848.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-12-27
Publication Date
2025-06-27

AI Technical Summary

Technical Problem

When existing browsers lack a specific video format decoder, they need to install a third-party video plug-in to play videos, resulting in poor user experience and occupying system resources.

Method used

By obtaining the browser's document object model, determine the node to be detected and check whether it contains elements in the specified file format. If so, the element in the target file format is constructed to replace elements in the specified file format to control the browser to play videos in the target file format.

Benefits of technology

It realizes that playing videos in the landing web page without relying on third-party video playback plug-ins, improving the applicability and scalability of the browser and improving the user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120223922A_ABST
    Figure CN120223922A_ABST
Patent Text Reader

Abstract

The invention provides a browser video playing method and device, electronic equipment and a storage medium. The method comprises the steps that a document object model of a browser is obtained, and the document object model comprises a plurality of nodes used for browser page display; determining a to-be-detected node in the document object model, and determining whether the to-be-detected node contains an element of a specified file format or not; if yes, the element in the target file format is constructed to replace the element in the specified file format, and the browser is controlled to play the video in the target file format through the element in the target file format, so that video playing in the target webpage does not need to depend on a third-party video playing plug-in, and the applicability and expandability of the browser are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computers, and in particular to a method, device, electronic device, and storage medium for browser video playback. Background Art

[0002] With the continuous development of computer technology, the extended functions of browsers are also constantly improving. When users browse the web using a browser, they can play video files in the browsing page through a built-in video plugin, such as watching short videos in the browser.

[0003] In related technologies, when a browser does not support or lacks a decoder for a specific video format, it is necessary to install a corresponding video plugin to play the video of that format normally. If the user does not install the required plugin, the video cannot be played on the page, thus affecting the user experience; and the video plugin will occupy more memory and processor resources, resulting in a decline in the performance of the browser. Summary of the Invention

[0004] This application provides a method, device, electronic device, and storage medium for browser video playback, which can improve the applicability and scalability of the browser.

[0005] In a first aspect, a method for browser video playback is provided. The method includes:

[0006] Obtain the document object model of the browser, where the document object model includes multiple nodes for browser page display;

[0007] Determine a node to be detected in the document object model, and determine whether the node to be detected contains an element of a specified file format;

[0008] If so, construct an element of the target file format to replace the element of the specified file format, so as to control the browser to play a video of the target file format through the element of the target file format.

[0009] In a second aspect, a device for browser video playback is provided. The device includes:

[0010] An obtaining module, configured to obtain the document object model of the browser, where the document object model includes multiple nodes for browser page display;

[0011] A determining module, configured to determine a node to be detected in the document object model, and determine whether the node to be detected contains an element of a specified file format;

[0012] A replacement module, which is used to, if so, construct elements in a target file format to replace the elements in the specified file format, so as to control the browser to play a video in the target file format through the elements in the target file format.

[0013] In a third aspect, an electronic device is provided, and the electronic device includes:

[0014] A memory for storing executable program code;

[0015] A processor for calling and running the executable program code from the memory, so that the electronic device executes the browser video playing method described in any one of the above.

[0016] In a fourth aspect, a computer-readable storage medium is provided, and the computer-readable storage medium stores a computer program, which when executed, implements the browser video playing method described in any one of the above.

[0017] The beneficial effects brought by the technical solutions provided in some embodiments of the present application at least include: The browser video playing method provided by the present application replaces the to-be-detected nodes containing the specified file type in the document object model of the current page in the browser; by constructing elements in the target file format to replace the elements in the specified file format to control the browser to play a video in the target file format through the elements in the target file format, it can achieve video playing in the target web page without relying on a third-party video playing plugin, improving the applicability and scalability of the browser. Description of the Drawings

[0018] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings required for the description of the embodiments or the prior art. Obviously, the drawings in the following description are only some embodiments of the present application. For those skilled in the art, without creative efforts, other drawings can be obtained according to these drawings.

[0019] Figure 1 It is the first flow diagram of the browser video playing method provided by the embodiment of the present application.

[0020] Figure 2 It is the second flow diagram of the browser video playing method provided by the embodiment of the present application.

[0021] Figure 3 It is the third flow diagram of the browser video playing method provided by the embodiment of the present application.

[0022] Figure 4 It is the structural diagram of the browser video playing device provided by the embodiment of the present application.

[0023] Figure 5 It is the first structural schematic diagram of the electronic device provided by the embodiment of the present application.

[0024] Figure 6 It is the second structural schematic diagram of the electronic device provided by the embodiment of the present application. Detailed implementation manners

[0025] To make the features and advantages of the present application more obvious and understandable, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative efforts fall within the protection scope of the present application.

[0026] When the following description involves the accompanying drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The implementation manners described in the following exemplary embodiments do not represent all the implementation manners consistent with the present application. On the contrary, they are only examples of the devices and methods consistent with some aspects of the present application as detailed in the appended claims.

[0027] Hereinafter, the terms "first" and "second" are only used for descriptive purposes and cannot be construed as implying or suggesting relative importance or implicitly indicating the quantity of the indicated technical features. Thus, the features defined with "first" and "second" may explicitly or implicitly include one or more of such features.

[0028] In the related art, when a target object plays a specific type of video in a browser, a third-party video player plugin needs to be used. However, due to the different degrees of support for the third-party video player plugin by the browser and the operating system, there are certain problems with the compatibility of the plugin. This may cause the video to not play properly on some browsers or operating systems. In addition, the third-party video player plugin usually occupies more system resources, including memory and the processor. This may lead to a decrease in browser performance and even cause the system to freeze or crash.

[0029] To solve the above problems, the embodiment of the present application provides a browser video playing method, which will be described in detail below. It should be noted that the description order of the following embodiments does not limit the preferred order of the embodiments. Please refer to Figure 1 , Figure 1 It is the first flowchart of the browser video playing method provided by the embodiment of the present application. The specific process of this browser video playing method can be as follows:

[0030] S101, obtain the Document Object Model (DOM) of the browser, where the DOM includes multiple nodes for browser page display.

[0031] It should be noted that a web page in a browser consists of three major components: HyperText Markup Language (HTML), Cascading Style Sheets (CSS), and JavaScript. Among them, HTML defines the structure of the web page, CSS defines the style of the web page, and JavaScript is responsible for the interaction and dynamic effects of the web page. In a browser, these three are all converted into a data structure that the browser can understand and operate on, namely the Document Object Model (DOM).

[0032] In this embodiment, in order to access or modify each node or node element in the browser web page, such as element nodes and attribute nodes, etc., where the element node represents a tag and its content in the HTML document. For example, 、 、 Such as representative element nodes; Attribute Nodes represent the attributes of tags in an HTML document. For example, <img src="image.jpg"> the src in it is an attribute node. In addition, operations or event handling on browser web page nodes can be achieved through the Document Object Model. For example, by obtaining the Document Object Model, elements nodes, attribute nodes, etc. on the web page can be dynamically modified to achieve the dynamic change effect of the web page.

[0033] Specifically, when the target object browses the target web page, the browser sends an HTTP request to the server of the specified target web page through the network. After receiving the request, the server of the target web page will return the hypertext content of the target web page as a response. After receiving the response, the browser starts to parse the code in the hypertext markup language. The text parser of the browser will read and parse the hypertext markup language code in the target web page line by line according to the specifications of the hypertext markup language. A Document Object Model tree (DOM tree) is constructed based on information such as hypertext markup language tags, attributes, etc. Among them, each hypertext markup language tag serves as a node of the Document Object Model, and the nested relationship between the tags determines the hierarchical structure of the Document Object Model tree. During the process of parsing the hypertext markup language by the browser, if an external CSS style sheet or JavaScript script is encountered, they will be loaded and executed as needed to achieve the interactive processing of the target page. Finally, the browser renders the target page according to the Document Object Model tree and CSS style information and displays the target page in the browser window. By obtaining the Document Object Model, the interactivity with the target page can be improved to speed up the processing speed of the browser for the page content.

[0034] S102. Determine the node to be detected in the Document Object Model, and determine whether the node to be detected contains elements in a specified file format.

[0035] Specifically, start traversing from the root node of the Document Object Model tree, and traverse all nodes level by level until the node to be detected is found. Among them, the node to be detected is a content embedding tag, such as <embed> or <object>etc., and can also be adjusted according to specific requirements for the nodes to be detected. For each traversed node, determine whether its node type is the preset node type to be detected and check whether the label elements in the node to be detected contain elements of the specified file format. For example, in a target web page that contains multiple embedded contents, it is necessary to find the <embed> or <object>The node label. At this time, start traversing from the root node of the document object model and search for nodes level by level until <embed> or <object>The label is checked to see if the format of the embedded audio file conforms to the specified file type. Through the traversal process, the embedded content of a specific type can be automatically found and processed accordingly to speed up the data processing speed.

[0036] S103, if so, construct elements of the target file format to replace the elements of the specified file format, so as to control the browser to play the video of the target file format through the elements of the target file format.

[0037] Specifically, determine the element type of the specified file format to be replaced in the document object model of the target web page. For example, <embed> or <object>The tag traverses all nodes in the HTML document, including the root node and its child nodes. It determines whether the node type of each node is an element node. If the node is an element node, it further checks whether the specified file format is included in the node. When an element of the specified file format to be replaced is found, an element of the target file format will be created, such as <video>A label replaces the elements of the specified file format in the node to be detected with the elements of the target file format and controls the browser to play the video of the corresponding target file format.

[0038] For example, there is a specified file format in a HyperText Markup Language document, such as <embed> There is a video with the suffix ".Flv" in the label. At this time, a custom element is generated , and in the custom element Generate child nodes <video>Label, and convert the video corresponding to the specified file format to generate a video corresponding to the target format file. For example, convert it to a video file with the format ".Mp4". Use the address of the video corresponding to the target format file as a child node <video>the src attribute in the tag, and then <embed> replace the tag with a custom element And play the video corresponding to the target format file in the target web page.

[0039] As can be seen from the above, by operating on the document object model of the target web page to achieve element replacement and control, different element types can be selected according to actual needs to meet the requirements of different scenarios. By replacing the nodes to be detected containing the specified file type, the browser function can be extended to be applicable to more scenarios. By constructing elements of the target file format to replace elements of the specified file format and controlling the browser to play the video of the target file format through the elements of the target file format, the applicability and scalability of the browser can be enhanced without relying on third-party plugins, thus bringing a better user experience to the target object.

[0040] Optionally, please refer to Figure 2 , Figure 2 which is the second flowchart of the browser video playing method provided by the embodiment of the present application. The specific process of this browser video playing method may include:

[0041] S201, detect whether the browser loads a specified script file, where the specified script file is used to monitor and process events in the browser.

[0042] In this embodiment, there are some security restrictions by default in the browser, which may cause the inability to load a specified type of script file. In actual requirements, a script file with pending functions is needed to implement corresponding functions. Therefore, when a script file with specific functions is needed, the browser needs to be detected to determine whether the corresponding script file can be loaded.

[0043] Specifically, to determine whether the specified monitoring file is loaded by the browser, a global variable can be set. Define a global variable in the specified script file, and other script files or the main page of the target web page can determine whether the specified script file has been loaded by checking whether the variable exists. For example, define a global variable in the specified script file, such as "myScriptLoaded", and assign it the value true. In other script files or the main page of the target web page, check whether the variable exists to determine whether the specified script file has been loaded. If the variable exists, it means that the specified script file has been loaded.

[0044] Optionally, use the onload event to detect whether the specified script file has been loaded. When the entire document (including the script file) and all its related resources have been loaded and rendered in the target web page, the onload event will be triggered. An onload event handler can be added to the specified script file to perform corresponding operations when it is triggered.

[0045] S202, if a specified script file is loaded, the browser is allowed to parse the content of the current page to generate a Document Object Model.

[0046] In this embodiment, when the browser loads a specified script file, it will execute the script line by line in the order of the script code in the document. If the code in the script file operates on the content of the current target page, such as creating, modifying, or deleting specific elements, the browser will generate a Document Object Model (DOM) after executing these operations.

[0047] Specifically, the target object sends an HTTP request through the network to a specified web server by the browser. After the web server receives the request, it will return the hypertext content of the target web page as a response. The browser receives the response and parses the hypertext content until it parses the tag containing the specified script file and starts to load the specified script file, and then parses the Hypertext Markup Language code. The text parser of the browser will read and parse the Hypertext Markup Language code in the target web page line by line according to the Hypertext Markup Language specification. A Document Object Model tree (DOM tree) is constructed based on the Hypertext Markup Language tags, attributes, and other information. Once the script file is loaded, the browser will start to execute the code in it. If the script file contains operations on the page content, such as finding elements, adding event listeners, modifying styles or content, etc., the browser will immediately execute these operations. During the execution of the script, if the script operates on the elements in the page, the browser will update the Document Object Model (DOM) in real time. This means that the script can dynamically change the appearance and behavior of the page, including adding new elements, changing the styles or content of elements, etc.

[0048] Optionally, during the process of obtaining the Document Object Model, the web content in the target page can be detected, and the web content of the target website can be detected in the cloud. By comparing the web content in the target website with the samples in the cloud virus signature database, if the web content of the target website matches the samples in the network virus signature database, it is determined that there is a security risk in the target website. At this time, an exception prompt message is generated to prompt the target object to make a handling.

[0049] S203, obtain the Document Object Model of the browser.

[0050] S204, determine the nodes to be detected in the Document Object Model, and determine whether the elements of the specified file format are included in the nodes to be detected.

[0051] S205, if so, construct elements of the target file format to replace the elements of the specified file format, so as to control the browser to play a video of the target file format through the elements of the target file format.

[0052] For the steps S203 - S205, please refer to the description of the above embodiments S101 - S103, which will not be elaborated here.

[0053] As can be seen from the above, in this embodiment, by detecting whether the browser loads a specified script file, where the specified script file is used to monitor and process events in the browser; if the specified script file is loaded, the browser is allowed to parse the content of the current page to generate a Document Object Model; obtain the Document Object Model of the browser; determine the nodes to be detected in the Document Object Model, and determine whether the nodes to be detected contain elements in a specified file format; if so, construct elements in the target file format to replace the elements in the specified file format, so as to control the browser to play a video in the target file format through the elements in the target file format, which can enhance the applicability and scalability of the browser without relying on a third - party plugin. In addition, loading the specified script file and allowing the browser to parse the content of the current page and generate a Document Object Model can achieve dynamic transformation of web page content, thereby further improving the user experience and the scalability of the browser.

[0054] Optionally, please refer to Figure 3 , Figure 3 FIG.

[0055] S301, obtain the Document Object Model of the browser, where the Document Object Model includes multiple nodes for browser page display.

[0056] For the step S301, please refer to the description of the above embodiment S101, which will not be elaborated here.

[0057] S302, detect each node in the Document Object Model, and regard all nodes containing the target tag in the Document Object Model as the nodes to be detected.

[0058] Specifically, for example, to obtain all <embed> tag elements in the Document Object Model, the code segment "const embeds = document.getElementsByTagName('embed');" can be used. This code segment will return a list of nodes containing all <embed> tag elements. Another example, if you want to obtain all <object>Nodes of the label element can use the code snippet "const objects = document.getElementsByTagName('object');" which will return a list containing all <object>The node list of the label element. It will later contain the specified format file <embed> label elements and <object>The label element is used as the node to be detected. For example, in a <embed> label element, a file with the specified format ".Flv" is found. <embed flashvars="flv = https: / / abbb / aaaa / video / / / abc.Flv", and at this time, this <embed> label is used as the node to be detected.

[0059] S303. Monitor whether there is a new node inserted into the Document Object Model. If there is a new node inserted, detect the new node, and use all the new nodes in the Document Object Model that contain the target label as the nodes to be detected.

[0060] In this embodiment, it is necessary to monitor whether there is a new node inserted into the Document Object Model (DOM) and detect the new node.

[0061] Specifically, create a MutationObserver object in the Document Object Model and specify a callback function. In the callback function, use the mutation.type property to determine the type of change, and traverse the mutation.addedNodes property. Among them, the mutation.addedNodes property is a list of nodes that contains the newly added nodes. Determine whether the tagName property of each newly added node contains the target label. If a newly added node containing the target label is found, use it as the node to be detected.

[0062] S304. Determine whether the node to be detected contains an element with a specified file format.

[0063] Specifically, start traversing from the root node of the Document Object Model tree, and traverse all nodes level by level until the node to be detected is found. Among them, the node to be detected is a content embedding tag, such as <embed> or <object>etc., and can also be adjusted according to specific requirements for the nodes to be detected. For each traversed node, determine whether its node type is the preset node type to be detected and check whether the tag elements in the node to be detected contain elements of the specified file format. For example, in a target web page containing multiple embedded contents, it is necessary to find the <embed> or <object>tag. At this time, start traversing from the root node of the document object model and search for nodes level by level until <embed> or <object>The label is checked to see if the embedded audio file format conforms to the specified file type. Through the traversal process, it is possible to automatically find the embedded content of a specific type and perform corresponding processing to speed up data processing.

[0064] S305, detect whether the to-be-detected link address included in the element of the specified file format in the to-be-detected node is valid.

[0065] In this embodiment, to detect whether the link address included in the element of the specified file format in the to-be-detected node is valid, so as to determine which links are valid, and perform format conversion on the file after detecting a valid file. Through this process, it is possible to determine whether a link of a specific file format exists, is accessible, and is valid.

[0066] Specifically, traverse all the to-be-detected node lists and obtain the link addresses within the to-be-detected nodes (for example, by accessing attributes such as src and data). Determine whether the file format of the link address conforms to the specified format requirements. For example, match the file extension through a regular expression. For link addresses that meet the specified file format requirements, perform validity detection. If the status code returned by the request is 200, it means the link is available. If the status code returned by the request is 404, it means the link does not exist or has expired. If other status codes are returned by the request, corresponding processing can be carried out according to the actual situation.

[0067] For example, assume that it is necessary to detect the <embed> availability of the video link address in the first to-be-detected node. All flashvars attributes in the page can be traversed to obtain "flv= https: / / abbb / aaaa / video / / / abc.Flv". At this time, perform validity detection on the video link address https: / / abbb / aaaa / video / / / abc.Flv, initiate a network request to access this link. If the status code returned at this time is 404, it means that the <embed> link address in the first to-be-detected node does not exist or has expired.

[0068] S306, if the to-be-detected link address is valid, construct the target link address, where the target link address corresponds to the video of the target file format.

[0069] In this embodiment, if the to-be-detected link address is valid, convert the video with the suffix ".Flv" format in the link address into a video file with the ".Mp4" format, and use <video>The label binds the link address of the converted video file and plays it on the target page.

[0070] Specifically, when it is detected that the <embed> video link address with the suffix ".Flv" in the label is valid, a custom element is generated at this time , and in the custom element Generate child nodes <video>Label, and after converting the video with the specified file format suffix ".Flv" into a video file corresponding to the target format file ".Mp4". Use the address of the video corresponding to the video file ".Mp4" as a child node <video>the src attribute in the tag, and then <embed> replace the tag with a custom element And play the video corresponding to the target format file on the target web page.

[0071] S307, construct a target tag, and insert the target link address into the target tag to obtain an element in the target file format.

[0072] Specifically, generate a custom element , and in the custom element Generate child nodes <video>Label, and convert the video corresponding to the specified file format to generate a video corresponding to the target format file. For example, convert it to a video file with the format ".Mp4". Use the target link address of the video corresponding to the target format file as a child node <video>The src attribute in the tag, and then <embed> replace the tag with a custom element 。

[0073] S308 replaces the elements of the target file format with the elements of the specified file format to control the browser to play the video of the target file format through the target link address.

[0074] Specifically, custom elements are generated , and in the custom element Generate child nodes <video>Label, and convert the video corresponding to the specified file format to generate a video corresponding to the target format file. For example, convert it to a video file with the format ".Mp4". Use the target link address of the video corresponding to the target format file as a child node <video>The src attribute in the tag, and then <embed> Replace the tag with a custom element And play the video corresponding to the target format file in the target web page.

[0075] S309, if the to-be-detected link address is invalid, delete the to-be-detected node and generate an error prompt message.

[0076] Specifically, when it is detected that the <embed> video link address with the suffix ".Flv" in the to-be-detected tag is invalid, generate a prompt message in the target web page and <embed> delete the tag from the document object model of the current target web page. For example, the document object model of the target web page contains <embed> a tag: <embed src="https: example.com video1.Flv"type="video flv"> , and at this time, through the validity detection, it is found that <embed> the video link address https: / / example.com / video1.Flv corresponding to the src attribute in the tag is invalid. At this time, the <embed> tag can be deleted from the document object model and an error prompt message is generated. For example, "Error: Invalid video link address. Possible reasons include link failure, target server failure, or network connection problem. Please check the correctness of the link and retry". Through the error prompt message, the user can understand the reason for the invalid video link and perform corresponding operations according to the suggestions in the prompt. For example, check the link address spelling and network connection status, etc. At the same time, the <embed> tag will also be deleted from the document object model to avoid the influence of invalid links on subsequent processing.

[0077] As can be seen from the above, in this embodiment, by detecting each node in the document object model and taking all the nodes containing the target tag in the document object model as the to-be-detected nodes, it can help developers find and operate specific nodes in the page, thus realizing more flexible and rich web page interaction effects and further improving the extensibility of the browser; by detecting whether the to-be-detected link address included in the element of the specified file format in the to-be-detected node is valid; if the to-be-detected link address is valid, construct the target link address, where the target link address corresponds to the video of the target file format, it can ensure that the used link address is valid and can further speed up the processing speed of the browser. By loading the specified script file and allowing the browser to parse and generate the document object model for the content of the current page, the dynamic transformation of the web page content can be realized to enhance the user experience. By constructing the target tag and inserting the target link address into the target tag to obtain the element of the target file format; replacing the element of the specified file format with the element of the target file format to control the browser to play the video of the target file format through the target link address, it can realize playing the video in the target web page without using a third-party video player plugin, thus effectively improving the applicability of the browser.

[0078] In addition, an embodiment of the present application also provides a browser video playback device. Please refer to Figure 4 , Figure 4 which is a schematic structural diagram of the browser video playback device provided by the embodiment of the present application. Among them, the browser video playback device 400 may include an acquisition module 401, a determination module 402, and a replacement module 403, specifically as follows:

[0079] The acquisition module 401 is configured to acquire the document object model of the browser, where the document object model includes multiple nodes for browser page display;

[0080] The determination module 402 is configured to determine a node to be detected in the document object model and determine whether an element in the node to be detected includes a specified file format;

[0081] The replacement module 403 is configured to, if so, construct an element of the target file format to replace the element of the specified file format, so as to control the browser to play a video of the target file format through the element of the target file format.

[0082] In some embodiments, the acquisition module 401 further includes a detection module, configured to detect whether the browser loads a specified script file, where the specified script file is used to monitor and process events in the browser;

[0083] Optionally, the acquisition module 401 further includes a detection and parsing module, configured to, if the specified script file is loaded, allow the browser to parse the content of the current page to generate a document object model.

[0084] In some embodiments, the determination module 402 further includes a node detection module, configured to detect each node in the document object model and use all nodes in the document object model that contain the target tag as the nodes to be detected.

[0085] In some embodiments, the replacement module 403 further includes a link address module, configured to detect whether the to-be-detected link address included in the element of the specified file format in the node to be detected is valid;

[0086] Optionally, the replacement module 403 further includes a construction module, configured to, if the to-be-detected link address is valid, construct a target link address, where the target link address corresponds to a video of the target file format.

[0087] In some embodiments, the replacement module 403 further includes a target tag construction module, configured to construct a target tag and insert the target link address into the target tag to obtain an element of the target file format;

[0088] Optionally, the replacement module 403 is further configured to replace the elements in the specified file format with the elements in the target file format, so as to control the browser to play the video in the target file format through the target link address.

[0089] In some embodiments, the replacement module 403 further includes a prompt module, configured to delete the node to be detected and generate an error prompt message if the link address to be detected is invalid.

[0090] It should be noted that the browser video playback device provided in the embodiments of the present application and the browser video playback method in the above embodiments belong to the same concept. Any method provided in the embodiments of the browser video playback method can be run on the browser video playback device. For the specific implementation process, please refer to the embodiments of the browser video playback method, which will not be elaborated here.

[0091] In this embodiment, the browser video playback device 400 obtains the document object model of the browser through the obtaining module 401, where the document object model includes multiple nodes for browser page display; through the determining module 402, the node to be detected is determined in the document object model, and it is determined whether the node to be detected contains elements in the specified file format; through the replacement module 403, if so, elements in the target file format are constructed to replace the elements in the specified file format, so as to control the browser to play the video in the target file format through the elements in the target file format. By obtaining the document object model of the browser, where the document object model includes multiple nodes for browser page display; determining the node to be detected in the document object model and determining whether the node to be detected contains elements in the specified file format; if so, constructing elements in the target file format to replace the elements in the specified file format, so as to control the browser to play the video in the target file format through the elements in the target file format, the applicability and scalability of the target browser are enhanced without relying on a third-party video playback plugin, thus bringing a better user experience to the target object.

[0092] This embodiment also provides a computer-readable storage medium, in which computer program code is stored. When the computer program code runs on a computer, the computer is made to execute the above relevant method steps to implement the browser video playback method provided in the above embodiments.

[0093] Among them, the storage medium may include: read-only memory (ROM, Read Only Memory), random access memory (RAM, Random Access Memory), magnetic disk or optical disc, etc.

[0094] Since the instructions stored in the storage medium can execute the steps in any of the browser video playing methods provided by the embodiments of the present application, the beneficial effects achievable by any of the browser video playing methods provided by the embodiments of the present application can be realized. For details, refer to the previous embodiments and will not be elaborated here.

[0095] Correspondingly, an electronic device 500 is further provided in an embodiment of the present application. The electronic device 500 may include devices such as vehicle-mounted terminals. Please refer to the figure. Figure 5 It is a first structural schematic diagram of the electronic device provided by an embodiment of the present application. The electronic device 500 includes a processor 501 and a memory 502. Among them, the processor 501 is electrically connected to the memory 502.

[0096] The processor 501 is the control center of the electronic device 500, connecting various parts of the entire electronic device through various interfaces and lines. By running or calling the computer programs stored in the memory 502 and calling the data stored in the memory 502, it executes various functions of the electronic device and processes data, thereby monitoring the electronic device as a whole.

[0097] The memory 502 can be used to store software programs and modules. The processor 501 executes various functional applications and browser video playing by running the computer programs and modules stored in the memory 502. The memory 502 may mainly include a program storage area and a data storage area. Among them, the program storage area can store an operating system, computer programs required for at least one function, etc.; the data storage area can store data created according to the use of the electronic device, etc.

[0098] In addition, the memory 502 may include a high-speed random access memory and may also include a non-volatile memory, such as at least one magnetic disk storage device, a flash memory device, or other volatile solid-state storage devices. Correspondingly, the memory 502 may further include a memory controller to provide the processor 501 with access to the memory 502.

[0099] In this embodiment, the processor 501 in the electronic device 500 will load the instructions corresponding to the processes of one or more computer programs into the memory 502 according to the following steps, and the processor 501 will run the computer programs stored in the memory 502 to implement various functions as follows:

[0100] Obtain the document object model of the browser, where the document object model includes multiple nodes for browser page display;

[0101] Determine the node to be detected in the document object model and determine whether the element of the specified file format is included in the node to be detected;

[0102] If so, construct elements of the target file format to replace elements of the specified file format, so as to control the browser to play a video in the target file format through the elements of the target file format.

[0103] In some embodiments, refer to Figure 6 , Figure 6 which is the second schematic structural diagram of the electronic device provided by the embodiments of the present application. The electronic device 500 may include: a processor 501, a memory 502, a display screen 503, a camera assembly 504, an audio circuit 505, a sensor 506, and a power supply 507. Among them, the processor 501 is electrically connected to the display screen 503, the camera assembly 504, the audio circuit 505, the sensor 506, and the power supply 507 respectively.

[0104] The display screen 503 can be used to display information input by the user or information provided to the user, as well as various graphical user interfaces of the electronic device. These graphical user interfaces can be composed of images, texts, icons, videos, and any combination thereof.

[0105] The camera assembly 504 may include an image processing circuit. The image processing circuit can be implemented by using hardware and / or software components, and may include various processing units that define an Image Signal Processing pipeline. The image processing circuit can at least include: multiple cameras, an Image Signal Processor (ISP processor), a control logic unit, and an image memory, etc. Each of the cameras can at least include one or more lenses and an image sensor. The image sensor can include a color filter array (such as a Bayer filter). The image sensor can acquire the light intensity and wavelength information captured by each imaging pixel of the image sensor, and provide a set of raw image data that can be processed by the image signal processor.

[0106] The audio circuit 505 can be used to provide an audio interface between the user and the electronic device through a speaker and a microphone. Among them, the audio circuit 505 includes a microphone. The microphone is electrically connected to the processor 501. The microphone is used to receive voice information input by the user.

[0107] The sensor 506 is used to collect information about the electronic device itself, or information about the user, or information about the external environment. For example, the sensor 506 can include one or more of sensors such as a vibration sensor, a temperature sensor, a distance sensor, a magnetic field sensor, a light sensor, an acceleration sensor, a fingerprint sensor, a Hall sensor, a position sensor, a gyroscope, an inertial sensor, an attitude sensor, a barometer, and a heart rate sensor.

[0108] The power supply 507 is used to supply power to various components of the electronic device 500. In some embodiments, the power supply 507 may be logically connected to the processor 501 through a power management system, so as to implement functions such as management of charging, discharging, and power consumption management through the power management system.

[0109] In the embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of modules or units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the displayed or discussed coupling or direct coupling or communication connection between each other can be through some interfaces. The indirect coupling or communication connection of the device or unit can be in electrical, mechanical or other forms.

[0110] For the browser video playback device of the embodiments of this application, its various functional modules can be integrated in a processing chip, or each module can exist physically alone, or two or more modules can be integrated in one module. The above integrated modules can be implemented in the form of hardware or in the form of software functional modules. If the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium.

[0111] The above has introduced in detail the browser video playback method, device, electronic device and storage medium provided by the embodiments of this application. Specific examples are used in this article to elaborate on the principle and implementation manner of this application. The above embodiments are only used to help understand the method and its core idea of this application; at the same time, for those skilled in the art, according to the idea of this application, there will be changes in the specific implementation manner and application scope. In summary, the content of this specification should not be construed as a limitation to this application. < / video> < / video> < / video> < / video> < / video> < / video> < / video> < / object> < / object> < / object> < / object> < / object> < / object> < / video> < / video> < / video> < / object> < / object> < / object> < / object>

Claims

1. A method for playing browser videos, characterized in that, The method includes: Obtain the Document Object Model (DOM) of the browser, where the DOM includes multiple nodes for browser page display; Determine a node to be detected in the DOM, and determine whether the node to be detected contains an element in a specified file format; If so, construct an element in the target file format to replace the element in the specified file format, so as to control the browser to play a video in the target file format through the element in the target file format.

2. The browser video playing method according to claim 1, wherein Before obtaining the Document Object Model of the browser, it includes: Detect whether the browser loads a specified script file, where the specified script file is used to listen for and process events in the browser; If the specified script file is loaded, allow the browser to parse the content of the current page to generate the Document Object Model.

3. The browser video playing method according to claim 1, wherein The determining a node to be detected in the DOM includes: Detect each node in the DOM, and use all nodes in the DOM that contain a target tag as the node to be detected.

4. The browser video playing method according to claim 1, wherein Before constructing an element in the target file format to replace the element in the specified file format, so as to control the browser to play a video in the target file format through the element in the target file format, it includes: Detect whether the detected link address included in the element in the specified file format in the node to be detected is valid; If the detected link address is valid, construct a target link address, where the target link address corresponds to a video in the target file format.

5. The browser video playing method according to claim 4, wherein The method further includes: Construct a target tag, and insert the target link address into the target tag to obtain the element in the target file format; Replace the element in the specified file format with the element in the target file format, so as to control the browser to play the video in the target file format through the target link address.

6. The browser video playback method according to claim 4, characterized in that, after detecting whether the detected link address included in the element in the specified file format of the node to be detected is valid, the method further includes: If the detected link address is invalid, delete the node to be detected and generate an error prompt message.

7. The browser video playing method according to claim 3, wherein After detecting each node in the DOM and using all nodes in the DOM that contain a target tag as the node to be detected, the method further includes: Monitor whether a new node is inserted into the DOM; If a new node is inserted, detect the new node, and use all new nodes in the DOM that contain a target tag as the node to be detected.

8. A browser video playback device, characterized in that, It includes: An acquisition module, configured to obtain the Document Object Model of the browser, where the DOM includes multiple nodes for browser page display; A determination module, configured to determine a node to be detected in the DOM, and determine whether the node to be detected contains an element in a specified file format; A replacement module, which is used to, if so, construct elements in a target file format to replace the elements in the specified file format, so as to control the browser to play a video in the target file format through the elements in the target file format.

9. An electronic device, characterized in that, The electronic device includes: A memory for storing executable program code; A processor for calling and running the executable program code from the memory, so that the electronic device executes the browser video playback method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, which, when executed, implements the browser video playback method according to any one of claims 1 to 7.