Video playing method and device, electronic equipment and readable storage medium

By creating and managing the view layer in the terminal and converting the video stream data to adapt to the format supported by the operating system, the problem that the operating system only supports floating window playback of videos in specific formats is solved, and floating window playback of videos in multiple formats is realized.

CN118741206AActive Publication Date: 2024-10-01HANGZHOU EZVIZ SOFTWARE CO LTD

Patent Information

Application Number
CN202410842781.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-26
Publication Date
2024-10-01
Estimated Expiration
2044-06-26

Smart Images

  • Figure CN118741206A_ABST
    Figure CN118741206A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a video playing method and device, electronic equipment and a readable storage medium, and relates to the technical field of computers, the method is applied to a terminal, and the method comprises the following steps: in a process of playing a target video in a non-floating window mode, creating a first view, and taking a preset video file as an input parameter, adding a player layer provided by an operating system in the first view; creating a second view, and adding a video rendering layer provided by the operating system in the second view; opening a picture-in-picture component by taking the player layer as an input parameter so as to display a floating window in the terminal; adding the second view into the floating window; obtaining current video stream data of the target video, and converting the current video stream data into a format supported by a video rendering layer; and rendering the converted video stream data by using a video rendering layer in the second view so as to play the target video in the floating window. According to the scheme, the video of which the player layer does not support the format can be played in a floating window mode.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a video playback method, device, electronic device, and readable storage medium. Background Art

[0002] At present, in order to play a video in a floating window in a terminal, the player layer provided by the operating system of the terminal can be used to open the picture-in-picture component to generate a floating window, and then play the video in the floating window. For example, in the iOS (a mobile operating system) system, the player layer is AVPlayerLayer, and the picture-in-picture component is AVPictureInPictureController.

[0003] However, the player layer provided by the terminal operating system often only supports rendering of videos in specific formats, which means that the terminal operating system only supports displaying videos in specific formats in the form of floating windows, but does not support displaying videos in other formats in the form of floating windows.

[0004] Therefore, how to play videos whose formats are not supported by the player layer in a floating window is an urgent problem to be solved. Summary of the invention

[0005] The purpose of the embodiments of the present application is to provide a video playback method, device, electronic device and readable storage medium to play videos in a format not supported by the player layer in a floating window. The specific technical solution is as follows:

[0006] In one aspect of an embodiment of the present application, a video playback method is provided, which is applied to a terminal, and the method includes:

[0007] In the process of playing the target video in a non-floating window mode, when an instruction for instructing to play the target video in a floating window mode is received, the target video is stopped from being played in the non-floating window mode, and a first view is created, a preset video file is used as an input parameter, and a player layer provided by the operating system of the terminal is added to the first view; and a second view is created, and a video rendering layer provided by the operating system is added to the second view; wherein the preset video file is in a format supported by the player layer;

[0008] Using the player layer as an input parameter, opening a picture-in-picture component provided by the operating system to display a floating window in a display interface of the terminal;

[0009] When a display event of the floating window is monitored, adding the second view to the floating window;

[0010] Acquire current video stream data of the target video, and if the acquired video stream data is in a format not supported by the video rendering layer, convert the acquired video stream data into a format supported by the video rendering layer;

[0011] The converted video stream data is rendered using the video rendering layer in the second view to play the target video in the floating window.

[0012] Optionally, the creating the second view includes:

[0013] Acquire attribute information of a preset view; wherein the attribute information represents: attributes of a control for controlling video playback contained in the view to be generated;

[0014] A view including the control represented by the attribute information is created as the second view.

[0015] Optionally, obtaining current video stream data of the target video includes:

[0016] According to the screen refresh rate of the terminal, the current video stream data is obtained from the video stream data of the target video cached in the local cache space; wherein the video stream data stored in the local cache space is obtained and cached by the terminal from the video server.

[0017] Optionally, obtaining the current video stream data from the video stream data of the target video cached in the local cache space according to the screen refresh rate of the terminal includes:

[0018] A timer whose timing period is synchronized with the screen refresh rate of the terminal is called to obtain current video stream data from the video stream data of the target video cached in the local cache space according to the timing period of the timer.

[0019] Optionally, the method further comprises:

[0020] When a closing instruction of the floating window is received, the display of the floating window is stopped, and the second view is removed from the floating window.

[0021] Optionally, the preset video file is a locally stored silent video file.

[0022] In another aspect of the embodiment of the present application, a video playback device is provided, which is applied to a terminal running an iOS system, and the device includes:

[0023] A view creation module, used for, during the process of playing a target video in a non-floating window mode, when receiving an instruction for instructing to play the target video in a floating window mode, stopping playing the target video in the non-floating window mode, creating a first view, taking a preset video file as an input parameter, adding a player layer provided by the operating system of the terminal to the first view; and creating a second view, adding a video rendering layer provided by the operating system to the second view; wherein the preset video file is in a format supported by the player layer;

[0024] A component opening module, used to use the player layer as an input parameter to open the picture-in-picture component provided by the operating system to display a floating window in the display interface of the terminal;

[0025] A view adding module, configured to add the second view to the floating window when a display event of the floating window is monitored;

[0026] A video stream acquisition module, used for acquiring the current video stream data of the target video, and converting the acquired video stream data into a format supported by the video rendering layer when the acquired video stream data is in a format not supported by the video rendering layer;

[0027] A rendering module is used to render the converted video stream data using the video rendering layer in the second view to play the target video in the floating window.

[0028] In another aspect of the embodiment of the present application, an electronic device is provided, including:

[0029] Memory, used to store computer programs;

[0030] The processor is used to implement any of the above-mentioned video playing methods when executing the program stored in the memory.

[0031] In another aspect of the embodiments of the present application, a computer-readable storage medium is provided, wherein a computer program is stored in the computer-readable storage medium, and when the computer program is executed by a processor, any of the above-mentioned video playback methods is implemented.

[0032] An embodiment of the present application also provides a computer program product comprising instructions, which, when executed on a computer, enables the computer to execute any of the above-described video playback methods.

[0033] Beneficial effects of the embodiments of the present application:

[0034] A video playback method provided in an embodiment of the present application is applied to a terminal, and the method includes:

[0035] In the process of playing the target video in a non-floating window manner, when an instruction is received to instruct to play the target video in a floating window manner, stop playing the target video in a non-floating window manner, and create a first view, take a preset video file as an input parameter, and add a player layer provided by the terminal's operating system in the first view; and create a second view, and add a video rendering layer provided by the operating system in the second view; wherein the preset video file is in a format supported by the player layer; take the player layer as an input parameter, and enable a picture-in-picture component provided by the operating system to display a floating window in the display interface of the terminal; when a display event of the floating window is monitored, add the second view to the floating window; obtain the current video stream data of the target video, and when the obtained video stream data is in a format not supported by the video rendering layer, convert the obtained video stream data into a format supported by the video rendering layer; use the video rendering layer in the second view to render the converted video stream data to play the target video in the floating window.

[0036] In this solution, by using the first view, a preset video file in a format supported by the player layer provided by the operating system is used as an input parameter of the player layer, so that the picture-in-picture component provided by the operating system can be opened normally to generate a floating window. On this basis, the second view with the video rendering layer provided by the operating system is added to the floating window, and when the video stream data is in a format not supported by the video rendering layer, the obtained video stream data is converted into a format supported by the video rendering layer, so that the video rendering layer in the second view can render the converted video stream data, so that when the target video is in a format not supported by the player layer, the target video can also be played in the form of a floating window. Therefore, through this solution, it is possible to play videos in formats not supported by the player layer in the form of a floating window.

[0037] Of course, implementing any product or method of the present application does not necessarily require achieving all of the advantages described above at the same time. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application, and for ordinary technicians in this field, other embodiments can also be obtained based on these drawings.

[0039] Figure 1 A schematic diagram of a flow chart of a video playback method provided in an embodiment of the present application;

[0040] Figure 2 Another flowchart of the video playback method provided in the embodiment of the present application;

[0041] Figure 3 A schematic diagram of a display interface of a terminal in a video playback method provided in an embodiment of the present application;

[0042] Figure 4 A schematic diagram of a floating window in a video playback method provided in an embodiment of the present application;

[0043] Figure 5 A schematic diagram of another flow chart of the video playback method provided in the embodiment of the present application;

[0044] Figure 6 A schematic diagram of information interaction in the video playback method provided in an embodiment of the present application;

[0045] Figure 7 A schematic diagram of the structure of a video playback device provided in an embodiment of the present application;

[0046] Figure 8 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0047] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field based on the present application belong to the scope of protection of the present application.

[0048] In order to play videos in a format not supported by the player layer in a floating window, the embodiment of the present application provides a video playback method, device, electronic device and readable storage medium. The video playback method can be applied to a terminal. Specifically, each step of the video playback method can be executed by a program (hereinafter referred to as an execution program) pre-developed and installed in the terminal. The method may include the following steps:

[0049] In the process of playing the target video in a non-floating window mode, when receiving an instruction for instructing to play the target video in a floating window mode, stop playing the target video in a non-floating window mode, create a first view, take a preset video file as an input parameter, add a player layer provided by the operating system of the terminal in the first view; and create a second view, add a video rendering layer provided by the operating system in the second view; wherein the preset video file is in a format supported by the player layer;

[0050] The player layer is used as an input parameter to enable the picture-in-picture component provided by the operating system to display a floating window in the terminal's display interface;

[0051] When a display event of the floating window is monitored, the second view is added to the floating window;

[0052] Acquire current video stream data of the target video, and if the acquired video stream data is in a format not supported by the video rendering layer, convert the acquired video stream data into a format supported by the video rendering layer;

[0053] The converted video stream data is rendered using the video rendering layer in the second view to play the target video in the floating window.

[0054] In this embodiment, by using the first view, a preset video file in a format supported by the player layer provided by the operating system is used as an input parameter of the player layer, so that the picture-in-picture component provided by the operating system can be opened normally to generate a floating window. On this basis, the second view with the video rendering layer provided by the operating system is added to the floating window, and when the video stream data is in a format not supported by the video rendering layer, the obtained video stream data is converted into a format supported by the video rendering layer, so that the video rendering layer in the second view can render the converted video stream data, so that when the target video is in a format not supported by the player layer, the target video can also be played in the form of a floating window. Therefore, through this solution, it is possible to play videos in formats not supported by the player layer in the form of a floating window.

[0055] Furthermore, this solution can play videos of various formats in a floating window manner in a terminal, has strong versatility, and can meet the needs of users to play various different videos in a floating window manner.

[0056] The following is an introduction to the video playback method provided by the embodiment of the present application in conjunction with the accompanying drawings. The method is applied to a terminal such as Figure 1 As shown, the method may include the following steps:

[0057] S101, in the process of playing the target video in a non-floating window mode, when receiving an instruction for instructing to play the target video in a floating window mode, stop playing the target video in a non-floating window mode, create a first view, take a preset video file as an input parameter, add a player layer provided by the operating system of the terminal in the first view; and create a second view, and add a video rendering layer provided by the operating system in the second view;

[0058] Among them, the preset video file is the format supported by the player layer;

[0059] The above-mentioned terminal can be an electronic device with video playback function, such as a smart phone, tablet computer, etc. The terminal's operating system, that is, the terminal core control software, is an interface program module between the user and the terminal hardware. Its function is to manage and control the terminal hardware and software resources. The terminal runs based on the operating system.

[0060] In this application, the first view, second view, player layer, video rendering layer, picture-in-picture component, and timer mentioned are all callable functions at the program level. If the operating system in this application is the iOS system, the view is UIview (User Interface view); the player layer is AVPlayerLayer; the video rendering layer is AVSampleBufferDisplayLayer; the picture-in-picture component is AVPictureInPictureController. If the operating system in this application is an operating system other than the iOS system, the first view, second view, player layer, video rendering layer, picture-in-picture component, etc. can be modules with the same or similar functions provided by the operating system.

[0061] The target video may be a video stored locally on the terminal, or a video obtained in real time from a video server via the Internet. For example, the target video may be a video of a remote user in a remote video conference, or a video of a film or TV series provided by a video server. Playing the target video in a non-floating window manner may refer to playing the target video in a video playback interface of a video playback client (i.e., a player) installed in the terminal.

[0062] For example, a user can use a remote conferencing application in a terminal to watch a remote user video, which is rendered and played by a player in the remote conferencing application. If the operating system of the terminal is an iOS system, and the remote user video is in a format not supported by the player layer (AVPlayerLayer) provided by the iOS system, it is impossible to directly call the picture-in-picture component (AVPictureInPictureController) provided by the iOS system to play the remote user video in the form of a floating window. The embodiment of the present application is intended to solve this problem.

[0063] The above-mentioned instruction to play the target video in the form of a floating window can be generated after the user performs a specified operation on the terminal. For example, when the user needs the terminal to return to the display desktop and also wants to play the target video in the form of a floating window, the user can trigger the return to desktop button of the terminal. At this time, an instruction to return to the desktop will be generated, and the display interface of the terminal will be switched from the video playback interface of the video playback client to the desktop. In this solution, the instruction to return to the desktop can be regarded as an instruction to play the target video in the form of a floating window. Alternatively, a button for floating window display can be set in the video playback interface of the video playback client. When the user needs to play the target video in the form of a floating window, the user can click the button to issue an instruction to play the target video in the form of a floating window.

[0064] In this step, when an instruction is received to play the target video in a floating window format, the target video can be stopped from being played in a non-floating window format. For example, the video playback interface of the video playback client can be closed and the terminal desktop can be displayed. At this time, the video playback client can continue to run in the background.

[0065] Input parameters refer to the content passed to the function when it is triggered.

[0066] In iOS system, the player layer is AVPlayerLayer, and the video rendering layer is AVSampleBufferDisplayLayer. AVPlayerLayer is the player layer of AVPlayer. AVPlayer is the video player of AVFountion framework in iOS system. The initialization of AVPlayerLayer needs to take the video file in the format it supports as the input parameter. Specifically, the address of the preset video file can be used as the AVPlayerItem parameter of AVPlayerLayer to initialize AVPlayerLayer. AVSampleBufferDisplayLayer is the display layer used for decoding and rendering video data in AVFountion framework.

[0067] The view in this embodiment may refer to the UIview in the iOS system, which is the base class of all controls in the iOS system. Therefore, in this embodiment, it is necessary to first create a first view and a second view, and then add a player layer (AVPlayerLayer) to the first view and a video rendering layer (AVSampleBufferDisplayLayer) to the second view.

[0068] The preset video file can be pre-stored in the local storage space of the terminal, which is only used to open the player layer (AV PlayerLayer), that is, the preset video file is only played in the background and not displayed in the terminal. In order to avoid the preset video file from making sound when playing in the background, interfering with the playback of the target video and affecting the user experience, the preset video file can be a silent video file, that is, a video file that does not carry sound information.

[0069] S102, using the player layer as an input parameter, enabling a picture-in-picture component provided by the operating system to display a floating window in the display interface of the terminal;

[0070] In iOS system, the picture-in-picture component is AVPictureInPictureController, which is a component provided by iOS system for generating floating window. Its initialization needs to take the player layer (AVPlayerLayer) as input parameter. In AVPict ureInPictureController, there is a StartPictureInPicture method, which is used to generate a floating window in the terminal's display interface. When AVPictureInPictureController is turned on, the terminal will automatically call the StartPictureInPicture method.

[0071] S103, when a display event of the floating window is monitored, adding the second view to the floating window;

[0072] As mentioned above, after AVPictureInPictureController is turned on, the terminal will automatically call the StartPictureInPicture method to generate a floating window in the display interface of the terminal. Therefore, the event of calling the StartPictureInPicture method can be regarded as a display event of the floating window.

[0073] When the display event of the floating window is monitored, the second view is added to the floating window, and the second view can be displayed in the manner of the floating window.

[0074] S104, obtaining current video stream data of the target video, and if the obtained video stream data is in a format not supported by the video rendering layer, converting the obtained video stream data into a format supported by the video rendering layer;

[0075] Video stream data refers to data in the process of video transmission. The current video stream data of the target video can be the data of the video frame to be played by the target video at the current playback progress. After obtaining the current video stream data of the target video, if the obtained video stream data is in a format not supported by the video rendering layer, the video stream data of the target video can be converted into a format supported by the video rendering layer. Specifically, the format conversion tool can be called to perform the format conversion. In the case where the video rendering layer is the AVSampleBufferDisplayLayer provided by the iOS system, the format supported by the video rendering layer is the CMSampleBuffer Ref format. The unsupported format may be a format other than CMSampleBufferRef, such as RGB (red / green / blue), YUV (brightness / chrominance) and other formats.

[0076] S105: Render the converted video stream data using the video rendering layer in the second view to play the target video in the floating window.

[0077] In this step, the converted video stream data can be assigned to the video rendering layer in the second view, so that the video rendering layer renders the converted video stream data. Since the second view has been added to the floating window, the target video can be played in the floating window by continuously acquiring the current video stream data of the target video and converting it into a format supported by the video rendering layer, and then using the video rendering layer in the second view to render the converted video stream data. Since this solution renders the converted video stream data through the video rendering layer in the second view, and does not render it in the player layer, the target video can be played in the form of a floating window regardless of whether the target video is in a format supported by the player layer.

[0078] In addition, if the acquired video stream data is in a format supported by the video rendering layer, the video stream data acquired by the video rendering layer in the second view may be directly used for rendering to play the target video in the floating window.

[0079] In this embodiment, by using the first view, a preset video file in a format supported by the player layer provided by the operating system is used as an input parameter of the player layer, so that the picture-in-picture component provided by the operating system can be opened normally to generate a floating window. On this basis, the second view with the video rendering layer provided by the operating system is added to the floating window, and when the video stream data is in a format not supported by the video rendering layer, the obtained video stream data is converted into a format supported by the video rendering layer, so that the video rendering layer in the second view can render the converted video stream data, so that when the target video is in a format not supported by the player layer, the target video can also be played in the form of a floating window. Therefore, through this solution, it is possible to play videos in formats not supported by the player layer in the form of a floating window.

[0080] In addition, in the related art, only videos in the format supported by the player layer can be displayed in the form of floating windows. Therefore, in order to solve this problem, it is necessary to manually convert videos in the format not supported by the player layer into the format supported by the player layer one by one on the video server or in the terminal before the picture-in-picture component provided by the operating system can be used to play the video in the form of a floating window. However, this solution can automatically play videos in the format not supported by the player layer in the form of floating windows in the terminal through an execution program, which can greatly reduce the labor cost.

[0081] In one embodiment of the present invention, Figure 2 As shown, the video playing method may further include:

[0082] S201, when a closing instruction of the floating window is received, stop displaying the floating window and remove the second view from the floating window.

[0083] The floating window can be Figure 3 As shown, it can be located in the upper layer of the terminal's desktop, or it can also be located in the upper layer of the display interface of any application in the terminal. The floating window has a close button for closing the floating window and a switch button for returning to the video playback interface of the video playback client. When it is detected that these two buttons are clicked, it can be regarded as receiving a closing instruction of the floating window. At this time, the floating window will no longer be displayed in the display interface of the terminal. In addition, in order to free up the terminal's memory and reduce the occupation of the terminal's computing resources, the second view can be removed from the floating window.

[0084] As for the first view and the opened picture-in-picture component, they do not need to be closed immediately, so that when the user needs to play the target video in a floating window again, or play other videos in a floating window, the floating window can be opened quickly and the consumption of computing resources can be reduced.

[0085] In this embodiment, it is possible to play a video in a format not supported by the player layer in a floating window. Further, when a closing instruction of the floating window is received, the floating window is stopped from being displayed, and the second view is removed from the floating window, which can free up the memory of the terminal and reduce the occupation of the terminal computing resources.

[0086] Since the floating window that comes with the operating system is defined in the operating system, its form is fixed. In this solution, by adding the second view to the floating window and playing the target video through the second view, instead of directly using the floating window that comes with the operating system to play the target video, the form of the second view can be customized, thereby indirectly realizing the customization of the floating window form. Based on this, in one embodiment of the present invention, the creation of the second view may include:

[0087] Step A1, obtaining attribute information of a preset view; wherein the attribute information represents: attributes of a control for controlling video playback contained in the view to be generated;

[0088] The control for controlling video playback in the view to be generated may include at least one of: a control for controlling video pause, a control for controlling video fast forward, a control for controlling video rewind, etc. The properties of the control may include: the position of the control in the floating window, the pattern of the control, etc.

[0089] The attribute information may also represent other attributes of the view to be generated besides the controls, such as the background color, background pattern, transparency, etc. of the view.

[0090] Step A2, creating a view containing the control represented by the attribute information as the second view.

[0091] By creating a second view containing controls represented by attribute information and then generating a floating window, the user can control the playback of the video in the floating window according to the controls contained in the second view, and the position and pattern of each control can also be customized. It can be seen that this solution has stronger scalability for the style of the floating window.

[0092] For example, the floating window generated in the terminal by this solution can be as follows: Figure 4 As shown, the floating window includes various controls pre-customized in the second view, namely the above-mentioned pause control, fast-forward control and rewind control.

[0093] When the attribute information also represents the background color, background pattern, transparency and other attributes of the view, a second view can be generated that includes the control represented by the attribute information and has the background color, background pattern, transparency and other attributes represented by the attribute information.

[0094] In this embodiment, it is possible to play videos in formats not supported by the player layer in a floating window. Furthermore, by obtaining the attribute information of a preset view and creating a view containing the controls represented by the attribute information as the second view, it is possible to customize the style of the floating window, which has stronger extensibility.

[0095] In one embodiment of the present invention, the step of obtaining the current video stream data of the target video includes:

[0096] According to the screen refresh rate of the terminal, the current video stream data is obtained from the video stream data of the target video cached in the local cache space; wherein the video stream data stored in the local cache space is obtained and cached by the terminal from the video server.

[0097] When playing online videos through a video playback client in a terminal, the terminal usually caches the video stream data obtained from the video server in the local cache space of the terminal, and then the video playback client can obtain the video stream data from the local cache space for rendering to achieve video playback. In the case of playing the target video in a floating window in this embodiment, the terminal can still continuously obtain the video stream data from the video server and cache it in the local cache space of the terminal, and then the terminal can obtain the current video stream data from the video stream data of the target video cached in the local cache space at a certain acquisition frequency, and the acquisition frequency can be the screen refresh rate of the terminal, for example, 60Hz, 120Hz, etc. By obtaining the video stream data according to the screen refresh rate of the terminal, the video playback can be made smoother and the user's viewing experience can be improved.

[0098] Currently, when a video playback client plays an online video, the system usually uses a callback function defined in an SDK (Software Development Kit) to send the video stream data to the player when receiving the video stream data. In this embodiment, the execution program actively obtains the video stream data at a certain frequency, and does not need to rely on the SDK to obtain the video stream data, thereby reducing the dependence on the SDK.

[0099] In one implementation, the step of obtaining the current video stream data from the video stream data of the target video cached in the local cache space according to the screen refresh rate of the terminal includes:

[0100] A timer whose timing period is synchronized with the screen refresh rate of the terminal is called to obtain current video stream data from the video stream data of the target video cached in the local cache space according to the timing period of the timer.

[0101] In the iOS system, the timer synchronized with the screen refresh rate of the terminal may be a CADisplayLink timer. Since the timing period of the CADisplayLink timer may always be consistent with the screen refresh rate of the terminal, even if the user modifies the screen refresh rate of the terminal, this solution can still utilize the CADisplayLink timer to obtain the current video stream data according to the screen refresh rate of the terminal.

[0102] In this embodiment, it is possible to play videos in formats not supported by the player layer in a floating window. Further, by obtaining video stream data according to the screen refresh rate of the terminal, the video playback can be smoother, improving the user's viewing experience.

[0103] In order to facilitate understanding of the video playback method provided in the embodiment of the present application, Figure 5-Figure 6 The video playback method is introduced as an example.

[0104] like Figure 5 As shown, in a terminal running the iOS system, if the target video needs to be played in a floating window, the AVPictureInPictureController needs to be set first to enable the floating window function of the iOS system; then a custom view, i.e., the second view, needs to be added to the floating window; and the CADisplayLink timer needs to be turned on to loop through the steps of obtaining the video stream data of the target video and rendering the video stream data of the target video, thereby playing the target video in the floating window. When the floating window is closed, the operation of the CADisplayLink timer is stopped at the same time.

[0105] In an application scenario, the target video is an online video provided by a video server. The information interaction process between the user, the terminal and the video server can be as follows: Figure 6 As shown. First, the user sends an instruction to the terminal to open a floating window for the target video, that is, an instruction for instructing to play the target video in the form of a floating window. The terminal can execute the above steps S101-S103 to open the floating window, and can return the opening result to the user through the UI interface, that is, the result of success or failure in opening the floating window. After the floating window is successfully opened, the terminal can request the video stream data of the target video from the video server, and the video server can return the video stream data to the terminal, and the terminal can start the CADisplayLink timer to continuously loop the steps of obtaining and rendering the current video stream data of the target video, that is, loop the above steps S104-S105. Finally, after the user sends an instruction to the terminal to close the floating window, the terminal can turn off the CADisplayLink timer and stop obtaining the video stream data.

[0106] In this embodiment, by using the first view, a preset video file in a format supported by the player layer provided by the operating system is used as an input parameter of the player layer, so that the picture-in-picture component provided by the operating system can be opened normally to generate a floating window. On this basis, the second view with the video rendering layer provided by the operating system is added to the floating window, and when the video stream data is in a format not supported by the video rendering layer, the obtained video stream data is converted into a format supported by the video rendering layer, so that the video rendering layer in the second view can render the converted video stream data, so that when the target video is in a format not supported by the player layer, the target video can also be played in the form of a floating window. Therefore, through this solution, it is possible to play videos in formats not supported by the player layer in the form of a floating window.

[0107] Based on the same inventive concept, the embodiment of the present application also provides a video playback device, which is applied to a terminal running an iOS system, such as Figure 7 Said device comprises:

[0108] The view creation module 701 is used for, during the process of playing the target video in a non-floating window mode, when receiving an instruction for instructing to play the target video in a floating window mode, stopping playing the target video in the non-floating window mode, creating a first view, taking a preset video file as an input parameter, adding a player layer provided by the operating system of the terminal to the first view; and creating a second view, adding a video rendering layer provided by the operating system to the second view; wherein the preset video file is in a format supported by the player layer;

[0109] A component opening module 702, configured to use the player layer as an input parameter to open a picture-in-picture component provided by the operating system to display a floating window in the display interface of the terminal;

[0110] A view adding module 703, configured to add the second view to the floating window when a display event of the floating window is monitored;

[0111] The video stream acquisition module 704 is used to acquire the current video stream data of the target video, and if the acquired video stream data is in a format not supported by the video rendering layer, convert the acquired video stream data into a format supported by the video rendering layer;

[0112] The rendering module 705 is used to render the converted video stream data using the video rendering layer in the second view to play the target video in the floating window.

[0113] Optionally, the view creation module 701 is specifically used to obtain attribute information of a preset view; wherein the attribute information represents: the attributes of the controls for controlling video playback contained in the view to be generated; and create a view containing the controls represented by the attribute information as the second view.

[0114] Optionally, the video stream acquisition module 704 is specifically used to obtain current video stream data from the video stream data of the target video cached in the local cache space according to the screen refresh rate of the terminal; wherein the video stream data stored in the local cache space is obtained and cached by the terminal from the video server.

[0115] Optionally, the video stream acquisition module 704 is specifically used to call a timer whose timing period is synchronized with the screen refresh rate of the terminal, so as to obtain current video stream data from the video stream data of the target video cached in the local cache space according to the timing period of the timer.

[0116] Optionally, the video playback device further includes:

[0117] The view removing module is used to stop displaying the floating window and remove the second view from the floating window when receiving a closing instruction of the floating window.

[0118] Optionally, the preset video file is a locally stored silent video file.

[0119] In this embodiment, by using the first view, a preset video file in a format supported by the player layer provided by the operating system is used as an input parameter of the player layer, so that the picture-in-picture component provided by the operating system can be opened normally to generate a floating window. On this basis, the second view with the video rendering layer provided by the operating system is added to the floating window, and when the video stream data is in a format not supported by the video rendering layer, the obtained video stream data is converted into a format supported by the video rendering layer, so that the video rendering layer in the second view can render the converted video stream data, so that when the target video is in a format not supported by the player layer, the target video can also be played in the form of a floating window. Therefore, through this solution, it is possible to play videos in formats not supported by the player layer in the form of a floating window.

[0120] The present application also provides an electronic device, such as Figure 8 As shown, including:

[0121] Memory 801, used for storing computer programs;

[0122] The processor 802 is used to implement any of the above-mentioned video playing methods when executing the program stored in the memory 801.

[0123] Furthermore, the electronic device may further include a communication bus and / or a communication interface, and the processor 802, the communication interface, and the memory 801 communicate with each other via the communication bus.

[0124] The communication bus mentioned in the above electronic device can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.

[0125] The communication interface is used for communication between the above electronic device and other devices.

[0126] The memory may include a random access memory (RAM) or a non-volatile memory (NVM), such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.

[0127] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.

[0128] In another embodiment provided in the present application, a computer-readable storage medium is provided, in which a computer program is stored. When the computer program is executed by a processor, the steps of any of the above-mentioned video playback methods are implemented.

[0129] In another embodiment provided in the present application, a computer program product including instructions is also provided, which, when executed on a computer, enables the computer to execute the video playback method described in any one of the above embodiments.

[0130] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can 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 the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be transmitted from a website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium may be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a solid-state hard disk (SSD), etc.

[0131] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0132] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device, electronic device, computer-readable storage medium, and computer program product embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments.

[0133] The above description is only a preferred embodiment of the present application and is not intended to limit the protection scope of the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application are included in the protection scope of the present application.

Claims

1. A video playback method, characterized in that: Applied to a terminal, the method comprises: In the process of playing the target video in a non-floating window mode, when an instruction for instructing to play the target video in a floating window mode is received, the target video is stopped from being played in the non-floating window mode, and a first view is created, a preset video file is used as an input parameter, and a player layer provided by the operating system of the terminal is added to the first view; and a second view is created, and a video rendering layer provided by the operating system is added to the second view; wherein the preset video file is in a format supported by the player layer; Using the player layer as an input parameter, opening a picture-in-picture component provided by the operating system to display a floating window in a display interface of the terminal; When a display event of the floating window is monitored, adding the second view to the floating window; Acquire current video stream data of the target video, and if the acquired video stream data is in a format not supported by the video rendering layer, convert the acquired video stream data into a format supported by the video rendering layer; The converted video stream data is rendered using the video rendering layer in the second view to play the target video in the floating window.

2. The method according to claim 1, characterized in that The creating the second view comprises: Acquire attribute information of a preset view; wherein the attribute information represents: attributes of a control for controlling video playback contained in the view to be generated; A view including the control represented by the attribute information is created as the second view.

3. The method according to claim 1, characterized in that The obtaining of the current video stream data of the target video includes: According to the screen refresh rate of the terminal, the current video stream data is obtained from the video stream data of the target video cached in the local cache space; wherein the video stream data stored in the local cache space is obtained and cached by the terminal from the video server.

4. The method according to claim 3, characterized in that The step of obtaining current video stream data from the video stream data of the target video cached in the local cache space according to the screen refresh rate of the terminal includes: A timer whose timing period is synchronized with the screen refresh rate of the terminal is called to obtain current video stream data from the video stream data of the target video cached in the local cache space according to the timing period of the timer.

5. The method according to claim 1, characterized in that The method further comprises: When a closing instruction of the floating window is received, the display of the floating window is stopped, and the second view is removed from the floating window.

6. The method according to any one of claims 1 to 5, characterized in that: The preset video file is a locally stored silent video file.

7. A video playback device, characterized in that: Applied to a terminal, the device comprises: A view creation module, used for, during the process of playing a target video in a non-floating window mode, when receiving an instruction for instructing to play the target video in a floating window mode, stopping playing the target video in the non-floating window mode, creating a first view, taking a preset video file as an input parameter, adding a player layer provided by the operating system of the terminal to the first view; and creating a second view, adding a video rendering layer provided by the operating system to the second view; wherein the preset video file is in a format supported by the player layer; A component opening module, used to use the player layer as an input parameter to open the picture-in-picture component provided by the operating system to display a floating window in the display interface of the terminal; A view adding module, configured to add the second view to the floating window when a display event of the floating window is monitored; A video stream acquisition module, used for acquiring the current video stream data of the target video, and converting the acquired video stream data into a format supported by the video rendering layer when the acquired video stream data is in a format not supported by the video rendering layer; A rendering module is used to render the converted video stream data using the video rendering layer in the second view to play the target video in the floating window.

8. An electronic device, characterized in that: include: Memory, used to store computer programs; A processor, for implementing any of the methods described in claims 1-6 when executing a program stored in a memory.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.

10. A computer program product, characterized in that It comprises a computer program which, when on a computer, implements the method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Video file preview method and display equipment

    CN111669634A

  • Image rendering method and device, electronic equipment and storage medium

    CN115767182A

  • Video playing method and device, computer equipment and storage medium

    CN117896567A

  • Combined system for game live-streaming and gameplay

    US20230405478A1

Cited By

  • Streaming media video playing method in picture-in-picture mode and related device

    CN120416567A