A video playback method, apparatus, electronic device, and readable storage medium
By creating a first and second view in the terminal, and adding the operating system's player layer and video rendering layer, the problem of the operating system not supporting video formats and being unable to play in a floating window was solved, enabling floating window playback of multiple video formats, improving user experience and playback versatility.
Patent Information
- Application Number
- CN202410842781.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-26
- Publication Date
- 2025-12-02
- Estimated Expiration
- 2044-06-26
AI Technical Summary
Existing operating systems only support specific video formats that cannot be displayed as floating windows, making it impossible to play unsupported video formats as floating windows in the terminal.
By creating a first view and adding a player layer provided by the operating system, and adding a video rendering layer in the second view, the converted video stream data is rendered using the video rendering layer to play the target video in a floating window.
It enables the playback of videos in a floating window that do not support the operating system's formats, improving the versatility of video playback and user experience, and reducing manual conversion costs.
Smart Images

Figure CN118741206B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a video playback method, apparatus, electronic device, and readable storage medium. Background Technology
[0002] Currently, to play videos as a floating window on a device, a picture-in-picture component can be enabled using the player layer provided by the device's operating system to generate a floating window, within which the video can then be played. For example, in iOS (a mobile operating system), this player layer is AVPlayerLayer, and the picture-in-picture component is AVPiectureInPictureController.
[0003] However, the player layer provided by the terminal's operating system often only supports rendering videos of specific formats. This means that the terminal's operating system can only display videos of specific formats as floating windows, while it does not support displaying videos of other formats as floating windows.
[0004] Therefore, how to play videos of formats not supported by the player layer using a floating window is an urgent problem to be solved. Summary of the Invention
[0005] The purpose of this application is to provide a video playback method, apparatus, electronic device, and readable storage medium to enable playback of videos in formats not supported by the player layer via a floating window. The specific technical solution is as follows:
[0006] In one aspect of this application, a video playback method is provided, applied to a terminal, the method comprising:
[0007] During the playback of a target video in a non-floating window mode, when an instruction is received to play the target video in a floating window mode, the playback of the target video in the non-floating window mode is stopped, and a first view is created, with a preset video file as input parameter, and a player layer provided by the terminal's operating system is added to the first view; and a second view is created, with a video rendering layer provided by the operating system 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 input parameter, the picture-in-picture component provided by the operating system is enabled to display a floating window in the display interface of the terminal;
[0009] When the display event of the floating window is detected, the second view is added to the floating window;
[0010] Obtain the 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, convert the obtained 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, creating the second view includes:
[0013] Obtain the attribute information of the preset view; wherein, the attribute information represents the attributes of the controls used to control video playback contained in the view to be generated;
[0014] Create a view containing the control represented by the aforementioned attribute information, as the second view.
[0015] Optionally, obtaining the 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 by the terminal from the video server and cached.
[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 with a timing period synchronized with the screen refresh rate of the terminal is invoked to retrieve the 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 includes:
[0020] When a command to close the floating window is received, the floating window is stopped from being displayed, 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 this application, a video playback device is also provided, applied to a terminal running the iOS system, the device comprising:
[0023] A view creation module is used to, during the playback of a target video in a non-floating window mode, when receiving an instruction to play the target video in a floating window mode, stop playing the target video in the non-floating window mode, create a first view, take a preset video file as input parameter, add a player layer provided by the terminal's operating system to the first view; and create a second view, add 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] The component activation module is used to take the player layer as input parameter and activate the picture-in-picture component provided by the operating system to display a floating window in the display interface of the terminal.
[0025] The view adding module is used to add the second view to the floating window when the display event of the floating window is detected;
[0026] The video stream acquisition module 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.
[0027] The rendering module is used to render the converted video stream data using the video rendering layer in the second view, so as to play the target video in the floating window.
[0028] In another aspect of the embodiments of this application, an electronic device is also provided, including:
[0029] Memory, used to store computer programs;
[0030] The processor, when executing a program stored in memory, implements any of the video playback methods described above.
[0031] In another aspect of the embodiments of this application, a computer-readable storage medium is also provided, wherein a computer program is stored therein, and the computer program, when executed by a processor, implements any of the video playback methods described above.
[0032] This application also provides a computer program product containing instructions that, when run on a computer, cause the computer to execute any of the video playback methods described above.
[0033] Beneficial effects of the embodiments in this application:
[0034] This application provides a video playback method applied to a terminal, the method comprising:
[0035] During the playback of the target video in a non-floating window mode, when an instruction is received to play the target video in a floating window mode, playback in the non-floating window mode is stopped, and a first view is created, taking a preset video file as input. A player layer provided by the terminal's operating system is added to the first view. A second view is also created, taking a video rendering layer provided by the operating system as input. The preset video file is in a format supported by the player layer. The picture-in-picture component provided by the operating system is enabled, taking the player layer as input, to display a floating window on the terminal's display interface. When a floating window display event is detected, the second view is added to the floating window. The current video stream data of the target video is obtained, and if the obtained video stream data is in a format not supported by the video rendering layer, it is converted to 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.
[0036] In this solution, a first view is used, with a preset video file in a format supported by the operating system's player layer as input to the player layer. This allows the picture-in-picture component provided by the operating system to function correctly, generating a floating window. A second view, containing a video rendering layer provided by the operating system, is then added to the floating window. Furthermore, if the video stream data is in a format not supported by the video rendering layer, the acquired video stream data is converted to a format supported by the video rendering layer. This allows the video rendering layer in the second view to render the converted video stream data, enabling the target video to play in a floating window even when the target video is in a format not supported by the player layer. Therefore, this solution enables the playback of videos in formats not supported by the player layer using a floating window.
[0037] Of course, implementing any product or method of this application does not necessarily require achieving all of the advantages described above at the same time. Attached Figure Description
[0038] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other embodiments can be obtained based on these drawings.
[0039] Figure 1 This is a schematic flowchart of a video playback method provided in an embodiment of this application;
[0040] Figure 2 This is another flowchart illustrating the video playback method provided in an embodiment of this application;
[0041] Figure 3 This is a schematic diagram of the display interface of the terminal in the video playback method provided in the embodiments of this application;
[0042] Figure 4 This is a schematic diagram of a floating window in the video playback method provided in the embodiments of this application;
[0043] Figure 5 This is another flowchart illustrating the video playback method provided in the embodiments of this application;
[0044] Figure 6 This is a schematic diagram of information interaction in a video playback method provided in an embodiment of this application;
[0045] Figure 7 This is a schematic diagram of the structure of the video playback device provided in the embodiments of this application;
[0046] Figure 8 This is a schematic diagram of the structure of the electronic device provided in the embodiments of this application. Detailed Implementation
[0047] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art based on this application are within the scope of protection of this application.
[0048] To enable playback of videos with formats not supported by the player layer via a floating window, this application provides a video playback method, apparatus, electronic device, and readable storage medium. This video playback method can be applied to a terminal. Specifically, each step of the video playback method can be executed by a pre-developed program (hereinafter referred to as the executable program) installed on the terminal. The method may include the following steps:
[0049] During the playback of the target video in a non-floating window mode, when an instruction is received to play the target video in a floating window mode, the playback of the target video in a non-floating window mode is stopped, and a first view is created, with a preset video file as input parameter. A player layer provided by the terminal's operating system is added to the first view; and a second view is created, with a video rendering layer provided by the operating system added to 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, so as to display a floating window in the terminal's display interface.
[0051] When the display event of the floating window is detected, add the second view to the floating window;
[0052] Get the 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, convert the obtained 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 utilizing a first view and using a preset video file in a format supported by the player layer provided by the operating system as the input parameter for the player layer, the picture-in-picture component provided by the operating system can be opened normally to generate a floating window. Based on this, a second view with a video rendering layer provided by the operating system is added to the floating window. Furthermore, even if the video stream data is in a format not supported by the video rendering layer, the acquired video stream data is converted to a format supported by the video rendering layer, allowing the video rendering layer in the second view to render the converted video stream data. Therefore, even when the target video is in a format not supported by the player layer, the target video can still be played in a floating window. Thus, this solution enables the playback of videos in formats not supported by the player layer using a floating window.
[0055] Furthermore, this solution enables the playback of various video formats in a floating window on the terminal, making it highly versatile and able to meet users' needs for playing multiple different videos in a floating window manner.
[0056] The video playback method provided in the embodiments of this application is described below with reference to the accompanying drawings. This method is applied to a terminal, such as... Figure 1 As shown, the method may include the following steps:
[0057] S101, during the process of playing the target video in a non-floating window manner, when an instruction is received to play the target video in a floating window manner, stop playing the target video in a non-floating window manner, create a first view, take the preset video file as input parameter, add the player layer provided by the terminal's operating system to the first view; and create a second view, add the video rendering layer provided by the operating system to the second view.
[0058] The preset video files are in formats supported by the player layer;
[0059] The aforementioned terminal can be an electronic device with video playback capabilities, such as a smartphone or tablet computer. The terminal's operating system, or core control software, is the interface program module between the user and the terminal hardware. Its function is to manage and control the terminal's 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 from a program perspective. If the operating system in this application is iOS, then the view is UIView (User Interface view); the player layer is AVPlayerLayer; the video rendering layer is AVSampleBufferDisplayLayer; and the picture-in-picture component is AVPiectureInPictureController. If the operating system in this application is an operating system other than iOS, then 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 that operating system.
[0061] The target video can 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 could be the video of a remote user in a remote video conferencing scenario, or it could be a movie or TV show provided by the video server. Playing the target video in a non-floating window manner means playing the target video within the video playback interface of a video playback client (i.e., the player) installed on the terminal.
[0062] For example, a user can use a remote conferencing application on the terminal to watch a video of a remote user. The video of the remote user is rendered and played through the player in the remote conferencing application. If the terminal's operating system is iOS and the video of the remote user is in a format not supported by the AVPlayer layer provided by the iOS system, then it is not possible to play the video of the remote user in the form of a floating window by directly calling the picture-in-picture component (AVPictureInPictureController) provided by the iOS system. The embodiments of this application are intended to solve this problem.
[0063] The instruction to play the target video in a floating window can be generated after the user performs a specified operation on the terminal. For example, when a user needs the terminal to return to the desktop while simultaneously playing the target video in a floating window, the user can trigger the terminal's return-to-desktop button. This will generate a return-to-desktop instruction, and the terminal's display interface will switch from the video playback client's video playback interface to the desktop. In this solution, this return-to-desktop instruction can be considered as an instruction to play the target video in a floating window. Alternatively, a floating window display button can be set in the video playback interface of the video playback client. When the user needs to play the target video in a floating window, they can click this button to issue an instruction to play the target video in a floating window manner.
[0064] In this step, when an instruction is received to play the target video in a floating window manner, the playback of the target video in a non-floating window manner can be stopped. For example, the video playback interface of the video playback client can be closed and the terminal desktop can be displayed, while 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 and called.
[0066] In iOS, the player layer is called AVPlayerLayer, and the video rendering layer is called AVSampleBufferDisplayLayer. AVPlayerLayer is the player layer for AVPlayer, which is the video player within the AVPountion framework in iOS. Initializing AVPlayerLayer requires a video file of its supported formats as input. Specifically, the address of a preset video file can be used as the AVPlayerItem parameter to initialize AVPlayerLayer. AVSampleBufferDisplayLayer is the display layer within the AVPountion framework used for decoding and rendering video data.
[0067] In this embodiment, the view can refer to the UIView in the iOS system. UIView 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, then add a player layer (AVPlayerLayer) to the first view, and add a video rendering layer (AVSampleBufferDisplayLayer) to the second view.
[0068] The preset video file can be stored in the terminal's local storage space in advance. It is only used to enable the AV PlayerLayer. That is to say, the preset video file is only played in the background and is not displayed on the terminal. In order to avoid the preset video file producing 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 without sound information.
[0069] S102, take the player layer as input parameter and enable the picture-in-picture component provided by the operating system to display a floating window in the terminal's display interface;
[0070] In iOS, the picture-in-picture component, AVPictureInPictureController, is a component provided by iOS for creating floating windows. Its initialization requires the player layer (AVPlayerLayer) as an input parameter. The AVPictureInPictureController class defines a StartPictureInPicture method, which is used to create a floating window in the terminal's display. When AVPictureInPictureController is started, the terminal automatically calls the StartPictureInPicture method.
[0071] S103, when the display event of the floating window is detected, add the second view to the floating window;
[0072] As shown above, since the terminal automatically calls the StartPictureInPicture method after AVPictureInPictureController is started, creating a floating window in the terminal's display interface, the event that calls the StartPictureInPicture method can be regarded as the display event of the floating window.
[0073] When the display event of the floating window is detected, the second view can be added to the floating window and displayed in the same way as the floating window.
[0074] S104, Obtain the 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, convert the obtained video stream data into a format supported by the video rendering layer.
[0075] Video stream data refers to the data generated during video transmission. The current video stream data of the target video can be the data of the video frames to be played 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, it can be converted to a format supported by the video rendering layer. This can be done using a format conversion tool. When the video rendering layer is the AVSampleBufferDisplayLayer provided by the iOS system, the supported format is CMSampleBufferRef. Unsupported formats include those other than CMSampleBufferRef, such as RGB (red / green / blue) and YUV (luminance / chrominance) formats.
[0076] S105, the converted video stream data is rendered using the video rendering layer in the second view in order 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, allowing the video rendering layer to render the converted video stream data. Since the second view is added to the floating window, by continuously acquiring the current video stream data of the target video and converting it to 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, the target video can be played in the floating window. Because this solution renders the converted video stream data through the video rendering layer in the second view, rather than rendering it in the player layer, the target video can be played in a floating window regardless of whether it 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 can be directly used for rendering to play the target video in the floating window.
[0079] In this embodiment, by utilizing a first view and using a preset video file in a format supported by the player layer provided by the operating system as the input parameter for the player layer, the picture-in-picture component provided by the operating system can be opened normally to generate a floating window. Based on this, a second view with a video rendering layer provided by the operating system is added to the floating window. Furthermore, even if the video stream data is in a format not supported by the video rendering layer, the acquired video stream data is converted to a format supported by the video rendering layer, allowing the video rendering layer in the second view to render the converted video stream data. Therefore, even when the target video is in a format not supported by the player layer, the target video can still be played in a floating window. Thus, this solution enables the playback of videos in formats not supported by the player layer using a floating window.
[0080] Furthermore, since related technologies can only display videos in formats supported by the player layer as floating windows, addressing this issue requires manual conversion of videos in formats unsupported by the player layer to supported formats one by one on the video server or in the terminal before the operating system's picture-in-picture component can be used to play the video as a floating window. This solution, however, can automate the playback of videos in formats unsupported by the player layer in the terminal via a single executable program, significantly reducing manual costs.
[0081] In one embodiment of the present invention, such as Figure 2 As shown, the video playback method may also include:
[0082] S201, when a command to close the floating window is received, the floating window is stopped from being displayed and the second view is removed from the floating window.
[0083] The floating window can be like Figure 3 As shown, it can be located above the terminal's desktop or above the display interface of any application within the terminal. This floating window includes a close button for closing the floating window and a toggle button for returning to the video playback client's interface. When either of these buttons is clicked, it is considered that a closing command for the floating window has been received, and the floating window will no longer be displayed on the terminal's screen. Furthermore, to free up terminal memory and reduce the consumption of terminal computing resources, the second view can be removed from the floating window.
[0084] As for the first view and the already opened picture-in-picture component, they do not need to be closed immediately. This allows users to quickly open the floating window when they need to play the target video or other videos in a floating window, thus reducing the consumption of computing resources.
[0085] In this embodiment, video formats not supported by the player layer can be played using a floating window. Furthermore, when a command to close 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 terminal memory and reduce the consumption of terminal computing resources.
[0086] Since the floating window built into the operating system is defined within that operating system, its form is fixed. However, in this solution, a second view is added to the floating window, and the target video is played through the second view, rather than directly using the operating system's built-in floating window. The form of this second view can be customized, thus indirectly achieving customization of the floating window's form. Based on this, in one embodiment of the present invention, creating the second view may include:
[0087] Step A1: Obtain the attribute information of the preset view; where the attribute information represents the attributes of the controls used to control video playback contained in the view to be generated.
[0088] The controls for video playback in the view to be generated may include at least one of the following: controls for pausing the video, controls for fast-forwarding the video, and controls for rewinding the video. The properties of the controls may include: the position of the control within the floating window, the control's pattern, etc.
[0089] The attribute information can also represent other properties of the view to be generated besides the controls, such as the background color, background pattern, and transparency of the view.
[0090] Step A2: Create a view containing the attribute information representing the control, as the second view.
[0091] By creating a second view containing the control's attribute information, and then generating a floating window, users can control the video playback based on the various controls contained in the second view within the floating window. Furthermore, the position and pattern of each control can be customized. As can be seen, this solution has stronger extensibility for the style of the floating window.
[0092] For example, the floating window generated in the terminal using this solution can be as follows: Figure 4 As shown, the floating window contains various controls that are pre-defined in the second view, namely the pause control, fast forward control, and rewind control mentioned above.
[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 contains 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 of formats not supported by the player layer using a floating window. Furthermore, by obtaining the attribute information of a preset view, a view containing the controls represented by the attribute information is created as a second view, which enables customization of the floating window style and provides greater scalability.
[0095] In one embodiment of the present invention, the above-mentioned acquisition of the current video stream data of the target video includes:
[0096] Based on the terminal's screen refresh rate, the current video stream data is obtained from the video stream data of the target video cached in the local cache space; the video stream data stored in the local cache space is obtained by the terminal from the video server and cached.
[0097] When playing online videos through a video playback client on a terminal, the terminal typically first caches the video stream data obtained from the video server in its local cache space. The video playback client then retrieves the video stream data from the local cache space for rendering to achieve video playback. In this embodiment, when playing the target video in a floating window manner, the terminal can still continuously obtain video stream data from the video server and cache it in its local cache space. The terminal can then retrieve the current video stream data from the cached target video stream data in its local cache space at a certain frequency. This retrieval frequency can be the terminal's screen refresh rate, such as 60Hz or 120Hz. By retrieving video stream data according to the terminal's screen refresh rate, video playback becomes smoother, improving the user's viewing experience.
[0098] Currently, when playing online videos, video playback clients typically use callback functions defined in the SDK (Software Development Kit) to send video stream data to the player when they receive it. However, in this embodiment, the executable program actively obtains video stream data at a certain frequency, without relying on the SDK to obtain video stream data, thus reducing the dependence on the SDK.
[0099] In one implementation, obtaining the current video stream data from the video stream data of the target video cached in the local cache space according to the terminal's screen refresh rate includes:
[0100] Call a timer whose timing period is synchronized with the terminal's screen refresh rate to retrieve the current video stream data from the target video's video stream data cached in the local cache space according to the timer's timing period.
[0101] In the iOS system, the timer that is synchronized with the terminal's screen refresh rate can be the CADisplayLink timer. Since the timing period of the CADisplayLink timer can always be consistent with the terminal's screen refresh rate, even if the user changes the terminal's screen refresh rate, this solution can still use the CADisplayLink timer to obtain the current video stream data according to the terminal's screen refresh rate.
[0102] In this embodiment, videos of formats not supported by the player layer can be played using a floating window. Furthermore, by obtaining video stream data according to the terminal's screen refresh rate, video playback can be made smoother, improving the user's viewing experience.
[0103] To facilitate understanding of the video playback method provided in the embodiments of this application, the following is combined with... Figures 5-6 The video playback method is described exemplarily.
[0104] like Figure 5 As shown, in a terminal running the iOS system, to play a target video in a floating window, you first need to set AVPictureInPictureController to enable the iOS system's floating window function; then add a custom view, i.e., a second view, to the floating window; and start the CADisplayLink timer to repeatedly execute the steps of acquiring the target video's video stream data and rendering the video stream data, thereby enabling the target video to play in the floating window. When the floating window is closed, the CADisplayLink timer stops running simultaneously.
[0105] In one application scenario, where 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 a command to the terminal to open a floating window for the target video, indicating that the target video should be played in a floating window manner. The terminal can execute steps S101-S103 to open the floating window and return the opening result to the user through the UI interface, i.e., whether the floating window was opened successfully or not. After the floating window is successfully opened, the terminal can request the video stream data of the target video from the video server. The video server can then return the video stream data to the terminal, and the terminal can start a CADisplayLink timer to continuously loop the steps of acquiring and rendering the current video stream data of the target video, i.e., looping through steps S104-S105. Finally, after the user sends a command to the terminal to close the floating window, the terminal can close the CADisplayLink timer and stop acquiring video stream data.
[0106] In this embodiment, by utilizing a first view and using a preset video file in a format supported by the player layer provided by the operating system as the input parameter for the player layer, the picture-in-picture component provided by the operating system can be opened normally to generate a floating window. Based on this, a second view with a video rendering layer provided by the operating system is added to the floating window. Furthermore, even if the video stream data is in a format not supported by the video rendering layer, the acquired video stream data is converted to a format supported by the video rendering layer, allowing the video rendering layer in the second view to render the converted video stream data. Therefore, even when the target video is in a format not supported by the player layer, the target video can still be played in a floating window. Thus, this solution enables the playback of videos in formats not supported by the player layer using a floating window.
[0107] Based on the same inventive concept, this application also provides a video playback device, applied to a terminal running the iOS system, such as... Figure 7 The device includes:
[0108] The view creation module 701 is used to, during the process of playing a target video in a non-floating window mode, when receiving an instruction to play the target video in a floating window mode, stop playing the target video in the non-floating window mode, create a first view, take a preset video file as input parameter, add a player layer provided by the terminal's operating system to the first view; and create a second view, add 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] The component activation module 702 is used to take the player layer as an input parameter and activate the picture-in-picture component provided by the operating system to display a floating window in the display interface of the terminal.
[0110] The view adding module 703 is used to add the second view to the floating window when the display event of the floating window is detected;
[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, so as to play the target video in the floating window.
[0113] Optionally, the view creation module 701 is specifically used to obtain the attribute information of a preset view; wherein, the attribute information represents the attributes of the controls used to control video playback contained in the view to be generated; and to create a view containing the controls represented by the attribute information as a second view.
[0114] Optionally, the video stream acquisition module 704 is specifically used to acquire 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; wherein the video stream data stored in the local cache space is acquired by the terminal from the video server and cached.
[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 acquire the 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 removal module is used to stop displaying the floating window and remove the second view from the floating window when a closing command is received.
[0118] Optionally, the preset video file is a locally stored silent video file.
[0119] In this embodiment, by utilizing a first view and using a preset video file in a format supported by the player layer provided by the operating system as the input parameter for the player layer, the picture-in-picture component provided by the operating system can be opened normally to generate a floating window. Based on this, a second view with a video rendering layer provided by the operating system is added to the floating window. Furthermore, even if the video stream data is in a format not supported by the video rendering layer, the acquired video stream data is converted to a format supported by the video rendering layer, allowing the video rendering layer in the second view to render the converted video stream data. Therefore, even when the target video is in a format not supported by the player layer, the target video can still be played in a floating window. Thus, this solution enables the playback of videos in formats not supported by the player layer using a floating window.
[0120] This application also provides an electronic device, such as... Figure 8 As shown, it includes:
[0121] Memory 801 is used to store computer programs;
[0122] The processor 802, when executing the program stored in the memory 801, implements any of the video playback methods described above.
[0123] Furthermore, the aforementioned electronic device may also include a communication bus and / or a communication interface, with the processor 802, the communication interface, and the memory 801 communicating with each other via the communication bus.
[0124] The communication bus mentioned in the above electronic devices can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus can be divided into address bus, data bus, control bus, etc. For ease of illustration, only one thick line is used to represent it in the diagram, but this does not indicate that there is only one bus or one type of bus.
[0125] The communication interface is used for communication between the aforementioned electronic devices and other devices.
[0126] The memory may include random access memory (RAM) or non-volatile memory (NVM), such as at least one disk storage device. Optionally, the memory may also be at least one storage device located remotely from the aforementioned processor.
[0127] The processors mentioned above can be general-purpose processors, including central processing units (CPUs), network processors (NPs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.
[0128] In another embodiment provided in this application, a computer-readable storage medium is also provided, which stores a computer program that, when executed by a processor, implements the steps of any of the video playback methods described above.
[0129] In another embodiment provided in this application, a computer program product containing instructions is also provided, which, when run on a computer, causes the computer to perform any of the video playback methods described in the above embodiments.
[0130] In the above embodiments, implementation can be achieved entirely or partially through software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented entirely or partially 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, all or part of the processes or functions described in the embodiments of this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a solid-state drive (SSD), etc.
[0131] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0132] The various embodiments in this specification are described in a related manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the embodiments of apparatus, electronic devices, computer-readable storage media, and computer program products are basically similar to the method embodiments, and therefore the descriptions are relatively simple; relevant parts can be referred to the descriptions of the method embodiments.
[0133] The above description is merely a preferred embodiment of this application and is not intended to limit the scope of protection of this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application are included within the scope of protection of this application.
Claims
1. A video playback method, characterized in that, Applied to a terminal, the method includes: During the playback of a target video in a non-floating window mode, when an instruction is received to play the target video in a floating window mode, the playback of the target video in the non-floating window mode is stopped, and a first view is created, with a preset video file as input parameter, and a player layer provided by the terminal's operating system is added to the first view; and a second view is created, with a video rendering layer provided by the operating system added to the second view; wherein, the preset video file is in a format supported by the player layer; Using the player layer as input parameter, the picture-in-picture component provided by the operating system is enabled to display a floating window in the display interface of the terminal; When the display event of the floating window is detected, the second view is added to the floating window; Obtain the 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, convert the obtained 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 creation of the second view includes: Obtain the attribute information of the preset view; wherein, the attribute information represents the attributes of the controls used to control video playback contained in the view to be generated; Create a view containing the control represented by the aforementioned attribute information, as the second view.
3. The method according to claim 1, characterized in that, The step of obtaining 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 by the terminal from the video server and cached.
4. The method according to claim 3, characterized in that, 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: A timer with a timing period synchronized with the screen refresh rate of the terminal is invoked to retrieve the 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 includes: When a command to close the floating window is received, the floating window is stopped from being displayed, and the second view is removed from the floating window.
6. The method according to any one of claims 1-5, characterized in that, The preset video file is a silent video file stored locally.
7. A video playback device, characterized in that, Applied to a terminal, the device includes: A view creation module is used to, during the playback of a target video in a non-floating window mode, when receiving an instruction to play the target video in a floating window mode, stop playing the target video in the non-floating window mode, create a first view, take a preset video file as input parameter, add a player layer provided by the terminal's operating system to the first view; and create a second view, add 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; The component activation module is used to take the player layer as input parameter and activate the picture-in-picture component provided by the operating system to display a floating window in the display interface of the terminal. The view adding module is used to add the second view to the floating window when the display event of the floating window is detected; The video stream acquisition module 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. The rendering module is used to render the converted video stream data using the video rendering layer in the second view, so as 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, when executing a program stored in memory, implements the method of any one of claims 1-6.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the method described in any one of claims 1-6.
10. A computer program product, characterized in that, Includes a computer program that, when on a computer, implements the method according to any one of claims 1-6.
Citation Information
Patent Citations
Video file preview method and display equipment
CN111669634A
Video playing method and device, computer equipment and storage medium
CN117896567A