Video playing method and related device
By identifying the content categories and display methods of video applications within the HarmonyOS system, and employing a player component reuse strategy, along with caching pools and lifecycle methods, the loading latency issue caused by frequent creation and destruction was resolved, improving playback smoothness and performance, and ensuring a better user experience.
Patent Information
- Application Number
- CN202511175082.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-21
- Publication Date
- 2025-11-18
AI Technical Summary
In HarmonyOS, the frequent creation and destruction of player components within video applications leads to significant loading delays and system resource overhead, especially on low-performance devices, severely impacting playback smoothness and user experience.
By determining the content category and display method within the current page of the video application, a player component reuse strategy is adopted. By utilizing a cache pool and lifecycle methods, the player component can be reused repeatedly, avoiding frequent creation and destruction.
It significantly improves the player's instant loading speed, reduces system resource consumption, enhances overall performance and user experience, and enables seamless playback continuation.
Smart Images

Figure CN120980288A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of operating system technology, and in particular to a video playback method and related apparatus. Background Technology
[0002] Currently in HarmonyOS, when the content displayed in a video application changes, the player component within the video application needs to undergo a complete resource release and recreation process. This involves destroying the currently running player component and then building a new one to play the changed content. Frequent component creation and destruction leads to significant loading delays and unnecessary system resource overhead, especially on low-performance devices, where the resulting performance degradation is particularly pronounced, reducing playback smoothness and severely impacting user experience. Summary of the Invention
[0003] In view of the above problems, this application provides a video playback method and related apparatus to improve playback smoothness and reduce performance loss. The specific solution is as follows:
[0004] The first aspect of this application provides a video playback method, including:
[0005] Determine the content category and content display method of the content displayed on the current page of the application. The application includes at least a video application currently running on the terminal. The content category is used to indicate the type of video contained in the displayed content, and the content display method is used to indicate the screen ratio of the video.
[0006] Based on the correspondence between the content category, the content display method, and the player component reuse strategy, the target player component reuse strategy for the current page is determined. The player component reuse strategy is used to indicate the reuse method of the player component for the current page.
[0007] In response to the content switching operation on the current page, based on the target player component reuse strategy, the player component of the current page is invoked to play the target content, which is the content displayed after the content switching operation is performed.
[0008] In one possible implementation, responding to a content switching operation on the current page and, based on the target player component reuse strategy, invoking the player component of the current page to play the target content includes:
[0009] Check if the player component of the current page exists in the cache pool. If the player component of the current page exists, determine the player component of the current page based on the target player component reuse strategy, and call the player component of the current page to play the target content. The cache pool is created when the display content of the current page is switched, and the player component of the current page is stored.
[0010] In one possible implementation, when the content category is regular video, and the regular video includes at least short videos excluding news feeds, and the content display method is full-screen display, determining the player component of the current page based on the target player component reuse strategy and calling the player component of the current page to play the target content includes:
[0011] When the displayed content is switched off from the current page, the target player component in the cache pool is invoked to play the target content. The target player component is a player component with a reusable decorator added. The reusable decorator is used to indicate that the player component has reusable characteristics.
[0012] In one possible implementation, before invoking the player component of the current page to play the target content, the method further includes:
[0013] The lifecycle method of the reusable decorator is invoked to update the state data of the player component in order to connect to the playback of the target content. The lifecycle method is the lifecycle callback of the reusable decorator and is invoked before the target player component is invoked.
[0014] In one possible implementation, where the content category is an information stream, the content is displayed in a partial area of the full screen, the partial display of the full screen indicates that the screen occupancy of the displayed content is less than the full screen, and the content switching operation indicates that the information stream of the current page is being updated, the step of determining the player component of the current page based on the target player component reuse strategy and calling the player component of the current page to play the target content includes:
[0015] After unloading the node controller belonging to the current node container, it is mounted to the target node container. The current node container is the node container that wraps the player component, and the target node container is the player component container created based on the target content. The node controller is used to switch the membership relationship of the player components between node containers.
[0016] In one possible implementation, when the content category is an information stream, the content display method is displaying in a partial area of the full screen, and the content switching operation represents a full-screen display of the target information stream of the current page, determining the player component of the current page based on the target player component reuse strategy and calling the player component of the current page to play the target content includes:
[0017] After unloading the node controller belonging to the current node container, it is mounted to the target node container. The current node container is the node container that wraps the player component, and the target node container is the player component container created based on the full-screen page. The node controller is used to switch the membership relationship of the player components between node containers.
[0018] In one possible implementation, the video playback method further includes:
[0019] During the unloading and mounting process of the node controller, the current state information of the player component is saved so that playback can be resumed based on the current state information when the node controller is remounted.
[0020] In one possible implementation, the video playback method further includes:
[0021] The layout and size of the player component are adjusted accordingly based on the size of the target node container.
[0022] In one possible implementation, when the content category is navigation content, the navigation content includes at least the introductory content of multiple videos, the content is displayed in full-screen mode, and the content switching operation represents a switch of the navigation content of the current page, the step of determining the player component of the current page based on the target player component reuse strategy and calling the player component of the current page to play the target content includes:
[0023] The reference relationship of the player component is passed to the target page associated with the target content, and the page identifier of the page component used by the target page to display the video is mounted to the player component. The target page is the details page to which the target content is redirected after it is selected.
[0024] A third aspect of this application provides a video playback device, comprising:
[0025] The page content recognition module is used to determine the content category and content display method of the content displayed on the current page of the application. The application includes at least a video application currently running on the terminal. The content category is used to indicate the type of video contained in the displayed content, and the content display method is used to indicate the screen ratio of the video.
[0026] The reuse strategy determination module is used to determine the target player component reuse strategy for the current page based on the correspondence between the content category, the content display method, and the player component reuse strategy. The player component reuse strategy indicates how the player component on the current page is reused.
[0027] The video content playback module is used to respond to the content switching operation on the current page, and based on the target player component reuse strategy, call the player component of the current page to play the target content, which is the display content obtained after performing the content switching operation.
[0028] A third aspect of this application provides a computer program product including computer-readable instructions that, when executed on an electronic device, cause the electronic device to implement the video playback method described in the first aspect or any implementation thereof.
[0029] A fourth aspect of this application provides an electronic device, including at least one processor and a memory connected to the processor, wherein:
[0030] The memory is used to store computer programs;
[0031] The processor is used to execute the computer program so that the electronic device can implement the video playback method of the first aspect or any implementation thereof.
[0032] The fifth aspect of this application provides a computer storage medium carrying one or more computer programs, which, when executed by an electronic device, enable the electronic device to implement the video playback method described in the first aspect or any implementation thereof.
[0033] By employing the above technical solution, the video playback method provided in this application can determine the content category and display method of the content displayed on the current page of the video application during runtime. Based on this, a player component reuse strategy is determined according to the content category and display method. When a user switches content on the current page, the method can respond to this operation and, based on the player component reuse strategy, allocate the current page's player component to the target content obtained after the content switch. This enables the reuse of the current page's player component for video playback when the playback content on the current page changes, effectively reducing the repeated creation and destruction of player components, significantly improving the player's instant loading speed and overall performance, reducing system resource consumption, and enhancing the user experience. Attached Figure Description
[0034] The above and other features, advantages, and aspects of the embodiments of this disclosure will become more apparent from the accompanying drawings and the following detailed description. Throughout the drawings, the same or similar reference numerals denote the same or similar elements. It should be understood that the drawings are schematic, and the originals and elements are not necessarily drawn to scale.
[0035] Figure 1 A flowchart of a video playback method provided in this application;
[0036] Figure 2 A flowchart illustrating a player component reuse method provided in this application;
[0037] Figure 3 A flowchart illustrating another method for reusing a player component as provided in this application;
[0038] Figure 4 A flowchart illustrating another method for reusing a player component provided in this application;
[0039] Figure 5 A screenshot showing the current page of a video application provided in this application;
[0040] Figure 6 A screenshot showing the current page of another video application provided in this application;
[0041] Figure 7 A screenshot of the current page used for another video provided in this application;
[0042] Figure 8 A structural diagram of a video playback device provided in this application;
[0043] Figure 9 This is a structural diagram of an electronic device provided in this application. Detailed Implementation
[0044] The embodiments of this application are described below with reference to the accompanying drawings. The terminology used in the implementation section of this application is for explaining specific embodiments only and is not intended to limit the scope of this application.
[0045] The embodiments of this application will now be described with reference to the accompanying drawings. Those skilled in the art will recognize that, with technological advancements and the emergence of new scenarios, the technical solutions provided in the embodiments of this application are equally applicable to similar technical problems.
[0046] The terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such terms are interchangeable where appropriate; this is merely a way of distinguishing objects with the same attributes in the embodiments of this application. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion, so that a process, method, system, product, or apparatus that comprises a series of elements is not necessarily limited to those elements, but may include other elements not explicitly listed or inherent to those processes, methods, products, or apparatuses.
[0047] Existing player components often undergo a complete resource release and recreation process when switching scenes within an application. For example, in scenarios with multiple player instances on a list page, such as a feed, or when switching between a portrait playlist and a full-screen playback page, frequent component creation and destruction can lead to significant loading delays and unnecessary system resource overhead. This performance loss is particularly pronounced on low-performance devices, severely impacting the user experience.
[0048] To address the aforementioned problems, this application provides a video playback method. The video playback method of this application embodiment will be described in detail below with reference to the accompanying drawings.
[0049] Reference Figure 1 , Figure 1 This is a flowchart illustrating a video playback method provided in an embodiment of this application, such as... Figure 1 As shown in the embodiment of this application, a video playback method may include steps 101 to 103, which are described in detail below.
[0050] 101. Determine the content category and content display method of the content displayed on the current page of the application. The application includes at least the video application currently running on the terminal. The content category is used to indicate the type of video contained in the displayed content, and the content display method is used to indicate the screen ratio of the video.
[0051] Specifically, commonly used video applications include: short video applications, live streaming applications, and applications that include feed streams or video lists (such as news and information, video modules in social media, and e-commerce live streaming). These video applications typically contain a large amount of video content, and users switch between videos by swiping.
[0052] Video applications typically offer various content types, which users can usually select by swiping left or right. For example, a short video application might offer categories such as "Recommended," "Live," and "Featured," which users can choose from by swiping. When a category is selected for playback, the corresponding content display methods might include full-screen playback or playback of a portion of the full-screen area.
[0053] For example, refer to Figure 5 As shown, the video content in the video application 2 running on mobile terminal 1 is displayed in full-screen mode, meaning that only one video is playing in full-screen mode, and that video content fills the entire screen. For example, short video applications and live streaming applications running on smartphones and other terminals often contain full-screen content. When a user swipes to the recommendation or live streaming interface, the relevant video content will be displayed in full-screen mode. Users can change the content by swiping up or down. For example, swiping up updates unwatched content, removing the current video content and adding unwatched content. Swiping down removes the current video content and adds the previously watched video content.
[0054] For example, refer to Figure 6 As shown, multiple videos are displayed within a specific area of the screen within the video application. This means multiple videos are shown in a small window across the entire screen. For example, in short video apps, live streaming apps, and news apps, multiple videos appear as a list under options like "Content Discovery." Users can also update the content displayed by swiping up and down, thus updating the various discovered content on the screen.
[0055] Reference Figure 7 As shown, the current page of the video application is a navigation interface for multiple video content, displaying introductions to each video in a list format. When a user selects one to view, they are redirected to the video's details page, which is displayed in full-screen mode. For example, compared to short video applications, in video applications specifically designed for long videos, such as movie theater apps and educational courses, users will switch between different pages to watch videos and switch between portrait full-screen modes. Furthermore, users may select a video from the application's navigation page and click to view its detailed description.
[0056] In one possible implementation, the identification of the aforementioned content categories and display methods can be achieved by identifying the application type of the currently running video application. Based on this, the content currently displayed on the video application's interface is identified, and the content category and display method of the content displayed on the current interface are determined according to the correspondence with the content categories and display methods. It is understood that those skilled in the art can choose the identification methods as needed, and no limitations are imposed here.
[0057] It is understandable that the above content categories and display methods may be adjusted and selected according to different video applications, and will not be elaborated further here.
[0058] 102. Based on the correspondence between content category and content display method and player component reuse strategy, determine the target player component reuse strategy for the current page. The player component reuse strategy is used to indicate how the player component on the current page can be reused.
[0059] Specifically, compared to the traditional approach where changes to the displayed content of the current page require the player component to be released and recreated, this approach uses player component reuse. Instead of destroying the current player component when the displayed content changes due to user actions, a reuse strategy is determined based on the content category and display method of the current page. This is because the content category and display method of the current page necessitate the use of appropriate player component reuse strategies.
[0060] For example, when the content category is regular video (such as short videos, live videos, etc.) and the content is displayed in full-screen mode, if the content displayed on the current page changes, the player component that leaves the current visible area can be placed in the cache pool, waiting to be called. This cache pool can be a pre-allocated memory area in the system memory. When calling the player component, it will be searched first from this cache pool, allowing the corresponding player component to be retrieved directly from the cache pool.
[0061] For content categorized as a feed stream and displayed as a partial full-screen area—that is, when the feed stream is displayed as a small window on the current page—the player from the feed stream that is not visible on the current page is reused for the feed stream that enters the current page when the user swipes. When switching between the small window feed stream and the full-screen mode, the current player component is reused.
[0062] When the content is analogous to navigation content and is displayed in full-screen mode, the player component from the previous page is reused when navigating across pages on the current page.
[0063] It is understandable that the player component reuse strategies listed above can be applied in a one-to-many manner or in a one-to-one manner, without any restrictions.
[0064] 103. In response to the content switching operation on the current page, based on the target player component reuse strategy, the player component of the current page is called to play the target content, which is the content displayed after the content switching operation is performed.
[0065] Specifically, when a user swipes on the current page to update the displayed content, or clicks to switch between full-screen and small-window displays, the player component of the current page can be allocated to the switched target content based on the aforementioned target player component reuse strategy, thus displaying the content. It can be seen that this video playback method reuses the player component of the current page to play the video content when the playback content changes, allowing the current player component to be cached and reused. This avoids repeated creation and destruction processes, significantly improving the player's instant loading speed and overall performance, reducing system resource consumption, and ensuring the continuity of playback status during reuse, achieving seamless playback continuation. The performance improvement brought about by player component reuse can be monitored through indicators such as the instant playback duration, memory usage, and CPU utilization of the player component. The performance improvement can be verified by comparing it with a playback method that does not reuse the player component.
[0066] In one embodiment, as a specific implementation of step 103 above, in response to the content switching operation on the current page, based on the target player component reuse strategy, the player component of the current page is invoked to play the target content, which may specifically include the following processing steps:
[0067] Check if the player component for the current page exists in the cache pool. If it does, determine the player component for the current page based on the target player component reuse strategy, and call the player component for the current page to play the target content. The cache pool is created when the displayed content of the current page is switched, and the player component for the current page is stored therein.
[0068] Specifically, the cache pool can be a storage area allocated in the database or memory of the terminal system, dedicated to storing player components. Currently running player components are cached in the cache pool when not in use, rather than being immediately destroyed. When a new player component is needed, an existing player component will be retrieved from the cache pool for reuse.
[0069] The triggering mechanism for caching the currently running player component may include the above. Figures 5 to 7 The update of the currently playing content, as shown, triggers an update of the player component. This may also include other methods of updating playback content that cause the current player component to be destroyed and recreated; these are not limited here.
[0070] In one embodiment, when the content category is regular video, and regular video includes at least short videos excluding news feeds, and the content is displayed in full-screen mode, the aforementioned determination of the current page's player component based on the target player component reuse strategy, and the invocation of the current page's player component to play the target content, may specifically include:
[0071] When the content is switched from the current page, the target player component in the cache pool is called to play the target content. The target player component is a player component with a reusable decorator added. The reusable decorator is used to indicate that the player component has reusable characteristics.
[0072] Specifically, taking the HarmonyOS system running on smartphones, tablets, and other smart terminals as an example, when a short video is displayed on the current page and scrolls up and down for full-screen playback, the `@Reusable` decorator can be added to the player component class. This marks the player component with the `@Reusable` decorator, making it reusable. The working principle is as follows:
[0073] When a custom component marked with @Reusable (i.e., the player component) is removed from the component tree (e.g., when the user swipes on the current page, causing the video content to leave the visible area), the component and its corresponding JSView (JavaScript View refers to a component used to build and manage the user interface (UI)) object are not immediately destroyed. Instead, they are placed into a pre-defined reuse cache pool by the system. This process is a framework-level optimization, requiring no explicit management of the pooling logic by the developer.
[0074] The player component is reused in a pool: When the system needs to create a new custom component node of the same type (for example, when a new video enters the playback area of the current page), it will first check if an available component instance exists in the reuse cache pool. If it exists, the instance is retrieved directly from the cache pool for reuse, rather than creating a new component. This significantly saves time on component re-creation, thereby improving player loading performance.
[0075] In another embodiment, in order to enable the reused player component to adapt to new playback tasks, the state data of the player component can be updated by calling the lifecycle method of the reusable decorator to connect to the playback of the target content. The lifecycle method is the lifecycle callback of the reusable decorator, which is called before the target player component is invoked.
[0076] For example, the `aboutToReuse` lifecycle method is a lifecycle callback specific to player components marked with `@Reusable`. It is called before the component is retrieved from the reuse pool and prepared for reuse. The `aboutToReuse` lifecycle method performs data update operations on the player to adapt to new playback tasks, which may include:
[0077] Update the video URL (Uniform Resource Locator).
[0078] Update the player's initial playback progress (for resuming playback).
[0079] Update metadata related to the video content (such as title, cover, etc.).
[0080] To ensure the consistency of the entire player component and its internal state, the child components can be notified to update by passing new data or calling the child components.
[0081] The aboutToReuse lifecycle method can also reset critical states of the player component to minimize the impact of old task remnants on new tasks. For example, it can set the player to a stopped or paused state, clear previous buffered states, and display a message for any errors during the reset.
[0082] The `aboutToReuse` lifecycle method described above ensures more accurate transmission and restoration of the player component's current playback progress, volume, playback mode, and other state information. This allows for faster resume playback when the player component is reused, further enhancing the user experience. For example, when a user swipes through a short video and returns to the previously played video content, playback can resume from where it left off.
[0083] Furthermore, considering the memory cleanup operations that smart terminals may perform, some underlying resources associated with the player component (such as media playback engine instances, decoders, etc.) may be deleted. To avoid resource leaks and state conflicts, appropriate handling can be designed in the aboutToReuse lifecycle method. For example, if the video source encoding format is different when switching, it can be resolved by re-initializing the decoder.
[0084] In another embodiment, when the content category is an information stream, the content is displayed in a partial area of the full screen (meaning the displayed content occupies less than the full screen), and the content switching operation represents updating the information stream of the current page, the above-mentioned determination of the player component of the current page based on the target player component reuse strategy and invocation of the player component of the current page to play the target content may specifically include:
[0085] After unloading the node controller belonging to the current node container, it is mounted to the target node container. The current node container is the node container that wraps the player component, and the target node container is the player component container created based on the target content. The node controller is used to switch the membership relationship of the player component between node containers.
[0086] Specifically, taking the HarmonyOS operating system as an example, when laying out the interactive interface, in scenarios where the content of a feed stream is updated by swiping through it, the player component is placed as a child component into a NodeContainer. A NodeContainer is a container used to hold and manage NodeControllers.
[0087] When a user swipes through the feed on the current page, the player component is not destroyed when it leaves the page. Instead, it is unloaded from the current NodeContainer via a NodeController. When a new feed enters the visible area of the current page and needs to be played, the same NodeController is mounted to a new NodeContainer, thus transferring the current player component.
[0088] Similarly, in some embodiments, when the content category is an information stream, the content is displayed in a partial area of the full screen, and the content switching operation represents a full-screen display of the target information stream of the current page, the above-mentioned determination of the player component of the current page based on the target player component reuse strategy and invocation of the player component of the current page to play the target content may specifically include:
[0089] After unloading the node controller belonging to the current node container, it is mounted to the target node container. The current node container is the node container that wraps the player component, and the target node container is the player component container created based on the full-screen page. The node controller is used to switch the membership relationship of the player component between node containers.
[0090] Specifically, in scenarios where the state switches between a small window in the information stream and vertical full-screen playback, when a user clicks on a certain information stream to enter full-screen playback, the NodeController corresponding to the current player component can be passed to the full-screen page, and the NodeController can be populated (mounted) in the NodeContainer of the full-screen page, thereby reusing the current player component.
[0091] Similarly, when the information stream returns from the full-screen page to the small window for playback, the NodeController corresponding to the current player component can be passed to the small window page, and the NodeController can be populated (mounted) in the NodeContainer of the small window page, thereby reusing the current player component.
[0092] In one embodiment, to achieve seamless playback during switching, the current state information of the player component is saved during the unloading and mounting of the node controller. This allows for faster replay when the node controller is remounted, based on the current state information.
[0093] Furthermore, due to the size limitations of the player component, when the information stream switches between full-screen and small window modes, the layout of the player component is adjusted accordingly based on the layout information of the target node container. That is, the layout and size of the player component are adjusted based on the size of the NodeContainer to ensure that the player component can adapt to the content playback of the page after the switch.
[0094] When adjusting the layout and size of the player component according to the size of the target node container, you can place the player component in the created container and bind the position and size of the player component to the size of the container. This way, the control bar of the player component can be placed at the bottom of the container. When the size of the container changes, the control bar remains at the bottom, leaving the remaining space for the player component to adjust its size.
[0095] It is understood that those skilled in the art can also use other well-known technical means to adjust the form of the player components, and no restrictions are imposed here.
[0096] In some embodiments, when the content category is navigation content, the navigation content includes at least the introductory content of multiple videos, the content is displayed in full screen, and the content switching operation represents a switch of the navigation content of the current page, the above-mentioned determination of the player component of the current page based on the target player component reuse strategy and invocation of the player component of the current page to play the target content may specifically include:
[0097] The player component reference is passed to the target page associated with the target content, and the page identifier of the page component used by the target page to display the video is attached to the player component. The target page is the details page that the target content is redirected to after it is selected.
[0098] Specifically, when a user navigates between related full-screen pages, such as from a list page to a details page in full-screen playback mode, the player component of the current page is not destroyed. Instead, a reference to the current player component is passed to the target page through parameter passing or sharing mechanisms between pages. This player component can be a globally accessible singleton class for managing player instances. When reusing the player component, after obtaining the player component instance from the target page (i.e., the current page), the surfaceId (page identifier) or related handle of the Surface component used to display the video on the new page is attached to the reused player instance, enabling it to display the video on the new page.
[0099] The reuse of the player component between the aforementioned full-screen pages can also be achieved using the above-mentioned method of mounting / unmounting node containers and node controllers, and there are no restrictions on this.
[0100] As a specific implementation method for reusing the aforementioned player components, refer to Figure 2 As shown, when a player component is removed from the component tree, player components marked with @Reusable enter the reuse cache pool, while player components that are not marked will be destroyed.
[0101] Specifically, when a user switches video content on the current page, the terminal operating system removes player components from the component tree. Player components marked with `@Reusable` are placed in the reuse cache pool, while those without `@Reusable` are destroyed. When a playback task exists on the current page and a new player component is needed, the system checks if the corresponding player component exists in the reuse cache pool. If a player component is found, the `aboutToReuse` lifecycle method is called to update the player component's state, and then the playback content is rendered on that player component. If the corresponding player component is not found in the cache pool due to system space cleanup or other reasons, a new player component instance can be created before subsequent video content playback can proceed.
[0102] Reference Figure 3 As shown, for the reuse of the player component in the information stream, refer to... Figure 3 As shown on the left, when a user swipes through the information stream displayed on the current page, if an information stream leaves the current page (i.e., its corresponding player component leaves the current visible area), the player component is not destroyed. Instead, it is unloaded from the current NodeContainer via NodeController. When a new information stream enters the visible area and requires the player component to play, the same NodeController is mounted to a new NodeContainer to achieve player component reuse.
[0103] Reference Figure 3 As shown on the right, when switching between full-screen and small window, when the information stream switches from small window to full-screen playback, the NodeController held by the player component of the current page is passed to the full-screen page, and the NodeController is populated in the NodeContainer of the full-screen page. The size of the player component is adjusted according to the size of the NodeContainer to make it suitable for the playback of full-screen content, thereby reusing the player component instance.
[0104] Reference Figure 4 As shown, when a user navigates from one page to another (for example, from a list page to a full-screen detail page), the current player instance is not destroyed. Instead, a reference to the global singleton player instance is passed to the target page through inter-page parameter passing, route passing, or shared state management mechanisms.
[0105] Specifically, a globally accessible singleton class is created to manage the player component. During page navigation, a reference to the player component instance is passed, enabling the player component to be reused. When a user navigates from one page to another (e.g., from a list page to a full-screen details page), the current player instance is not destroyed. Instead, the reference to this global singleton player component instance is passed to the target page through inter-page parameter passing, route passing, or shared state management mechanisms. The surfaceId of the new control is then attached to the reused player component instance.
[0106] For example in Figure 4 In page A, after obtaining the passed player instance reference, the surfaceId or related handle of the Surface component used to display the video in the new page B is attached to this reused, unique player instance, making it a player component belonging to page B, thus enabling the video to be displayed in the new page B. To improve the continuity of video playback when switching player components, the playback status of the video content on the player component is monitored, and pause and fast-forward operations are recorded, thereby improving the seamless continuation of playback after page switching.
[0107] In other embodiments, to further enhance the user experience, the system can predict which videos the user might watch when switching between devices, and reuse and initialize the player in the background in advance, further shortening the playback time. This ensures smooth playback even on low-end devices and in weak network environments. The cache pool can also be dynamically adjusted in size and recycling strategy based on the complexity of the video application scenario and the resource availability of smart devices to maximize resource utilization and avoid resource waste or shortage in extreme cases.
[0108] The above describes a video playback method provided by an embodiment of this application. The following describes an apparatus for performing the above video playback method.
[0109] Please see Figure 8 , Figure 8 This is a schematic diagram of the structure of a video playback device provided in an embodiment of this application. Figure 8 As shown, the video playback device includes:
[0110] The page content recognition module 801 is used to determine the content category and content display method of the content displayed on the current page of the application. The application includes at least the video application currently running on the terminal. The content category is used to indicate the type of video contained in the displayed content, and the content display method is used to indicate the screen ratio of the video.
[0111] The reuse strategy determination module 802 is used to determine the target player component reuse strategy for the current page based on the correspondence between content category and content display method and player component reuse strategy. The player component reuse strategy indicates how the player component on the current page is reused; and...
[0112] The video content playback module 803 is used to respond to the content switching operation on the current page. Based on the target player component reuse strategy, it calls the player component of the current page to play the target content, which is the content displayed after the content switching operation is performed.
[0113] In one possible implementation, the video content playback module 803, in response to a content switching operation on the current page, calls the player component of the current page to play the target content based on a target player component reuse strategy. This process includes:
[0114] Check if the player component for the current page exists in the cache pool. If it does, determine the player component for the current page based on the target player component reuse strategy, and call the player component for the current page to play the target content. The cache pool is created when the displayed content of the current page is switched, and the player component for the current page is stored therein.
[0115] In one possible implementation, when the content category is regular video, which includes at least short videos excluding news feeds, and the content display method is full-screen display, the video content playback module 803 determines the player component of the current page based on the target player component reuse strategy, and calls the player component of the current page to play the target content. This process includes:
[0116] When the content is switched from the current page, the target player component in the cache pool is called to play the target content. The target player component is a player component with a reusable decorator added. The reusable decorator is used to indicate that the player component has reusable characteristics.
[0117] In one possible implementation, before invoking the player component of the current page to play the target content, the video content playback module 803 is also used for:
[0118] The lifecycle methods of the reusable decorator are called to update the state data of the player component in order to connect to the playback of the target content. The lifecycle methods are the lifecycle callbacks of the reusable decorator and are called before the target player component is invoked.
[0119] In one possible implementation, when the content category is an information stream, the content is displayed in a partial area of the full screen (meaning the displayed content occupies less than the full screen), and the content switching operation represents an update to the information stream of the current page, the video content playback module 803 determines the player component of the current page based on the target player component reuse strategy and calls the player component of the current page to play the target content. This process includes:
[0120] After unloading the node controller belonging to the current node container, it is mounted to the target node container. The current node container is the node container that wraps the player component, and the target node container is the player component container created based on the target content. The node controller is used to switch the membership relationship of the player component between node containers.
[0121] In one possible implementation, when the content category is an information stream, the content is displayed in a partial area of the full screen, and the content switching operation represents a full-screen display of the target information stream on the current page, the video content playback module 803 determines the player component of the current page based on the target player component reuse strategy, and calls the player component of the current page to play the target content. This process includes:
[0122] After unloading the node controller belonging to the current node container, it is mounted to the target node container. The current node container is the node container that wraps the player component, and the target node container is the player component container created based on the full-screen page. The node controller is used to switch the membership relationship of the player component between node containers.
[0123] In one possible implementation, the video content playback module 803 is also used for:
[0124] During the unloading and mounting of the node controller, the current state information of the player component is saved so that playback can resume based on the current state information when the node controller is remounted.
[0125] In one possible implementation, the video content playback module 803 is also used for:
[0126] Adjust the layout and size of the player component accordingly based on the size of the target node container.
[0127] In one possible implementation, when the content category is navigation content, the navigation content includes introductions to at least several videos, the content is displayed in full-screen mode, and the content switching operation represents a switch of the navigation content on the current page, the video content playback module 803 determines the player component of the current page based on the target player component reuse strategy, and calls the player component of the current page to play the target content. This process includes:
[0128] The player component's reference relationship is passed to the target page associated with the target content, and the page identifier of the page component used by the target page to display the video is attached to the player component. The target page is the details page that the target content is redirected to after it is selected.
[0129] This application also provides an electronic device in its embodiments. (See reference...) Figure 9 The diagram illustrates a structural schematic suitable for implementing the electronic device in the embodiments of this application. The electronic device in the embodiments of this application may include, but is not limited to, fixed terminals such as mobile phones, laptops, PDAs (personal digital assistants), PADs (tablet computers), desktop computers, etc. Figure 9 The electronic device shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments of this application.
[0130] like Figure 9 As shown, the electronic device may include a processing unit (e.g., a central processing unit, a graphics processing unit, etc.) 901, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 902 or a program loaded from a storage device 908 into a random access memory (RAM) 903. When the electronic device is powered on, the RAM 903 also stores various programs and data required for the operation of the electronic device. The processing unit 901, ROM 902, and RAM 903 are interconnected via a bus 904. An input / output (I / O) interface 905 is also connected to the bus 904.
[0131] Typically, the following devices can be connected to I / O interface 905: input devices 906 including, for example, touchscreens, touchpads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; output devices 907 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 908 including, for example, memory cards, hard drives, etc.; and communication devices 909. Communication device 909 allows electronic devices to exchange data via wireless or wired communication with other devices. Although Figure 9 Electronic devices with various devices are shown, but it should be understood that it is not required to implement or have all of the devices shown. More or fewer devices may be implemented or have alternatively.
[0132] This application also provides a computer program product including computer-readable instructions, which, when executed on an electronic device, cause the electronic device to implement any of the video playback methods provided in this application.
[0133] This application also provides a computer-readable storage medium that carries one or more computer programs. When the one or more computer programs are executed by an electronic device, the electronic device can implement any of the video playback methods provided in this application.
[0134] It should also be noted that the device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. In addition, in the device embodiment drawings provided in this application, the connection relationship between modules indicates that they have a communication connection, which can be implemented as one or more communication buses or signal lines.
[0135] Through the above description of the embodiments, those skilled in the art can clearly understand that this application can be implemented by means of software plus necessary general-purpose hardware, or it can be implemented by special-purpose hardware including application-specific integrated circuits, special-purpose CPUs, special-purpose memory, special-purpose components, etc. Generally, any function performed by a computer program can be easily implemented by corresponding hardware, and the specific hardware structure used to implement the same function can also be diverse, such as analog circuits, digital circuits, or special-purpose circuits. However, for this application, software program implementation is more often the preferred implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a readable storage medium, such as a computer floppy disk, USB flash drive, mobile hard disk, ROM, RAM, magnetic disk, or optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, training equipment, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0136] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product.
[0137] 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 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. For example, the computer instructions may be transmitted from one website, computer, training device, or data center to another website, computer, training device, 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 may be any available medium that a computer can store or a data storage device such as a training device or data center that integrates one or more available media. The available media may be magnetic media (e.g., floppy disks, hard disks, magnetic tapes), optical media (e.g., DVDs), or semiconductor media (e.g., solid-state drives (SSDs)).
Claims
1. A video playback method, characterized in that, include: Determine the content category and content display method of the content displayed on the current page of the application. The application includes at least a video application currently running on the terminal. The content category is used to indicate the type of video contained in the displayed content, and the content display method is used to indicate the screen ratio of the video. Based on the correspondence between the content category, the content display method, and the player component reuse strategy, the target player component reuse strategy for the current page is determined. The player component reuse strategy is used to indicate the reuse method of the player component for the current page. In response to the content switching operation on the current page, based on the target player component reuse strategy, the player component of the current page is invoked to play the target content, which is the content displayed after the content switching operation is performed.
2. The video playback method according to claim 1, characterized in that, The response to the content switching operation on the current page, based on the target player component reuse strategy, involves calling the player component of the current page to play the target content, including: Check if the player component of the current page exists in the cache pool. If the player component of the current page exists, determine the player component of the current page based on the target player component reuse strategy, and call the player component of the current page to play the target content. The cache pool is created when the display content of the current page is switched, and the player component of the current page is stored.
3. The video playback method according to claim 2, characterized in that, When the content category is regular video, and the regular video includes at least short videos excluding news feeds, and the content display method is full-screen display, determining the player component of the current page based on the target player component reuse strategy and calling the player component of the current page to play the target content includes: When the displayed content is switched off from the current page, the target player component in the cache pool is invoked to play the target content. The target player component is a player component with a reusable decorator added. The reusable decorator is used to indicate that the player component has reusable characteristics.
4. The video playback method according to claim 3, characterized in that, Before invoking the player component of the current page to play the target content, the method further includes: The lifecycle method of the reusable decorator is invoked to update the state data of the player component in order to connect to the playback of the target content. The lifecycle method is the lifecycle callback of the reusable decorator and is invoked before the target player component is invoked.
5. The video playback method according to claim 2, characterized in that, When the content category is information feed, the content display method is displaying in a partial area of full screen, where the partial display of full screen indicates that the screen occupancy of the displayed content is less than the full screen, and the content switching operation indicates updating the information feed of the current page, the step of determining the player component of the current page based on the target player component reuse strategy and calling the player component of the current page to play the target content includes: After unloading the node controller belonging to the current node container, it is mounted to the target node container. The current node container is the node container that wraps the player component, and the target node container is the player component container created based on the target content. The node controller is used to switch the membership relationship of the player components between node containers.
6. The video playback method according to claim 2, characterized in that, When the content category is an information stream, the content display method is a partial display in a full-screen area, and the content switching operation represents a full-screen display of the target information stream of the current page, the step of determining the player component of the current page based on the target player component reuse strategy and calling the player component of the current page to play the target content includes: After unloading the node controller belonging to the current node container, it is mounted to the target node container. The current node container is the node container that wraps the player component, and the target node container is the player component container created based on the full-screen page. The node controller is used to switch the membership relationship of the player components between node containers.
7. The video playback method according to claim 5 or 6, characterized in that, Also includes: During the unloading and mounting process of the node controller, the current state information of the player component is saved so that playback can be resumed based on the current state information when the node controller is remounted.
8. The video playback method according to claim 6, characterized in that, Also includes: The layout and size of the player component are adjusted accordingly based on the size of the target node container.
9. The video playback method according to any one of claims 2 to 8, characterized in that, When the content category is navigation content, the navigation content includes introductions to at least several videos, the content is displayed in full-screen mode, and the content switching operation represents a switch of the navigation content on the current page, the step of determining the player component of the current page based on the target player component reuse strategy and calling the player component of the current page to play the target content includes: The reference relationship of the player component is passed to the target page associated with the target content, and the page identifier of the page component used by the target page to display the video is mounted to the player component. The target page is the details page to which the target content is redirected after it is selected.
10. A video playback device, characterized in that, include: The page content recognition module is used to determine the content category and content display method of the content displayed on the current page of the application. The application includes at least a video application currently running on the terminal. The content category is used to indicate the type of video contained in the displayed content, and the content display method is used to indicate the screen ratio of the video. The reuse strategy determination module is used to determine the target player component reuse strategy for the current page based on the correspondence between the content category, the content display method, and the player component reuse strategy. The player component reuse strategy indicates how the player component on the current page is reused. The video content playback module is used to respond to the content switching operation on the current page, and based on the target player component reuse strategy, call the player component of the current page to play the target content, which is the display content obtained after performing the content switching operation.
11. A computer program product, characterized in that, It includes computer-readable instructions that, when executed on an electronic device, cause the electronic device to implement the video playback method as described in any one of claims 1 to 9.
12. An electronic device, characterized in that, It includes at least one processor and a memory connected to the processor, wherein: The memory is used to store computer programs; The processor is used to execute the computer program to enable the electronic device to implement the video playback method as described in any one of claims 1 to 9.
13. A computer storage medium, characterized in that, The storage medium carries one or more computer programs that, when executed by an electronic device, enable the electronic device to implement the video playback method as described in any one of claims 1 to 9.