Detailed Description
The following description of the technical solutions in the embodiments of the present application will be clear and complete, and it is obvious that the described embodiments are only some embodiments of the present application, but not all embodiments. All other embodiments, which can be made by one of ordinary skill in the art without undue burden from the present disclosure, are within the scope of the present disclosure.
For a more detailed description of the present application, a browser video playing method, apparatus, terminal device and computer readable storage medium provided in the present application are specifically described below with reference to the accompanying drawings.
Referring to fig. 1, fig. 1 is a schematic diagram illustrating an application scenario of a browser video playing method provided in an embodiment of the present application, where the application scenario includes aterminal device 100 provided in an embodiment of the present application, and theterminal device 100 may be various electronic devices (such as a structure diagram of 102, 104, 106, and 108) with a display screen, including, but not limited to, a smart phone and a computer device, where the computer device may be at least one of a desktop computer, a portable computer, a laptop computer, a tablet computer, and the like. The terminal device may be installed and run with a browser and a video playing plug-in, where the browser and the video playing plug-in belong to two completely independent applications. Alternatively, the type or kind of browser may be various, such as an IE browser, google browser, firefox browser, 360 browser, and the like. The video playing plug-in is an application program special for playing streaming media, supports webSocket communication, and can be operated as a service in the background after the installation is completed. Waiting for other applications (e.g., browser) to establish webSocket connection with them, and initiating instructions. The function of the method is to process the play of the media stream, and is not limited to the service functions of directly performing control operation and playback search on the network video recorder (i.e. NVR) and the video camera through the http request, as shown in fig. 2.
Theterminal device 100 may refer broadly to one of a plurality of terminal devices, and the present embodiment is illustrated with theterminal device 100 only. Those skilled in the art will appreciate that the number of terminal devices described above may be greater or lesser. For example, the number of the terminal devices may be only several, or the number of the terminal devices may be tens or hundreds, or more, and the number and types of the terminal devices are not limited in the embodiment of the present application. Theterminal device 100 may be configured to perform a browser video playing method provided in an embodiment of the present application.
In an optional implementation manner, the application scenario may further include a server in addition to theterminal device 100 provided in the embodiment of the present application, where a network is disposed between the server and the terminal device. The network is used as a medium for providing a communication link between the terminal device and the server. The network may include various connection types, such as wired, wireless communication links, or fiber optic cables, among others.
It should be understood that the number of terminal devices, networks and servers is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation. For example, the server may be a server cluster formed by a plurality of servers. Wherein the terminal device interacts with the server through the network to receive or send messages and the like. The server may be a server providing various services. The server may be used to execute the steps of a browser video playing method provided in the embodiments of the present application. In addition, when the terminal device executes a browser video playing method provided in the embodiment of the present application, a part of steps may be executed in the terminal device, and a part of steps may be executed in the server, which is not limited herein.
Based on the above, the embodiment of the application provides a browser video playing method. Referring to fig. 3, fig. 3 shows a flowchart of a video playing method of a browser according to an embodiment of the present application, and the method is applied to the terminal device in fig. 1 for illustration, and includes the following steps:
step S110, establishing webSocket connection between the browser and the video playing plug-in.
Wherein the video playing plug-in is pre-installed and independent of the browser; the video playback plug-ins include one or more sub-playback plug-ins.
Specifically, the video playing plug-in is an application for streaming video playing that is pre-installed in a terminal device (e.g., a computer). The video playing plug-in is a browser independent functional component, i.e. not embedded in the browser.
Optionally, the video playing plug-in includes a plurality of sub-playing plug-ins, each representing a different type or function of plug-in, e.g., different sub-playing plug-ins support different types or formats of video playing. In an alternative embodiment, the sub-play plug-in may include, but is not limited to, a single window plug-in, a quad screen plug-in, a plug-in carrying a cradle head control function, and the like.
WebSocket is a protocol that performs full duplex communication over a single TCP connection. The method is characterized in that the server can actively push information to the client, the client can also actively send information to the server, and the method is a real bidirectional equal dialogue, namely mutual communication between two main bodies can be realized through webSocket. At present, all browsers can support webSocket protocol, and when the browser is connected with a video playing plug-in (or a sub-playing plug-in), the browser and the video playing plug-in (or the sub-playing plug-in) can communicate with each other.
Further, the process of establishing webSocket connection between the browser and the video playing plug-in is as follows: and opening an H5 page in the browser, and then inputting related information (such as browser information and video playing plug-in information) in the H5 page, so as to establish webSocket connection between the browser and the video playing plug-in. Wherein, the browser information includes but is not limited to browser name, installation or storage location, access mode or path, etc.; video playback plug-in information includes, but is not limited to, video playback plug-in name, installation or storage location, access mode or path, etc.
The browser can be one or more of google browser, firefox browser, 360 browser or IE browser. When a plurality of browsers exist, the plurality of browsers can establish webSocket connection with the video playing plug-in at the same time.
In addition, after the webSocket connection is established between the browser and the video playing plug-in, the video playing plug-in can return an identification information to the browser through a webSocket protocol, wherein the identification information is usually referred to as uuid of the video playing plug-in, and the uuid is used as an identification of the connection, and is also a signaling address of a command sent by the browser to the video playing plug-in, so that the command can be conveniently sent by the browser to the video playing plug-in.
Step S120, a starting instruction is sent to the video playing plug-in through the browser so as to start the corresponding sub-playing plug-in.
After the connection between the browser and the video playing plug-in is successfully established, any one or more sub-playing plug-ins in the video playing plug-ins can be started by sending a starting instruction through the browser. The specific process is as follows: when a video needs to be played in a browser and a certain sub-play plug-in is needed, a starting instruction can be sent out through an H5 page of the browser, the starting instruction is sent to the video play plug-in through a webSocket protocol, and after the video play plug-in receives the starting instruction, the corresponding sub-play plug-in is started according to the starting instruction.
The starting instruction mainly comprises a plug-in type and occupation information. The plug-in type is mainly used for determining the sub-play plug-in to be started, namely determining which sub-play plug-in to be started; the occupation information is mainly used for determining the size and the display position of the sub-play plug-in after the start.
Next, an embodiment of a promoter playing plug-in is given, and the detailed description is as follows:
in one embodiment, the initiation instructions include a plug-in type; starting a corresponding sub-play plug-in, comprising: and starting the corresponding sub-play plug-in according to the plug-in type.
The plug-in types can be multiple, and each type can represent different functions or support different formats of video.
In an alternative embodiment, the plug-in types may include a single window plug-in, a quarter-screen plug-in, a plug-in that carries a cradle head control function, and the like.
After determining the plug-in type, the plug-in type can be searched or indexed in various sub-play plug-ins of the video play plug-in according to the plug-in type, and then the sub-play plug-in corresponding to the plug-in type is started.
And step S130, covering and displaying the started sub-play plug-in to the corresponding position of the browser.
In one embodiment, the startup instruction includes occupancy information; covering the started sub-play plug-in to the corresponding position of the browser, wherein the method comprises the following steps: determining the target size and the target position of the started sub-play plug-in according to the occupation information; and covering the started sub-play plug-in to a target position of the browser according to the target size.
The placeholder information generally refers to placeholder div information, wherein div is a div element in a browser H5 page, and the div is used as a place for replacing a plug-in to camp on when a sub-play plug-in is not started. When a sub-play plug-in is started, the target size (e.g., width and height) and target position (i.e., display position in the browser) of the started sub-play plug-in are determined by the position information and size in the div information.
After receiving the occupation information, the video playing plug-in determines the display position (i.e. the target position) and the display size (i.e. the target size) of the sub-playing plug-in the browser, which need to be started, according to the occupation information, and then covers the started sub-playing plug-in the browser for display according to the target position and the target size.
In addition, after the sub-playing plug-in is started, the sub-playing plug-in can return an identification message to the browser through webSocket protocol, wherein the identification message generally refers to uuid of the started sub-playing plug-in, and the uuid is used as an identification of a sending instruction between the currently started sub-playing plug-in and an H5 page in the browser, and is also a sending address of the sending instruction of the browser to the currently started sub-playing plug-in, so that the browser can conveniently send the instruction to the currently started sub-playing plug-in.
Step S140, sending a playing instruction to the started sub-playing plug-in through the browser so that the started sub-playing plug-in plays the video.
After the sub-playing plug-in is started, a playing instruction can be sent to the sub-playing plug-in through an H5 page of the browser, wherein the playing instruction is related information for executing the sub-playing plug-in to play video, and the related information can include, but is not limited to, a playing video type, a playing video name, a playing video speed, a playing video path and the like.
According to the browser video playing method provided by the embodiment of the application, firstly, webSocket connection between a browser and a video playing plug-in is established; wherein the video playing plug-in is pre-installed and independent of the browser; the video playing plug-in comprises one or more sub-playing plug-ins; then sending a starting instruction to the video playing plug-in through the browser so as to start the corresponding sub-playing plug-in; covering the started sub-play plug-in to the corresponding position of the browser and displaying the sub-play plug-in; and sending a playing instruction to the started sub-playing plug-in through the browser so that the started sub-playing plug-in plays the video.
According to the browser video playing method, a plurality of sub-playing plug-ins are installed in advance, and the video playing plug-ins are independent of a browser; when the browser needs to use the video playing plug-in, connection between the browser and the video playing plug-in is established, wherein different kinds of browsers can be simultaneously connected with the video playing plug-in, and then the corresponding sub-playing plug-in is started by sending related instructions through the browser, so that related videos are played. The method can effectively solve the problem of compatibility of the video playing plug-in different browsers, and can play different types or kinds of videos only by installing one video plug-in, so that the method is very convenient to use.
Because the browser is relatively independent of the video playing plug-in (or the sub-playing plug-in), when one sub-playing plug-in is started, the sub-playing plug-in can be covered at a designated position of the browser, and is not embedded in a certain page of the browser. When the browser changes based on some operations of the user, the sub-play plug-in does not follow the changes of the browser to generate corresponding changes. For example, when the browser zooms, and switches tab pages, the sub-play plug-in does not directly follow the browser to zoom. If the sub-playing plug-in needs to make corresponding changes along with the browser, some instructions need to be sent to the started sub-playing plug-in through the browser, and then the playing plug-in is controlled, for example, stopping playing video, closing the sub-playing plug-in, adjusting the sub-playing plug-in, hiding the sub-playing plug-in, and the like, and the following embodiments are referred to for specific description.
In one embodiment, the browser video playing method further includes: and sending a stopping instruction to the started sub-play plug-in through the browser so as to stop the started sub-play plug-in from playing the video.
Specifically, the stop instruction is a command for controlling the sub-playback plug-in to stop playing video. The command may use the H5 page of the browser to send a stop command to the started sub-playback plug-in, where the sub-playback plug-in responds to the stop command to stop playing the video currently being played.
In one embodiment, the browser video playing method further includes: and sending a closing instruction to the started sub-play plug-in through the browser so as to close the started sub-play plug-in.
The closing instruction is used for closing the started and running sub-play plug-in. The closing instruction can be sent to the started sub-play plug-in based on the webSocket protocol through the H5 page of the browser, and the sub-play plug-in receiving the closing instruction can respond to the closing instruction, so that the running sub-play plug-in is closed; when the sub-play plug-in is closed, the browser cannot communicate with the sub-play plug-in until the browser is restarted by an opening instruction.
In one embodiment, the browser video playing method further includes: when the scaling of the browser is monitored, sending an adjusting instruction to the started sub-play plug-in through the browser so as to adjust the target size and/or the target position of the started sub-play plug-in displayed by the browser.
Specifically, when the browser sends a zoom, for example, when the browser window becomes larger or smaller, the sub-playing plug-in also needs to be adjusted accordingly. The H5 page of the browser may be adopted, and the adjustment instruction is sent to the started subplay plug-in through webSocket protocol, and the subplay plug-in responds to the adjustment instruction, so as to change the display size and/or the display position in the display.
In one embodiment, the browser video playing method further includes: when the browser is monitored to be switched to the page, a hiding instruction is sent to the started sub-play plug-in through the browser so as to hide the started sub-play plug-in.
Specifically, when the browser switches tab pages (i.e., performs a page switch), the started sub-playback plug-in will be overlaid on the switched browser pages, but the sub-playback plug-in is not desired to be displayed at this time. Then the switching event of the browser needs to be monitored, and when the browser switches out the current H5 page, a hiding command needs to be initiated to the sub-play plug-in to hide the sub-play plug-in. When the browser switches back to the current page, a display command is started again, so that the sub-play plug-in unit is displayed again.
By adopting the mode, the video playing plug-in (or the sub-playing plug-in) can be directly controlled through the browser, so that the video playing plug-in is more convenient to use. In addition, the video playing plug-in supports to be connected with a plurality of browsers at the same time, so that the compatibility problem can be well solved, and the use efficiency is improved.
It should be understood that, although the steps in the flowchart of fig. 3 are shown in sequence as indicated by the arrows, the steps are not necessarily performed in sequence as indicated by the arrows. The steps are not strictly limited to the order of execution unless explicitly recited herein, and the steps may be executed in other orders. Moreover, at least some of the steps in fig. 3 may include multiple sub-steps or stages that are not necessarily performed at the same time, but may be performed at different times, nor does the order in which the sub-steps or stages are performed necessarily occur sequentially, but may be performed alternately or alternately with at least some of the other steps or sub-steps of other steps.
The embodiment disclosed in the application describes a method for playing a browser video in detail, and the method disclosed in the application can be implemented by using various types of devices, so that the application also discloses a device for playing a browser video corresponding to the method, and specific embodiments are given below for detailed description.
Referring to fig. 4, a video playing device for a browser according to an embodiment of the present application mainly includes:
aconnection establishment module 410, configured to establish webSocket connection between the browser and the video playing plug-in; wherein the video playing plug-in is pre-installed and independent of the browser; the video playback plug-ins include one or more sub-playback plug-ins.
The sub-plug-instarting module 420 is configured to send a starting instruction to the video playing plug-in through the browser, so as to start the corresponding sub-playing plug-in.
And the sub-plug-indisplay module 430 is used for covering and displaying the started sub-play plug-in at the corresponding position of the browser.
Thevideo playing module 440 is configured to send a playing instruction to the started sub-playing plug-in through the browser, so that the started sub-playing plug-in plays the video.
In one embodiment, the initiation instructions include a plug-in type; the sub-plug-instarting module 420 is configured to start a corresponding sub-play plug-in according to the plug-in type.
In one embodiment, the startup instruction includes occupancy information; a sub-plug-indisplay module 430, configured to determine a target size and a target position of the started sub-play plug-in according to the occupation information; and covering the started sub-play plug-in to a target position of the browser according to the target size.
In one embodiment, the apparatus further comprises: and the video stopping playing module is used for sending a stopping instruction to the started sub-playing plug-in through the browser so as to stop the started sub-playing plug-in from playing the video.
In one embodiment, the apparatus further comprises: and the sub-play plug-in closing module is used for sending a closing instruction to the started sub-play plug-in through the browser so as to close the started sub-play plug-in.
In one embodiment, the apparatus further comprises: and the sub-play plug-in adjusting module is used for sending an adjusting instruction to the started sub-play plug-in through the browser when the scaling of the browser is monitored so as to adjust the target size and/or the target position of the started sub-play plug-in displayed by the browser.
In one embodiment, the apparatus further comprises: and the sub-play plug-in hiding module is used for sending a hiding instruction to the started sub-play plug-in through the browser when the page switching of the browser is monitored, so as to hide the started sub-play plug-in.
The specific limitation of the browser video playing apparatus may be referred to as limitation of the method hereinabove, and will not be described herein. Each of the modules in the above-described apparatus may be implemented in whole or in part by software, hardware, and combinations thereof. The above modules may be embedded in hardware or independent of a processor in the terminal device, or may be stored in software in a memory in the terminal device, so that the processor may call and execute operations corresponding to the above modules.
Referring to fig. 5, fig. 5 shows a block diagram of a terminal device according to an embodiment of the present application. Theterminal device 50 may be a computer device. Theterminal device 50 in the present application may include one or more of the following components:processor 52,memory 54, and one or more application programs, wherein the one or more application programs may be stored inmemory 54 and configured to be executed by the one ormore processors 52, the one or more application programs configured to perform the methods described in the method embodiments of application to a terminal device, and also configured to perform the methods described in the method embodiments of application to a browser video playback.
Processor 52 may include one or more processing cores. Theprocessor 52 utilizes various interfaces and lines to connect various portions of the overallterminal device 50, perform various functions of theterminal device 50 and process data by executing or executing instructions, programs, code sets, or instruction sets stored in thememory 54, and invoking data stored in thememory 54. Alternatively, theprocessor 52 may be implemented in hardware in at least one of digital signal processing (Digital Signal Processing, DSP), field programmable gate array (Field-Programmable Gate Array, FPGA), programmable logic array (Programmable Logic Array, PLA). Theprocessor 52 may integrate one or a combination of several of a central processing unit (Central Processing Unit, CPU), a graphics processor (Graphics Processing Unit, GPU), and a modem, etc. The CPU mainly processes an operating system, a user interface, an application program and the like; the GPU is used for being responsible for rendering and drawing of display content; the modem is used to handle wireless communications. It will be appreciated that the modem may not be integrated into theprocessor 52 and may be implemented solely by a single communication chip.
TheMemory 54 may include a random access Memory (Random Access Memory, RAM) or a Read-Only Memory (Read-Only Memory).Memory 54 may be used to store instructions, programs, code sets, or instruction sets. Thememory 54 may include a stored program area and a stored data area, wherein the stored program area may store instructions for implementing an operating system, instructions for implementing at least one function (e.g., a touch function, a sound playing function, an image playing function, etc.), instructions for implementing various method embodiments described below, and the like. The storage data area may also store data created by theterminal device 50 in use, etc.
It will be appreciated by those skilled in the art that the structure shown in fig. 5 is merely a block diagram of a portion of the structure associated with the present application and is not limiting of the terminal device to which the present application is applied, and that a particular terminal device may include more or fewer components than shown, or may combine some of the components, or have a different arrangement of components.
In summary, the terminal device provided in the embodiment of the present application is configured to implement the corresponding method for playing the video of the browser in the foregoing method embodiment, and has the beneficial effects of the corresponding method embodiment, which is not described herein again.
Referring to fig. 6, a block diagram of a computer readable storage medium according to an embodiment of the present application is shown. The computerreadable storage medium 60 stores program code that is capable of being invoked by a processor to perform the methods described in the browser video playback method embodiments described above, or by a processor to perform the methods described in the browser video playback method embodiments described above.
The computerreadable storage medium 60 may be an electronic memory such as a flash memory, an EEPROM (electrically erasable programmable read only memory), an EPROM, a hard disk, or a ROM. Optionally, the computerreadable storage medium 60 comprises a non-transitory computer readable medium (non-transitory computer-readable storage medium). The computerreadable storage medium 60 has storage space forprogram code 62 that performs any of the method steps described above. The program code can be read from or written to one or more computer program products.Program code 62 may be compressed, for example, in a suitable form.
In the description of the present specification, a description referring to terms "one embodiment," "some embodiments," "examples," "specific examples," or "some examples," etc., means that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the present application. In this specification, schematic representations of the above terms are not necessarily directed to the same embodiment or example. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples. Furthermore, the different embodiments or examples described in this specification and the features of the different embodiments or examples may be combined and combined by those skilled in the art without contradiction.
The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the application. Thus, the present application is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.