Disclosure of Invention
The application provides a video playing method, a video playing device and a computer readable storage medium, which can solve the problem that the video cannot be successfully redirected in the related technology. The technical scheme is as follows:
in a first aspect, a video playing method is provided, which is applied to a virtual machine installed in a virtual desktop server, and the method includes:
when an access instruction of a target webpage sent by a terminal is received, sending a webpage request of the target webpage to a webpage server; receiving webpage information of the target webpage sent by the webpage server; when the target webpage has a video, acquiring a video identifier of the video from the webpage information; generating a page address of the video according to the video identifier of the video; constructing a floating frame (iframe) tag, and setting the page address as the src attribute value of the iframe tag; and sending the iframe label to the terminal, and acquiring and playing the video by the terminal according to the iframe label.
It should be noted that the page address of the video may indicate the position of the page where the video is located, that is, the page where the video is located may be obtained according to the page address of the video, and the video is played in the page. In addition, the page may further include a player in the target web page for playing the video, where the video is played in a frame of the player included in the page.
In addition, the iframe tag is used to create an inline frame that contains another document. The iframe tag has a plurality of attributes, wherein the src attribute value of the iframe tag is the document address of the document to be displayed.
In the embodiment of the application, because the virtual machine is an iframe tag constructed according to the video identifier of the video and is sent to the terminal, the terminal can successfully acquire the page where the video is played according to the received src attribute value of the iframe tag, so that redirection of the video can be successfully achieved.
When a video exists in the target webpage, acquiring a video identifier of the video from the webpage information includes: when the video exists in the target webpage, acquiring a video address of the video from the webpage information; and when the video address does not meet the preset condition, acquiring the video identifier of the video from the webpage information.
Further, when the video address meets the preset condition, the video address is sent to the terminal, and the terminal acquires and plays the video according to the video address.
It should be noted that the video address of the video may indicate the location of the video, i.e., the video may be obtained according to the video address of the video.
In addition, the preset condition may be preset, and the preset condition is a condition for determining whether the video address acquired from the web page information is a real address, that is, a condition for determining whether the video address acquired from the web page information can successfully acquire the video.
In this embodiment of the application, when the video address does not satisfy the preset condition, it indicates that the video address is not a real address, and at this time, the virtual machine may obtain a video identifier of the video, so as to generate a page address of the video accordingly. And when the video address meets the preset condition, the video address is indicated to be a real address, and at the moment, the virtual machine can send the video address to the terminal so that the terminal can directly acquire and play the video according to the video address.
Further, when there is a video in the target webpage, before acquiring the video address of the video from the webpage information, the method further includes: and when the video tag exists in the webpage information, determining that the video exists in the target webpage. Correspondingly, when a video exists in the target webpage, acquiring a video address of the video from the webpage information includes: and when the video tag exists in the webpage information, acquiring the src attribute value of the video tag as the video address of the video.
It should be noted that the video tag is used to define a video, such as a movie clip or other video stream. The video tag has a plurality of attributes, wherein the src attribute value of the video tag is the video address of the video to be played.
In the embodiment of the application, the virtual machine can quickly judge whether the video exists in the target webpage or not according to the existence of the video tag, and when the video exists in the target webpage, the video in the target webpage can be quickly acquired according to the video tag, so that the video redirection speed can be improved.
Further, when the video address does not satisfy the preset condition, before acquiring the video identifier of the video from the web page information, the method further includes: and when the video address does not comprise a preset character string, determining that the video address does not meet the preset condition. And when the video address comprises a preset character string, determining that the video address meets a preset condition.
When judging whether the video address comprises the preset character string, judging whether a suffix of the video address is the preset character string, when the suffix of the video address is not the preset character string, determining that the video address does not meet the preset condition, and when the suffix of the video address is the preset character string, determining that the video address meets the preset condition.
Wherein, the generating the page address of the video according to the video identifier of the video comprises: acquiring a construction rule corresponding to the target webpage; acquiring a plurality of construction elements indicated in the construction rule, wherein one of the construction elements is a video identifier of the video; and combining the plurality of construction elements according to the construction rules to obtain the page address of the video.
It should be noted that the construction rule corresponding to the target web page is a rule for constructing a page address of the video in the target web page.
In addition, the plurality of building elements indicated in the building rule are a plurality of pieces of information required for building the page address of the video in the target web page.
It is worth noting that when the virtual machine successfully acquires the construction rule corresponding to the target webpage, it indicates that the target webpage supports sharing of the page address of the video, and at this time, the page address of the video may be generated according to the construction rule. When the virtual machine does not obtain the construction rule corresponding to the target webpage, it is indicated that the target webpage does not support sharing of the page address of the video, and the operation can be ended at this time.
Further, the method further comprises: acquiring window parameters of the video, wherein the window parameters comprise window positions, window sizes and shielding information; and sending the window parameters to the terminal, and displaying a video window by the terminal according to the window parameters, wherein the video window is used for playing the video.
In the embodiment of the application, the virtual machine can acquire the window parameter of the video in a timing or real-time manner, and once the window parameter of the video is found to be changed, the changed window parameter is sent to the terminal, so that the terminal can rapidly adjust the video window for playing the video according to the changed window parameter.
Further, the method further comprises: receiving login information sent by the webpage server; and sending the login information to the terminal, wherein the login information is used for obtaining the access authority of the video.
The login information is used to acquire the access right of the video, and the login information is used to identify the user identity when the virtual machine accesses the web server, and is generally generated by the web server and transmitted to the virtual machine when the virtual machine first accesses the web server. In practical applications, in order to ensure the security of the login information, the login information may be encrypted first, and then the encrypted login information may be sent to the terminal.
In the embodiment of the application, the virtual machine can send the login information to the terminal, and the terminal can use the login information to acquire the video from the webpage server at the moment, so that the terminal can be ensured to have enough authority to access the webpage server to acquire the video, and the success rate of video redirection can be improved.
In a second aspect, a video playing method is provided, which is applied to a terminal, and the method includes:
sending an access instruction of a target webpage to a virtual machine installed in a virtual desktop server; receiving an iframe tag sent by the virtual machine, wherein the src attribute value of the iframe tag is a page address of a video existing in the target webpage, the page address is generated according to a video identifier of the video, and the video identifier of the video is obtained from webpage information of the target webpage; and acquiring and playing the video according to the iframe label.
In the embodiment of the application, the terminal sends the access instruction of the target webpage to the virtual machine installed in the virtual desktop server. And then the terminal receives the iframe label sent by the virtual machine, the src attribute value of the iframe label is the page address of the video existing in the target webpage, the page address is generated according to the video identifier of the video, and the video identifier of the video is obtained from the webpage information of the target webpage. And then, the terminal acquires the video according to the iframe label and plays the video. According to the embodiment of the application, the iframe tag is constructed according to the video identifier of the video, so that the terminal can successfully acquire the page where the video is played according to the src attribute value of the iframe tag, and the video can be successfully redirected.
Further, after sending the access instruction of the target webpage to the virtual machine installed in the virtual desktop server, the method further includes: receiving a video address of the video sent by the virtual machine, wherein the video address is obtained from webpage information of the target webpage; and acquiring and playing the video according to the video address.
In the embodiment of the application, the terminal can acquire and play the video according to the received iframe label and also can acquire and play the video according to the received video address, so that the flexibility of video acquisition is improved, and the success rate of video redirection is improved.
Further, after sending the access instruction of the target webpage to the virtual machine installed in the virtual desktop server, the method further includes: receiving window parameters of the video sent by the virtual machine, wherein the window parameters comprise window positions, window sizes and shielding information; and displaying the video window according to the window parameter. Correspondingly, the acquiring and playing the video comprises: and acquiring the video and playing the video in the video window.
When the terminal displays the video window according to the window parameter, the size of the video window can be set to the window size in the window parameter, the video window is displayed at the window position in the window parameter, the shielded part in the video window is determined according to shielding information in the window parameter, and the shielded part in the video window is set to be in a transparent state.
Further, after sending the access instruction of the target webpage to the virtual machine installed in the virtual desktop server, the method further includes: receiving login information sent by the virtual machine, wherein the login information is used for acquiring the access authority of the video; correspondingly, the acquiring and playing the video according to the iframe tag includes: generating a page acquisition request carrying the src attribute value of the iframe tag, where the page acquisition request is used to request to acquire a page pointed by the src attribute value of the iframe tag, and the page is played with the video; sending the page acquisition request and the login information to a webpage server; and when receiving the page information of the page sent by the web server, displaying the page according to the page information of the page.
In the embodiment of the application, when the terminal receives the login information sent by the virtual machine, the login information can be used for acquiring the video from the webpage server, so that the terminal can be ensured to have enough authority to access the webpage server to acquire the video, and the success rate of video redirection can be improved. Moreover, in order to ensure the security of the login information, the login information may be transmitted in an encrypted manner, and the terminal may delete the login information after the terminal acquires the video from the web server using the login information.
In a third aspect, a video playing apparatus is provided, where the video playing apparatus has a function of implementing the behavior of the video playing method in the first aspect. The video playing device comprises at least one module, and the at least one module is used for implementing the video playing method provided by the first aspect.
In a fourth aspect, a video playing apparatus is provided, where the video playing apparatus has a function of implementing the behavior of the video playing method in the second aspect. The video playing device comprises at least one module, and the at least one module is used for realizing the video playing method provided by the second aspect.
In a fifth aspect, a video playing apparatus is provided, where the structure of the video playing apparatus includes a processor and a memory, where the memory is used to store a program that supports the video playing apparatus to execute the video playing method provided in the first aspect, and store data used to implement the video playing method in the first aspect. The processor is configured to execute programs stored in the memory. The video playback device may further include a communication bus for establishing a connection between the processor and the memory.
In a sixth aspect, a video playing apparatus is provided, where the structure of the video playing apparatus includes a processor and a memory, where the memory is used to store a program that supports the video playing apparatus to execute the video playing method provided in the second aspect, and store data used to implement the video playing method in the second aspect. The processor is configured to execute programs stored in the memory. The video playback device may further include a communication bus for establishing a connection between the processor and the memory.
In a seventh aspect, a computer-readable storage medium is provided, which stores instructions that, when executed on a computer, cause the computer to execute the video playing method of the first aspect.
In an eighth aspect, a computer-readable storage medium is provided, which stores instructions that, when executed on a computer, cause the computer to execute the video playing method of the second aspect.
In a ninth aspect, there is provided a computer program product comprising instructions which, when run on a computer, cause the computer to perform the video playback method of the first aspect described above.
A tenth aspect provides a computer program product comprising instructions which, when run on a computer, cause the computer to perform the video playback method of the second aspect.
The technical effects obtained by the third, fifth, seventh and ninth aspects are similar to the technical effects obtained by the corresponding technical means in the first aspect, and are not described herein again.
The technical effects obtained by the fourth, sixth, eighth and tenth aspects are similar to the technical effects obtained by the corresponding technical means in the second aspect, and are not repeated here.
The technical scheme provided by the application can at least bring the following beneficial effects: and when the virtual machine installed in the virtual desktop server receives an access instruction of the target webpage sent by the terminal, sending a webpage request of the target webpage to the webpage server. And then, the virtual machine receives webpage information of a target webpage sent by a webpage server, when the target webpage has a video, a video identifier of the video is obtained from the webpage information of the target webpage, a page address of the video is generated according to the video identifier of the video, an iframe tag is constructed, and the page address of the video is set as an src attribute value of the iframe tag. And then, the virtual machine sends the iframe label to the terminal, and the terminal acquires the video according to the iframe label and plays the video. According to the embodiment of the application, the iframe tag is constructed according to the video identifier of the video, so that the terminal can successfully acquire the page where the video is played according to the src attribute value of the iframe tag, and the video can be successfully redirected.
Detailed Description
To make the objects, technical solutions and advantages of the present application more clear, embodiments of the present application will be described in further detail below with reference to the accompanying drawings.
Before explaining the embodiments of the present application in detail, application scenarios and system architectures related to the embodiments of the present application will be described.
First, an application scenario of the embodiment of the present application will be described.
The virtual desktop is a typical cloud computing application, can provide a remote computer desktop service deployed at a cloud end for a user, and specifically, a virtualization technology is used for virtualizing a server into a plurality of virtual machines, an operating system and application software required by the user are run in each virtual machine, and the user can log in the virtual machine at a terminal and access virtual machine resources. Since all services in the virtual desktop are processed in the virtual machine, the virtual desktop consumes resources of the server all the time, and especially, the resource consumption of the server by video playing in the virtual desktop is quite large, which may possibly affect the performance of the server, so redirecting the video has an important meaning for improving the experience of the virtual desktop. The embodiment of the application is applied to a video redirection scene under a virtual desktop.
Next, a system architecture according to an embodiment of the present application will be described.
Fig. 1 is a schematic structural diagram of a virtual desktop system according to an embodiment of the present application. Referring to fig. 1, the virtual desktop system includes: virtual desktop server 110 and terminal 120. The virtual Desktop server 110 and the terminal 120 may communicate via a Desktop Protocol, where the Desktop Protocol may be a Remote Desktop Protocol (RDP), and the like, which is not limited in this embodiment of the present application.
The virtual desktop server 110 may provide a software execution environment and a virtual machine control platform of a virtual machine for providing a virtual desktop environment, and a virtual desktop service may be installed in the virtual machine to process message interaction between a client and an operating system of the virtual machine and receive messages of the operating system to render a desktop. The virtual desktop server 110 may be a server, or may be a server cluster formed by a plurality of servers, which is not limited in this embodiment of the present application.
Terminal 120 may access the virtual desktop environment provided by the virtual machine in virtual desktop server 110, and a client may be installed in terminal 120 to receive and process desktop protocol messages. The terminal 120 may be a Personal Computer (PC), a Thin Client (TC), an Android system device, an ios system device, and the like, which is not limited in this embodiment of the present application.
The virtual desktop server 110 has a virtual machine 111 installed therein, and the virtual machine 111 may have a browser and a browser plug-in installed therein. Specifically, the browser plug-in may first determine whether a video exists in the web page, obtain a video identifier of the video from the web page information of the web page if the video exists in the web page, generate a page address of the video according to the video identifier of the video, and send the page address to the terminal 120.
Among them, the terminal 120 has a client 121 and a browser engine 122 installed therein. When receiving the page address sent by the virtual machine 111 installed in the virtual desktop server 110, the client 121 may invoke the browser engine 122 to obtain the video, specifically, the browser engine 122 may obtain and display a page according to the page address, where the video is played after the page is displayed. In addition, the terminal 120 may include an output device (e.g., a display) for displaying desktop content and an input device (e.g., a mouse, a keyboard, etc.) for user input.
Fig. 2 is a schematic structural diagram of a computer device provided in an embodiment of the present application, where the computer device may be the virtual desktop server 110 or the terminal 120 shown in fig. 1. Referring to fig. 2, the computer device comprises at least one processor 201, a communication bus 202, a memory 203 and at least one communication interface 204.
The processor 201 may be a Central Processing Unit (CPU), a microprocessor, an application-specific integrated circuit (ASIC), or may be one or more integrated circuits for controlling the execution of programs according to the present disclosure.
The communication bus 202 may include a path for communicating information between the aforementioned components.
The Memory 203 may be a Read-Only Memory (ROM) or other type of static storage device that can store static information and instructions, a Random Access Memory (RAM) or other type of dynamic storage device that can store information and instructions, an Electrically Erasable Programmable Read-Only Memory (EEPROM), a compact disc Read-Only Memory (CD-ROM) or other optical disc storage, optical disc storage (including compact disc, laser disc, optical disc, digital versatile disc, blu-ray disc, etc.), magnetic disk storage media or other magnetic storage devices, or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and that can be accessed by a computer, but is not limited to these. The memory 203 may be self-contained and coupled to the processor 201 via the communication bus 202. The memory 203 may also be integrated with the processor 201.
The communication interface 204 may be any device, such as a transceiver, for communicating with other devices or communication networks, such as ethernet, Radio Access Network (RAN), Wireless Local Area Networks (WLAN), etc.
In particular implementations, processor 201 may include one or more CPUs, such as CPU0 and CPU1 shown in fig. 2, as one embodiment.
In particular implementations, a computer device may include multiple processors, such as processor 201 and processor 205 shown in fig. 2, as an embodiment. Each of these processors may be a single-Core Processor (CPU) or a multi-Core Processor (CPU). A processor herein may refer to one or more devices, circuits, and/or processing cores for processing data (e.g., computer program instructions).
In particular implementations, the computer device may also include an output device 206 and an input device 207, as one embodiment. The output device 206 is in communication with the processor 201 and may display information in a variety of ways. For example, the output device 206 may be a Liquid Crystal Display (LCD), a Light Emitting Diode (LED) display device, a Cathode Ray Tube (CRT) display device, a projector (projector), or the like. The input device 207 is in communication with the processor 201 and may receive user input in a variety of ways. For example, the input device 207 may be a mouse, a keyboard, a touch screen device, or a sensing device, among others.
The computer device may be a general purpose computer device or a special purpose computer device. In a specific implementation, the computer device may be a desktop computer, a laptop computer, a web server, a Personal Digital Assistant (PDA), a mobile phone, a tablet computer, a wireless terminal device, a communication device, or an embedded device, and the embodiment of the present application does not limit the type of the computer device.
The memory 203 is used for storing a program code 210 for executing the scheme of the application, and the processor 201 is used for executing the program code 210 stored in the memory 203. The computer device may implement the video playing method provided in the embodiment of fig. 3 below by the processor 201 and the program code 210 in the memory 203.
It should be noted that before executing the video playing method provided by the embodiment of the present application, the terminal may first connect to a virtual machine in the virtual desktop server using a desktop protocol, at this time, the virtual machine may provide a virtual desktop environment for the terminal, and then, a browser and a browser plug-in may be installed in the virtual machine to implement a video redirection technology. Also, the terminal may notify the virtual machine of device information of the terminal, which may include a terminal type (which may be divided by an operating system), whether video redirection is supported, and the like. When the terminal supports video redirection, the video redirection under the virtual desktop can be realized through the video playing method provided by the embodiment of the application.
Fig. 3 is a flowchart of a video playing method according to an embodiment of the present application, where the method is applied to the virtual desktop system shown in fig. 1. Referring to fig. 3, the method includes:
step 301: and the terminal sends an access instruction of the target webpage to a virtual machine installed in the virtual desktop server.
It should be noted that step 301 may be performed by a client installed in the terminal.
In addition, the target web page may be an HTML web page, such as an HTML5 web page, which is not limited in this embodiment of the present application.
Furthermore, the access instruction of the target webpage is used for indicating to access the target webpage, the access instruction of the target webpage can be triggered by a user, and the user can be triggered by mouse operation, keyboard operation and other operations.
Step 302: and when the virtual machine receives an access instruction of the target webpage sent by the terminal, sending a webpage request of the target webpage to the webpage server.
It should be noted that step 302 may be performed by a browser installed in the virtual machine.
In addition, the web page request of the target web page is used to request to acquire the target web page, and the web page request of the target web page may carry a web page address of the target web page, such as a Uniform Resource Locator (URL) of the target web page.
Moreover, after receiving the web page request of the target web page, the web page server can acquire the web page information of the target web page and return the web page information of the target web page to the virtual machine.
Step 303: the virtual machine receives webpage information of a target webpage sent by a webpage server.
It should be noted that step 303 may be performed by a browser installed in the virtual machine.
In addition, the webpage information of the target webpage includes related information of all contents in the target webpage, such as related information of contents, such as characters, pictures, music, and the like, in the target webpage.
It is to be noted that after the browser installed in the virtual machine acquires the web page information of the target web page, the browser may call the browser plug-in installed in the virtual machine to perform video redirection, which may be specifically implemented as the following steps 304 to 308.
Step 304: the virtual machine judges whether a video exists in the target webpage.
It should be noted that step 304 may be performed by a browser plug-in installed in the virtual machine.
Specifically, the virtual machine may determine whether a video tag exists in the web page information of the target web page; when the video tag exists in the webpage information of the target webpage, determining that the video exists in the target webpage; and when the video tag does not exist in the webpage information of the target webpage, determining that the video does not exist in the target webpage. Of course, whether the video exists in the target webpage may also be determined in other manners, which is not limited in the embodiment of the present application.
It should be noted that the video tag is used to define a video, such as a movie clip or other video stream. The video tag has a plurality of attributes, wherein the src attribute value of the video tag is a video address of the video to be played, such as a URL of the video to be played.
Step 305: when the video exists in the target webpage, the virtual machine acquires the video identification of the video from the webpage information of the target webpage.
It should be noted that step 305 may be performed by a browser plug-in installed in the virtual machine.
In addition, the video identifier of the video is used for uniquely identifying the video, and the video identifier of the video may be obtained from a web page address of a target web page or a web page code of the target web page, which is not limited in this application.
Specifically, when a video exists in a target webpage, the virtual machine can directly acquire a video identifier of the video from webpage information of the target webpage; or, when the video exists in the target webpage, the virtual machine may first obtain the video address of the video from the webpage information of the target webpage, then judge whether the video address meets the preset condition, and when the video address does not meet the preset condition, obtain the video identifier of the video from the webpage information of the target webpage.
Further, when the video address meets a preset condition, the virtual machine may send the video address to the terminal.
It should be noted that the video address of the video may indicate the location of the video, i.e., the video may be obtained according to the video address of the video.
In addition, the preset condition may be preset, and the preset condition is a condition for determining whether the video address acquired from the web page information is a real address, that is, a condition for determining whether the video address acquired from the web page information can successfully acquire the video.
And when the video address does not meet the preset condition, the video address is not a real address, and the video identifier of the video can be acquired at the moment so as to generate the page address of the video. And when the video address meets the preset condition, the video address is indicated to be a real address, and at the moment, the video address can be sent to the terminal so that the terminal can directly acquire and play the video according to the video address.
When a video exists in the target webpage, the operation of the virtual machine acquiring the video address of the video from the webpage information of the target webpage may be: when a video tag exists in the webpage information of the target webpage, the src attribute value of the video tag is acquired as the video address of the video.
The operation of the virtual machine for determining whether the video address meets the preset condition may be: the virtual machine judges whether the video address comprises a preset character string or not; when the video address does not comprise a preset character string, determining that the video address does not meet a preset condition; and when the video address comprises a preset character string, determining that the video address meets a preset condition.
It should be noted that the preset character string may be preset, for example, the preset character string may be a video type, and the video type may include an audio video interleaved (avi) type, a Motion Picture Experts Group (MPEG) 4 type, and the like.
In addition, when determining whether the video address includes the preset character string, it may be specifically determined whether a suffix of the video address is the preset character string, when the suffix of the video address is not the preset character string, it is determined that the video address does not satisfy the preset condition, and when the suffix of the video address is the preset character string, it is determined that the video address satisfies the preset condition.
Step 306: and the virtual machine generates a page address of the video according to the video identifier of the video.
It should be noted that step 306 may be performed by a browser plug-in installed in the virtual machine.
In addition, the page address of the video may indicate the position of the page where the video is located, that is, the page where the video is located may be obtained according to the page address of the video, and the video is played in the page. In addition, the page may further include a player in the target web page for playing the video, where the video is played in a frame of the player included in the page.
Specifically, the virtual machine may obtain a construction rule corresponding to the target webpage; acquiring a plurality of construction elements indicated in the construction rule, wherein one of the construction elements is a video identifier of the video; and combining the plurality of construction elements according to the construction rule to obtain the page address of the video. Of course, the page address of the video may also be generated in other ways according to the video identifier of the video, which is not limited in this embodiment of the application.
It should be noted that the construction rule corresponding to the target web page is a rule for constructing a page address of the video in the target web page. For example, the construction rule corresponding to the target web page may be "domain name/embedded/video identifier of the located website", and the like.
In addition, the plurality of building elements indicated in the building rule are a plurality of pieces of information required for building the page address of the video in the target web page. For example, when the construction rule is "domain name/embed/video identifier of the located website", the plurality of construction elements indicated by the construction rule are the domain name, embed and video identifier of the website where the target webpage is located.
When the virtual machine acquires the construction rule corresponding to the target webpage, the corresponding construction rule can be acquired from the corresponding relation between the stored website identification and the construction rule according to the website identification of the website where the target webpage is located, and the corresponding construction rule is used as the construction rule corresponding to the target webpage. Of course, the construction rule corresponding to the target webpage may also be obtained in other manners, which is not limited in the embodiment of the present application.
It should be noted that the website identifier of the website is used to uniquely identify the website, for example, the website identifier of the website may be a name, a domain name, and the like of the website, which is not limited in this embodiment of the application.
In addition, when the construction rule corresponding to the target webpage is successfully acquired, it is indicated that the target webpage supports sharing of the page address of the video, and the page address of the video can be generated according to the construction rule. When the construction rule corresponding to the target webpage is not acquired, it is indicated that the target webpage does not support sharing of the page address of the video, and the operation may be ended at this time.
Step 307: the virtual mechanism establishes an iframe tag, and sets the page address of the video as the src attribute value of the iframe tag.
It should be noted that step 307 may be performed by a browser plug-in installed in the virtual machine.
In addition, the iframe tag is used to create an inline frame that contains another document. The iframe tag has a plurality of attributes, wherein the src attribute value of the iframe tag is the document address of the document to be displayed, such as the URL of the document to be displayed.
Step 308: and the virtual machine sends the iframe label to the terminal.
It should be noted that step 308 can be performed by a browser plug-in installed in the virtual machine.
It is worth noting that, in the embodiment of the application, the virtual machine not only can construct an iframe tag and send the iframe tag to the terminal, but also can obtain window parameters of the video and send the window parameters of the video to the terminal. And the virtual machine can also receive login information sent by the webpage server and send the login information to the terminal.
It should be noted that the operation of the virtual machine acquiring the window parameter of the video and sending the window parameter to the terminal may be performed by a browser plug-in installed in the virtual machine. The operation of the virtual machine receiving the login information transmitted from the web server and transmitting to the terminal may be performed by a browser installed in the virtual machine.
In addition, the window parameter is a related parameter of a video window for playing the video, and the window parameter is used for positioning the video window, for example, the window parameter may include a window position, a window size, occlusion information, and the like. In practical application, the virtual machine may obtain the window parameter of the video in a timed or real-time manner, and once the window parameter of the video is found to be changed, the changed window parameter is sent to the terminal.
The login information is used to acquire the access right of the video, and the login information is used by the virtual machine to identify the user identity when accessing the web server, and is generally generated by the web server and transmitted to the virtual machine when the virtual machine first accesses the web server. The login information may be small text files (cookies) or the like. In practical applications, in order to ensure the security of the login information, the login information may be encrypted first, and then the encrypted login information may be sent to the terminal.
It should be noted that, in the embodiment of the present invention, when receiving the web page information of the target web page sent by the web page server, the virtual machine may not acquire the video in the target web page, and only acquire and display the web page contents of the target web page other than the video according to the web page information of the target web page.
Step 309: and the terminal receives the iframe label sent by the virtual machine.
It should be noted that step 309 may be performed by a client installed in the terminal.
In addition, the src attribute value of the iframe tag is the page address of the video existing in the target webpage, the page address of the video is generated according to the video identifier of the video, and the video identifier of the video is obtained from the webpage information of the target webpage.
Step 310: and the terminal acquires and plays the video in the target webpage according to the iframe label.
It should be noted that step 310 may be performed by a browser engine installed in the terminal.
Specifically, the terminal may generate a page acquisition request carrying the src attribute value of the iframe tag, where the page acquisition request is used to request to acquire a page to which the src attribute value of the iframe tag points, and a video in a target webpage is played in the page; sending the page acquisition request to a web server; and when receiving the page information of the page sent by the web server, displaying the page according to the page information of the page.
It should be noted that after the page is displayed, the video in the target web page is played in the page. Since the page may further include a player in the target webpage for playing the video, and the video is played in a frame of the player included in the page, the terminal may directly control the playing of the video through the player in the page, in this case, the playing effect of the video after the video is redirected is the same as the playing effect of the original video.
Further, the terminal may receive the iframe tag sent by the virtual machine, and may also receive a video address of a video in the target webpage sent by the virtual machine, where the video address of the video is obtained from the webpage information of the target webpage. When the terminal receives the video address of the video in the target webpage sent by the virtual machine, the video can be obtained and played according to the video address of the video.
It should be noted that the operation of the terminal receiving the video address of the video in the target webpage sent by the virtual machine may be executed by a client installed in the terminal, and the operation of the terminal acquiring the video according to the video address of the video and playing the video may be executed by a browser engine installed in the terminal.
In addition, when the video address of the video is the src attribute value of the video tag of the target web page, when the terminal receives the video address of the video in the target web page sent by the virtual machine, an HTML web page may be created first, the src attribute value of the video tag of the HTML web page is set as the video address of the video, and then the web page content of the HTML web page may be loaded, where the loading of the web page content of the HTML web page is to obtain the video according to the video address of the video and play the video.
When the terminal acquires the video and plays the video according to the video address of the video, a video acquisition request carrying the video address of the video can be generated; sending the video acquisition request to a webpage server; and when the video data of the video sent by the webpage server is received, playing the video according to the video data of the video.
It should be noted that the terminal may also receive window parameters of the video sent by the virtual machine, where the window parameters may include window position, window size, occlusion information, and the like. When the terminal receives the window parameter of the video sent by the virtual machine, the video window can be displayed according to the window parameter. Then, when the terminal acquires and plays the video, the terminal may acquire the video first and then play the video in the video window.
When the terminal displays the video window according to the window parameter, the size of the video window can be set to the window size in the window parameter, the video window is displayed at the window position in the window parameter, the shielded part in the video window is determined according to shielding information in the window parameter, and the shielded part in the video window is set to be in a transparent state.
When the terminal plays the video in the video window, if the terminal displays the page according to the page information of the page pointed by the src attribute value of the iframe tag, the page can be displayed in the video window, and if the terminal plays the video according to the video data of the video, the video can be played in the video window.
It should be noted that the terminal may also receive login information sent by the virtual machine, where the login information is used to obtain access rights of the video. When the terminal receives the login information sent by the virtual machine, the login information can be used for acquiring the video from the webpage server. Specifically, the terminal may send the login information to the web server while sending the page acquisition request or the video acquisition request to the web server, so as to ensure that the terminal has sufficient authority to access the web server to acquire the video.
In addition, in order to ensure the security of the login information, the login information may be transmitted in an encrypted manner, and the terminal may delete the login information after the terminal acquires the video from the web server using the login information.
It is worth noting that in the embodiment of the application, effective information can be mined from the webpage information of the target webpage as much as possible, so that video redirection is realized. After the video is redirected, the pressure of the virtual desktop server can be reduced, the resource occupation is reduced, the influence of video playing on the performance of the virtual desktop server is avoided, and the transmission bandwidth from the virtual machine to the terminal can be greatly reduced because the terminal directly obtains the video from the webpage server. In addition, compared with a mode that the virtual machine compresses the video first and then transmits the video to the terminal in the related art, the embodiment of the application can avoid the influence of the compression on the video quality and ensure the playing effect of the video.
Further, considering that the capability of the terminal is limited, in order to avoid excessive stress on the terminal caused by video playing, the number of redirected videos may be limited in the embodiment of the present application. Specifically, the virtual machine may be notified that the terminal supports video redirection when the number of redirected videos is less than a number threshold, and may be notified that the terminal does not support video redirection when the number of redirected videos is greater than or equal to the number threshold. Wherein the number threshold may be set in advance.
Furthermore, in order to enhance the universality and prevent the video redirection failure caused by the fact that the terminal cannot be connected with an external network, a proxy server can be added, and the terminal can acquire the video from the webpage server through the proxy server.
In the embodiment of the application, the terminal sends the access instruction of the target webpage to the virtual machine installed in the virtual desktop server, and when the virtual machine receives the access instruction of the target webpage sent by the terminal, the virtual machine sends the webpage request of the target webpage to the webpage server. And then, the virtual machine receives webpage information of a target webpage sent by a webpage server, when the target webpage has a video, a video identifier of the video is obtained from the webpage information of the target webpage, a page address of the video is generated according to the video identifier of the video, an iframe tag is constructed, and the page address of the video is set as an src attribute value of the iframe tag. And then, the virtual machine sends the iframe label to the terminal. And when the terminal receives the iframe label sent by the virtual machine, acquiring the video according to the iframe label and playing the video. According to the embodiment of the application, the iframe tag is constructed according to the video identifier of the video, so that the terminal can successfully acquire the page where the video is played according to the src attribute value of the iframe tag, and the video can be successfully redirected.
Fig. 4 is a schematic structural diagram of a video playing apparatus provided in an embodiment of the present application, where the apparatus is applied to a virtual machine installed in a virtual desktop server, and the apparatus may be implemented by software, hardware, or a combination of the two to become part or all of a computer device, and when the computer device shown in fig. 2 is a virtual desktop server, the computer device may be the computer device shown in fig. 2. Referring to fig. 4, the apparatus includes: a first sending module 401, a first receiving module 402, a first obtaining module 403, a generating module 404, a constructing module 405, and a second sending module 406.
A first sending module 401, configured to perform step 302 in the embodiment of fig. 3;
a first receiving module 402, configured to perform step 303 in the embodiment of fig. 3;
a first obtaining module 403, configured to perform step 305 in the embodiment of fig. 3;
a generating module 404, configured to perform step 306 in the embodiment of fig. 3;
a building module 405 for performing step 307 in the embodiment of fig. 3;
a second sending module 406, configured to execute step 308 in the embodiment of fig. 3.
Optionally, the first obtaining module 403 includes:
the first acquisition unit is used for acquiring a video address of a video from the webpage information when the video exists in the target webpage;
and the second acquisition unit is used for acquiring the video identification of the video from the webpage information when the video address does not meet the preset condition.
Optionally, the first obtaining module 403 further includes:
the first determining unit is used for determining that the video exists in the target webpage when the video tag exists in the webpage information;
accordingly, the first obtaining unit is configured to:
and when the video tag exists in the webpage information, acquiring the src attribute value of the video tag as the video address of the video.
Optionally, the first obtaining module 403 further includes:
and the second determining unit is used for determining that the video address does not meet the preset condition when the preset character string is not included in the video address.
Optionally, the first obtaining module 403 further includes:
and the third sending module is used for sending the video address to the terminal when the video address meets the preset condition, and the terminal acquires and plays the video according to the video address.
Optionally, the generating module 404 includes:
the third acquisition unit is used for acquiring a construction rule corresponding to the target webpage;
a fourth obtaining unit, configured to obtain multiple construction elements indicated in the construction rule, where one of the multiple construction elements is a video identifier of the video;
and the combination unit is used for combining the plurality of construction elements according to the construction rules to obtain the page address of the video.
Optionally, the apparatus further comprises:
the second acquisition module is used for acquiring window parameters of the video, wherein the window parameters comprise window positions, window sizes and shielding information;
and the fourth sending module is used for sending the window parameters to the terminal, the terminal displays the video window according to the window parameters, and the video window is used for playing the video.
Optionally, the apparatus further comprises:
the second receiving module is used for receiving login information sent by the webpage server;
and the fifth sending module is used for sending the login information to the terminal, wherein the login information is used for obtaining the access authority of the video.
In the embodiment of the application, when the virtual machine installed in the virtual desktop server receives the access instruction of the target webpage sent by the terminal, the webpage request of the target webpage is sent to the webpage server. And then, the virtual machine receives webpage information of a target webpage sent by a webpage server, when the target webpage has a video, a video identifier of the video is obtained from the webpage information of the target webpage, a page address of the video is generated according to the video identifier of the video, an iframe tag is constructed, and the page address of the video is set as an src attribute value of the iframe tag. And then, the virtual machine sends the iframe label to the terminal, and the terminal acquires the video according to the iframe label and plays the video. According to the embodiment of the application, the iframe tag is constructed according to the video identifier of the video, so that the terminal can successfully acquire the page where the video is played according to the src attribute value of the iframe tag, and the video can be successfully redirected.
Fig. 5 is a schematic structural diagram of a video playing apparatus provided in an embodiment of the present application, where the apparatus is applied to a terminal, and the apparatus may be implemented by software, hardware, or a combination of the two as part or all of a computer device, and when the computer device shown in fig. 2 is a terminal, the computer device may be the computer device shown in fig. 2. Referring to fig. 5, the apparatus includes: a sending module 501, a first receiving module 502 and a first playing module 503.
A sending module 501, configured to execute step 301 in the embodiment of fig. 3;
a first receiving module 502, configured to perform step 309 in the embodiment of fig. 3;
a first playing module 503, configured to execute step 310 in the embodiment of fig. 3.
Optionally, the apparatus further comprises:
the second receiving module is used for receiving a video address of the video sent by the virtual machine, wherein the video address is obtained from webpage information of a target webpage;
and the second playing module is used for acquiring and playing the video according to the video address.
Optionally, the apparatus further comprises:
the third receiving module is used for receiving window parameters of the video sent by the virtual machine, wherein the window parameters comprise window positions, window sizes and shielding information;
the display module is used for displaying the video window according to the window parameter;
accordingly, the first playing module is configured to:
and acquiring a video and playing the video in a video window.
Optionally, the apparatus further comprises:
the fourth receiving module is used for receiving login information sent by the virtual machine, wherein the login information is used for obtaining the access authority of the video;
accordingly, the first playing module 503 includes:
the generating unit is used for generating a page acquisition request carrying the src attribute value of the iframe tag, wherein the page acquisition request is used for requesting to acquire a page pointed by the src attribute value of the iframe tag, and a video is played in the page;
the sending unit is used for sending a page acquisition request and login information to the webpage server;
and the display unit is used for displaying the page according to the page information of the page when receiving the page information of the page sent by the web server.
In the embodiment of the application, the terminal sends the access instruction of the target webpage to the virtual machine installed in the virtual desktop server. And then the terminal receives the iframe label sent by the virtual machine, the src attribute value of the iframe label is the page address of the video existing in the target webpage, the page address is generated according to the video identifier of the video, and the video identifier of the video is obtained from the webpage information of the target webpage. And then, the terminal acquires the video according to the iframe label and plays the video. According to the embodiment of the application, the iframe tag is constructed according to the video identifier of the video, so that the terminal can successfully acquire the page where the video is played according to the src attribute value of the iframe tag, and the video can be successfully redirected.
It should be noted that: in the video playing apparatus provided in the foregoing embodiment, only the division of the functional modules is exemplified when playing a video, and in practical applications, the functions may be distributed by different functional modules according to needs, that is, the internal structure of the apparatus is divided into different functional modules to complete all or part of the functions described above. In addition, the video playing apparatus and the video playing method provided by the above embodiments belong to the same concept, and specific implementation processes thereof are detailed in the method embodiments and are not described herein again.
In the above embodiments, the implementation may be wholly or partly realized by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When loaded and executed on a computer, cause the processes or functions described in accordance with the embodiments of the application to occur, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a network of computers, or other programmable device. The computer instructions may be stored on a computer readable storage medium or transmitted from one computer readable storage medium to another, for example, from one website, computer, server, or data center to another website, computer, server, or data center via wire (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device, such as a server, a data center, etc., that includes one or more of the available media. The usable medium may be a magnetic medium (e.g., floppy Disk, hard Disk, magnetic tape), an optical medium (e.g., Digital Versatile Disk (DVD)), or a semiconductor medium (e.g., Solid State Disk (SSD)), among others.
The above-mentioned embodiments are provided not to limit the present application, and any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the protection scope of the present application.