List video playing method, terminal and storage medium

By monitoring the list scrolling status in the Android system terminal and replacing the cover placeholder of the list subitem with the global video player, the waste of system resources caused by frequent creation and destruction of video players is solved, improving performance and saving power.

CN119071575APending Publication Date: 2024-12-03CHENGDU CELIS TECH CO LTD

Patent Information

Application Number
CN202411479779.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-23
Publication Date
2024-12-03

AI Technical Summary

Technical Problem

In applications on Android system terminals, multiple video player instances need to be created and destroyed when sliding the list frequently, resulting in high system resource overhead, fast power consumption and serious heating.

Method used

By listening to the scrolling status of the list, determine the position of the target list child and replace its cover placeholder with a global video player. Only one global player is used to play videos of different child items in the list, reducing the video player object's Create and destroy.

Benefits of technology

It effectively reduces the frequency of creating and destroying video player objects, improves terminal performance, saves power and reduces heating problems.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119071575A_ABST
    Figure CN119071575A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of video processing, in particular to a list video playing method, a terminal and a storage medium. The method comprises the following steps: monitoring a rolling state of a list on a page; when it is monitored that the list stops rolling, determining a target position of a target list subitem of a video needing to be played in a current page; replacing the cover placeholder map of the target list subitem with a global video player according to the target position; and playing the video in the target list subitem by adopting the global video player. According to the method, all videos in the list are played through the global video player, so that creation and destruction of video player objects are reduced, and the terminal performance is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of video processing technology, and more particularly to a method, a terminal and a storage medium for playing list videos. Background Art

[0002] In the application App of Android terminal, there are often community-related function modules involved. The homepage of the community module is generally a list that can be slid up and down. As the community content becomes richer and richer, the list may include videos. When the user slides the list, the video content needs to be played on the screen.

[0003] Currently, when the list is scrolled frequently, multiple video player instances need to be loaded into the memory, and the memory will frequently create and destroy the player instances. When there is too much memory overhead, or the video player instances are frequently created and destroyed, the system resource overhead will increase, causing the terminal to consume power quickly and heat up severely.

[0004] In view of this, the present application provides a method, terminal and storage medium for playing list videos. Summary of the invention

[0005] In order to reduce terminal memory overhead and save terminal power, the present application provides a method, terminal and storage medium for playing list videos.

[0006] In order to achieve the above objectives, this application adopts the following technical solutions: In a first aspect, the present application provides a method for playing a list video, comprising: Monitor the scrolling status of the list on the page; When it is detected that the list stops scrolling, the target position of the target list sub-item on the current page where the video needs to be played is determined; According to the target position, the cover placeholder of the target list sub-item is replaced with a global video player; The global video player is used to play the video in the target list sub-item.

[0007] In a second aspect, the present application provides a terminal, including: at least one processor, and a memory communicatively coupled to at least one of the processors; The memory stores instructions that can be executed by at least one of the processors, and the instructions are executed by at least one of the processors so that at least one of the processors can execute the above-mentioned method for playing list videos.

[0008] In a third aspect, the present application provides a computer-readable storage medium having computer instructions stored thereon, and the computer instructions can be executed by one or more processors to implement the above-mentioned method for playing list videos.

[0009] This application includes at least the following beneficial effects: This application obtains the position of the list sub-item by monitoring the scrolling state of the list, and replaces the cover placeholder in the target list sub-item with a global video player, so that only one global player is used to play the videos of different list sub-items in the list, reducing the creation and destruction of video player objects to improve performance. This application does not need to set a video player in the view of each list sub-item, but uses a global video player to replace the cover placeholder in the target list sub-item that needs to play the video, thereby avoiding frequent creation and destruction of player instances and improving terminal performance. BRIEF DESCRIPTION OF THE DRAWINGS

[0010] In order to more clearly illustrate the specific implementation methods of the present application or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0011] Figure 1 It is a flowchart of a method for playing a list video provided in an embodiment of the present application; Figure 2 This is a schematic diagram of a page provided in an embodiment of the present application; Figure 3 This is a schematic diagram of a process for determining a target location provided in an embodiment of the present application; Figure 4 It is a flowchart of a method for replacing a global video player provided in an embodiment of the present application; Figure 5 It is a flowchart of another method for playing list videos provided in an embodiment of the present application; Figure 6 is a schematic diagram of the structure of a terminal provided in an embodiment of the present application; Figure 7 is a schematic diagram of the structure of another terminal provided in an embodiment of the present application; Among them, 10-target list sub-item, 11-video cover, 12-icon, 13-text, 14-cover placeholder, 20-page, 301-processor, 302-memory, 303-input device, 304-output device. DETAILED DESCRIPTION

[0012] The following is a description of exemplary embodiments of the present application in conjunction with the accompanying drawings, including various details of the embodiments of the present application to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the present application. Similarly, for the sake of clarity and conciseness, the description of well-known functions and structures is omitted in the following description.

[0013] The embodiment of the present application provides a method for playing a list video, which is applicable to the scenario of playing and displaying videos in list form on a terminal. The user can scroll the list on the terminal screen to watch videos of different list items. Optionally, the method provided in this embodiment is executed by a terminal equipped with an Android application, which can be a portable terminal such as a mobile phone, a smart watch, a tablet computer (PAD), a personal digital assistant (PDA), or a vehicle-mounted terminal, a vending machine, a consultation display machine, a large visual screen, etc.

[0014] It should be noted that the method provided in this embodiment is not only applicable to the Android operating system, but also to other existing operating systems or operating systems that will appear in the future.

[0015] See also Figure 1 , the present application provides a method for playing a list video, comprising: S110: Monitor the scrolling status of the list on the page.

[0016] In this embodiment, the list control of the activity page (Activity) can be a cyclic recycling view RecyclerView. RecyclerView is a container that is used to display a list (list) format and is a slidable list control provided by the Android system. When the list slides, only a small number of adjacent views are actually displayed on the screen. When the view slides out of the screen, RecyclerView reuses the slid-out view and fills it with new data. Since it recycles the existing structure instead of continuously creating new list items, it can effectively improve the time efficiency and space efficiency of the application.

[0017] Optionally, in the Android system, call the "add scroll listener" method of the list control RecyclerView object in advance: public void addOnScrollListener(@NonNull OnScrollListener listener) to listen to the scrolling of the list control. Pre-override the "scroll state change" method override funonScrollStateChanged(recyclerView: RecyclerView, newState: Int). The overridden method will be called back when the scroll state of the list changes. During the callback, you can judge the scroll direction of the RecyclerView and whether it has reached the critical point. When the critical point is reached, you can load the next page of paging data. Override is a concept in object-oriented programming that allows subclasses to change the implementation of methods inherited by parent classes.

[0018] The return values ​​of the scroll status include the following: public static final int SCROLL_STATE_IDLE = 0; Static state without scrolling; public static final int SCROLL_STATE_DRAGGING = 1; The screen is being dragged externally, usually when the user is scrolling with a finger; public static final int SCROLL_STATE_SETTLING = 2; Automatic scrolling; newState is the scroll state variable of recyclerView, and the return value of the scroll state will be assigned to newState. When the value of newState is 0, that is, public static final int SCROLL_STATE_IDLE = 0, it means that the current list has stopped scrolling, and the target position determination operation of the target list item that needs to play the video is executed. If it is not 0, continue to monitor the scroll state of the list.

[0019] S120: When it is detected that the list stops scrolling, a target position of a target list sub-item on the current page where a video needs to be played is determined.

[0020] The list includes multiple list sub-items arranged along a certain direction, and each list sub-item includes any one of text, picture and video, or a combination of two or more. Optionally, the list includes multiple list sub-items arranged vertically, or multiple list sub-items arranged horizontally. Figure 2is a schematic diagram of a page provided by an embodiment of the present application. Page 20 includes a fully displayed list sub-item, referred to as a target list sub-item 10. The cover placeholder image 14 in the target list sub-item 10 is fully displayed on page 20, and there is no situation where part of the cover placeholder image exceeds page 20. In addition, the target list sub-item 10 may also include text 13. In fact, when the cover placeholder image 14 is fully displayed on page 20, the user's line of sight is most likely focused on the cover placeholder image 14. If the user wants to play the video, it is necessary to select this target list sub-item 10 to play the video. See Figure 2 The cover placeholder image 14 includes a video cover 11 and an icon 12 on the video cover 11 for indicating a play button. Figure 2 When the video needs to be played, the video frame should replace the cover placeholder image 14, so as to present the video to the user.

[0021] For the convenience of description and distinction, the position of the target list item in the current page is called the target position, which can be represented by the distance from the end point of the page or by the position index number of the list item in the RecyclerView.

[0022] S130. According to the target position, the cover placeholder image of the target list sub-item is replaced with the global video player.

[0023] In RecyclerView, the scope of the adapter is the entire list, not a single list item. This means that although RecyclerView can display multiple different types of list items, these list items share the same adapter. Each list item has a corresponding list item view, which together constitute the layout file of the adapter. In other words, the view of the list item is a part of the view in the layout file of the list's adapter. The view of the list item includes a cover placeholder that needs to be displayed, and may also include user avatars, nicknames, pictures and texts of post content, etc. This embodiment needs to obtain the view of the target list item according to the target position, and replace the cover placeholder with a global video player in the view of the target list item. The global video player is a player that can be used for all list items in the list that need to play videos during page scrolling.

[0024] When the list continues to scroll and then stops, the target position of the new target list item in the current page can be determined, so that the cover placeholder image is replaced with the global video player in the view of the new target list item. Similarly, as the list continues to scroll and stop, this global video player is used to achieve video playback for all list items.

[0025] S140: Use a global video player to play the video in the target list sub-item.

[0026] Use the global video player to call its playback module and set the video link for the video player. Then, call the preparation method of the global video player, and then call the play method of the global video player. The video will automatically play after rendering successfully.

[0027] This embodiment monitors the scrolling state of the list, obtains the position of the list sub-item, and replaces the cover placeholder in the target list sub-item with a global video player, so that only one global player is used to play the videos of different list sub-items in the list, reducing the creation and destruction of video player objects to improve performance. This application does not need to set a video player in each list sub-item view, but uses a global video player to replace the cover placeholder in the target list sub-item with a video playback demand, thereby avoiding frequent creation and destruction of player instances and improving terminal performance.

[0028] Based on the above embodiment, this embodiment refines the process of determining the target position. Optionally, when the list stops scrolling, the first position of the visible list sub-item at the top and the second position of the visible list sub-item at the bottom of the current page are searched; each list sub-item is traversed from the first position to the second position; when each list sub-item is traversed, it is determined whether to determine it as the target list sub-item based on whether each list sub-item meets the playback requirements: including the video and the cover placeholder is completely visible, and the global video player is used to play the video in the target list sub-item.

[0029] For some examples, see Figure 3 , when the list stops scrolling, determine the target position of the target list item that needs to play the video on the current page, including the following operations: S210: When it is detected that the list stops scrolling, find the first position of the top visible list item and the second position of the bottom visible list item in the current page.

[0030] Optionally, taking the Android system as an example, call the "Find First Visible Item Position" method public int findFirstVisibleItemPosition() in the layout manager of the list control RecyclerView object to obtain the position of the top visible list item that appears on the current page. It is an integer value, which represents the position index number of the list item in RecyclerView. For example, if findFirstVisibleItemPosition() returns a value of 3, it means that in the layout of RecyclerView, the fourth item from the top is the top visible list item. This position index starts from 0, that is, index 0 represents the first position, index 1 represents the second position, and so on. Here, the position of the top visible list item is called the first position.

[0031] Call the "find the last visible item position" method public int findLastVisibleItemPosition() in the layout manager of the list control RecyclerView object. The findLastVisibleItemPosition() method is used to obtain the position of the last visible item. This position is calculated based on the current layout state of RecyclerView. If the content of RecyclerView exceeds one screen, the position returned by this method will be the position of the last fully visible item. By calling the "find the last visible item position" method, the position of the last subitem of the list that appears on the current page is obtained, that is, the position of the bottom visible list subitem, which is called the second position. The second position is also represented by an integer value as the position index number in RecyclerView.

[0032] S220, traverse each list item from the first position to the second position.

[0033] There is at least one list item between the first position and the second position.

[0034] S230, determine whether the first list sub-item traversed includes a video, and determine whether the cover placeholder of the first list sub-item is completely visible. If the data object in the traversed first list sub-item includes a video, and the cover placeholder of the first list sub-item is completely visible, execute S240, i.e., determine the target list sub-item and the target position; otherwise, execute S250, i.e., determine whether all list sub-items between the first position and the second position have been traversed. The first list sub-item is any list sub-item from the first position to the second position.

[0035] Determining whether the data object in the first list item traversed includes a video includes the following operations: First, using the layout manager object of the list control to call the "find sub-item view by position" method public ViewfindViewByPosition(int position) to obtain the view of the list item at the current traversal position, and obtain the data object in the view through the adapter object of the list control. Then, determine whether the current data object includes a video. The terminal needs to agree with the server in advance on setting fields or setting format links. If the data object includes a setting field or a setting format link, it is considered that the current data object includes a video; otherwise, it does not include a video.

[0036] Determining whether the cover placeholder of the list sub-item is completely visible includes: determining the visible area of ​​the cover placeholder of the first list sub-item, and determining the respective heights of the cover placeholder and the visible area; when the height of the cover placeholder is consistent with the height of the visible area, determining that the cover placeholder of the first list sub-item is completely visible. In some examples, first, obtain the view object of the cover placeholder; call the method of getting the visible rectangle through the view object to obtain the visible area of ​​the cover placeholder; call the "find by id" method findViewById(@IdRes int id) of the view object of the list sub-item to obtain the view object of the cover placeholder; call the "get visible rectangle" method public final boolean getLocalVisibleRect(Rect r) of the cover placeholder object through the view object, pass in a rectangle object, and the visible area of ​​the cover placeholder view object will be saved in the rectangle object, and the rectangle object provides the position attributes of the four vertices of top, bottom, left and right. Then, call the "get height" method public final intgetHeight() through the view object of the cover placeholder to obtain the height of the cover placeholder. Finally, based on whether the height of the cover placeholder is consistent with the height of the visible area, determine whether the cover placeholder of the list item is completely visible. Subtract the upper position attribute from the lower position attribute of the rectangle object to get the height of the rectangle (i.e., the visible area); determine whether the height of the rectangle is equal to the height of the cover placeholder. If the height of the rectangle is equal to the height of the cover placeholder, it means that the cover placeholder is completely visible and does not exceed the screen. Otherwise, it means that the cover placeholder is not completely visible.

[0037] S240: Determine the list sub-item as a target list sub-item, and determine a target position of the target list sub-item. Then proceed to S250.

[0038] S250: Determine whether all list items between the first position and the second position have been traversed. If not, return to S220 to perform the traversal operation of the next list item; if yes, execute S260: end the operation.

[0039] If the data objects in the traversed list sub-item include videos, and the cover placeholder of the list sub-item is completely visible, it means that the current traversed position is the position where the video is to be played. The current traversed position (i.e., the position index number of the aforementioned list sub-item) is assigned to the temporary variable "target position". This embodiment pre-sets a global variable "play position" to indicate the position of the video playback in the list, that is, the nth list sub-item in the list, and the initial value is -1. After the traversal is completed, the value of the "target position" is assigned to the global variable "play position".

[0040] It should be noted that there may be multiple target list sub-items on the current page, and the video of the top target list sub-item will be played first. When the video of the target list sub-item is finished playing, if the page has not been scrolled, and the next list sub-item is also a target list sub-item that needs to play a video, the video of the next target list sub-item will continue to be played automatically. In some examples, when it is monitored that the video of the target list sub-item has been played and the list has not been scrolled, in the next target list sub-item view of the current page, the cover placeholder is replaced with the global video player; the global video player is used to play the video in the next target list sub-item.

[0041] This embodiment searches for the first position and the second position and traverses between the two positions to accurately find the target position of the target list sub-item that needs to play the video. Further, by calling the method for obtaining the visible rectangle and the method for obtaining the height, it is determined whether the cover placeholder is completely visible.

[0042] Based on the above embodiments, this embodiment further refines the replacement process and removal process of the global video player. Figure 4 , according to the target position of the target list item, the cover placeholder image of the target list item is replaced with the global video player, including the following steps: S310. According to the target position of the target list item, search for the view holder object of the list at the target position.

[0043] S320. Call the view property of the list sub-item in the view holder object to obtain the view of the target list sub-item; the view of the target list sub-item includes a cover placeholder image.

[0044] S330. According to the layout parameters of the cover placeholder image, in the view of the target list sub-item, the cover placeholder image is replaced with the global video player.

[0045] It should be noted that in order to improve the reliability of programming, S310~S320 can be encapsulated as a method "Replace Video Player", so that the "Replace Video Player" method can be directly called to achieve the replacement of the global video player. Predefine a global variable: Whether the video player has been replaced. This variable is used to indicate whether the global video player has been replaced in the view of the target list sub-item. Variable value: false represents no, and variable value true represents yes. In the "Replace Video Player" method, first determine whether the value of the global variable: Whether the video player has been replaced is false. If it is true, it means that the global video player has been replaced, and there is no need to replace it again. The global video player is directly used to play the video in the target list sub-item. If it is false, execute S310~S330.

[0046] Optionally, when performing the operation of finding the view holder object of the list at the target position according to the target position of the target list subitem, use the list control to call its "find view holder according to position" method publicViewHolder findViewHolderForAdapterPosition(int position), where position is the aforementioned target position. This method returns the view holder object of the list at the target position.

[0047] When the view property of the list item in the view holder object is called to obtain the view of the target list item, the view of the target list item is stored in the view holder object, that is, the view of the layout file of the adapter. By calling the view property of the list item in the view holder object, the view of the target list item is obtained.

[0048] When replacing the cover placeholder with the global video player in the view of the target list item according to the layout parameters of the cover placeholder, first, directly call the system's "find view by id" method findViewById(R.id.iv_video_cover) through the view of the target list item to obtain the cover placeholder. Because the global video player is to be added at the position of the cover placeholder, the size of the global video player needs to be consistent with the cover placeholder, so call the "get layout parameters" method public ViewGroup.LayoutParamsgetLayoutParams() of the cover placeholder to obtain the layout parameters of the cover placeholder, including the end point position, length and width of the cover placeholder. Then, assign the layout parameters of the cover placeholder to the global video player, so that when the global video player is added to the view of the target list item, it is consistent with the layout parameters of the original cover placeholder. Finally, replace the cover placeholder with the global video player. Further, assign the value of the global variable "whether the video player has been replaced" to true, indicating that the global video player has been added.

[0049] Optionally, before replacing the cover placeholder of the target list sub-item with the global video player, the method further includes: monitoring the rendering of the first frame of the video and determining that the rendering of the first frame is completed. After the first frame is rendered, the cover placeholder of the target list sub-item is replaced with the global video player, including: obtaining the cover placeholder from the view of the target list sub-item; deleting the cover placeholder or setting it to invisible, and adding the global video player to the view of the target list sub-item; or, adding the global video player to the view of the target list sub-item to cover the cover placeholder.

[0050] In some examples, the "add listener" method void addListener(Listener listener) of the video player is called in advance to set a playback listener for the global video player. Through the playback listener, the first frame rendering completion status of the video is monitored. The "first frame rendering completion" method overridefun onRenderedFirstFrame() in the playback listener is rewritten in advance. This method indicates that a callback is called when the first frame of the video is rendered. During the callback, the player's end, buffering, idle, and playback error states can be monitored.

[0051] Then, the cover placeholder is replaced with a global video player through the following three implementation methods.

[0052] The first implementation method: delete the cover placeholder image in the view of the target list sub-item, and add the global video player to the view of the target list sub-item.

[0053] When the rendering of the first frame of the video is detected, the system's "find view by id" method findViewById(R.id.iv_video_cover) is directly called through the view of the target list item, and the cover placeholder image is obtained from the view of the target list item, and the obtained cover placeholder image is deleted. After the cover placeholder image is deleted, it is stored in the specified storage space for subsequent restoration. Use the "list child view" to call the "add view" method public void addView(Viewchild, LayoutParams params) to add the global video player to the view of the target list item.

[0054] The second implementation method: set the cover placeholder image in the view of the target list sub-item to be invisible, and add the global video player to the view of the target list sub-item.

[0055] When the rendering of the first frame of the video is detected, the system's "find view by id" method findViewById(R.id.iv_video_cover) is directly called through the view of the target list item to obtain the cover placeholder from the view of the target list item. Call the invisible property of the cover placeholder public inline varView.isInvisible: Boolean and set it to false, that is, set the property of the cover placeholder to invisible, then the cover placeholder is hidden. Use the "list child view" to call the "add view" method public voidaddView(View child, LayoutParams params) to add the global video player to the view of the target list item.

[0056] The third implementation method: add the global video player to the view of the target list item and cover the cover placeholder image.

[0057] When it is detected that the rendering of the first frame of the video is completed, the system's "find view by id" method findViewById(R.id.iv_video_cover) is directly called through the view of the target list sub-item to obtain the cover placeholder from the view of the target list sub-item. Use the "list sub-item view" to call the "add view" method public void addView(Viewchild, LayoutParams params) to add the global video player to the view of the target list sub-item. This implementation adds the global video player to the upper layer of the cover placeholder to cover the cover placeholder.

[0058] It should be noted that before replacing the cover placeholder with the global video player, first call the "get parent container" method public final ViewParent getParent() to obtain the parent container of the global video player. If the parent container is obtained, it means that the global video player exists in the original parent container. Then call the "remove view" method public void removeView(View view) through the parent container to remove the global video player from the original parent container, so that the global video player can be stored in the parent container of the cover placeholder in the target list subitem, that is, the global video player and the cover placeholder are placed in the same parent container.

[0059] This embodiment replaces the first frame after rendering is completed, so that the video can be played directly after the cover placeholder disappears on the page, without any gap in the user's vision, thereby improving the user's viewing experience.

[0060] Optionally, after replacing the cover placeholder of the target list sub-item with the global video player according to the target position of the target list sub-item, the method further includes: pausing the playback and reappearing the cover placeholder when the target list sub-item is separated from the current page. In some examples, the following operations are included: S410: When it is detected that a target list item is separated from the current page, the video playback is paused.

[0061] The attachment status listener is used to monitor the attachment status of the target list item. The attachment status includes detached and undetached.

[0062] Optionally, set the attachment state listener in advance. Call the "child attachment state change" method of the list control object, public void addOnChildAttachStateChangeListener(@NonNullOnChildAttachStateChangeListener listener), to monitor the state changes of the target list item between unattached and detached during the scrolling of the list control. In the attachment state listener, override the "child detachment" method override funonChildViewDetachedFromWindow(view: View). This override method will be called back when the list item is detached from the interface window during the list scrolling process. At the bottom of the system, the attached and detached states of the list item view are monitored by registering the OnChildAttachStateChangeListener interface of RecycleView. This interface has a feature: when the list item slides into the RecyclerView area, onChildViewAttachedToWindow will be triggered, and onChildViewDetachedFromWindow will be triggered when it moves out of the RecyclerView area. Thus, the unattached and detached states can be monitored by different triggered objects. When the detached state is monitored, call the "pause" method of the video player object to pause the video playback.

[0063] S420: Remove the global video player from the view of the target list subitem.

[0064] First, call the "Get Child Item Position" method public intgetChildAdapterPosition(@NonNull View child) through the list control, pass the parameters of the "Child Item Separation" method into it, and get the "position of the currently separated list item". Then, determine whether the global variable "Is the video player replaced" is equal to true, and whether the global variable "Play position" is equal to the "position of the currently separated list item". If both conditions are met, it means that the separated list item is the item with the global video player, and the global video player needs to be removed from the view of the target list item. Note that the removal here only does not exist in the view of the separated target list item, and the global video player still exists in the terminal. When the list stops scrolling next time, after determining the target position of the new target list item, you can continue to replace it in the view of the new target list item.

[0065] S430. Redisplay the cover placeholder image in the view of the target list sub-item.

[0066] Optionally, redisplaying the cover placeholder image includes: setting a property of the cover placeholder image to be visible, or restoring the cover placeholder image.

[0067] At the Android system code level, first get the cover placeholder image, call the visible property of the cover placeholder image public inline var View.isVisible: Boolean, set it to true, and set the cover placeholder image to be visible. Further, set the value of the global variable "play position" to the initial value -1, and set the value of the global variable "whether the video player has been replaced" to the initial value false, so as to proceed to the next new target list item operation.

[0068] When the first implementation is used to delete the cover placeholder, it is necessary to restore the deleted cover placeholder from the specified storage space to redisplay the cover placeholder in the view of the target list subitem. When the second implementation is used to hide the cover placeholder, its property needs to be set to visible, that is, call the invisible property of the cover placeholder object, public inline var View.isInvisible: Boolean, and set it to true. When the third implementation is used to overwrite the cover placeholder, if the global video player has been removed, the cover placeholder will naturally be displayed.

[0069] In this embodiment, when the global video player is removed after the list sub-items are separated, space occupation can be saved while ensuring that there is only one global video player.

[0070] Based on the above embodiments, this embodiment provides a more detailed method for playing list videos. After the page is created, a scroll listener, an attachment status listener and a playback listener are set to support the method for playing list videos provided by the above embodiments; when the page is in a destroyed state, the scroll listener, the attachment status listener and the playback listener are removed; and the global video player is released.

[0071] Optional, see Figure 5 , specifically including the following steps: S500: Create a first layout file for a page, and create a second layout file for an adapter of a list control.

[0072] For the convenience of description and distinction, the layout file of the page is called a first layout file, and the layout file of the adapter of the list control is called a second layout file.

[0073] When creating the first layout file, you first need to create a new layout file .xml at the code level, and place a list control RecyclerView in the layout file to display the content list of the community posts: <androidx.recyclerview.widget.RecyclerView android:id="list" android:layout_width="match_parent" android:layout_height="match_parent" / >Here both the width and height are set to match_parent so that the list will take up the entire page space.

[0074] The layout file of the adapter of the list control RecyclerView is each item of the list of community content to be displayed on the page. RecyclerView is only used as a container (list) to load and display data such as pictures and videos of each list sub-item. The specific data in the container is provided by the adapter. The adapter acts as a bridge between RecyclerView and data, mapping the data to the RecyclerView to be displayed. When data needs to be displayed, RecyclerView will retrieve the data from the Adapter and load it for display.

[0075] When creating the second layout file, first create a new layout file .xml, and write controls in the layout file for displaying user avatars, nicknames, pictures of post content, and text. Controls are used to display data such as avatars and nicknames. Add a cover placeholder image to represent the cover of the video. Load the layout file into the view holder of the list control adapter. In the view holder, obtain the controls in the layout file and then bind them to the data such as text, pictures, or video links to be displayed.

[0076] In some examples, at the Android system code level, the onBindViewHolder function is an important method in RecyclerView, which is used to bind data to views. When using multiple views, a common holder variable needs to be defined to store references to different types of views. The onBindViewHolder function creates the corresponding view holder according to the view type. In the onCreateViewHolder() method, the corresponding view holder is created according to the view type. Different layout files can be set for different levels, and the corresponding view references are saved in the view holder. Each list item in RecyclerView has an associated view holder instance, which caches the view reference of the list item. The adapter uses these view references to bind each view to the data to be displayed, such as text, pictures, or video links.

[0077] S510, initialization page.

[0078] Create a new page class, name it Community Page, and let it inherit from the system's Activity. Activity is one of the four major components of the Android system. It is used to display the user interface and interact with the user. In other words, it is what the user sees on the terminal screen. Activity has its own life cycle, which includes: Creation state: Corresponding lifecycle method: protected void onCreate(@Nullable BundlesavedInstanceState).

[0079] Running status: Corresponding life cycle method: protected void onResume().

[0080] Pause state: Corresponding life cycle method: protected void onPause().

[0081] Stop state: Corresponding life cycle method: protected void onStop().

[0082] Destruction state: Corresponding life cycle method: protected void onDestroy().

[0083] S520: Initialize the list and initialize the global video player when the page is in the creation state.

[0084] When initializing the list, first call the system method "Set Content View" public void setContentView(@LayoutRes int layoutResID) to load the first layout file into the current page. Then get the list control object instance, that is, the RecyclerView object, according to the id of the list control. Instantiate the adapter of the RecyclerView object to get the adapter object. Next, call the "Set Adapter" method of the RecyclerView object public voidsetAdapter(@Nullable Adapter adapter) to bind the list control and the adapter. After binding the adapter, the list control can display the list content.

[0085] When initializing the global video player, use the ExoPlayer provided by the official system to instantiate the global video player object. Call the "add listener" method of the global video player void addListener(Listenerlistener) to set the playback listener for the global video player.

[0086] Rewrite the "First Frame Rendering Completed" method override funonRenderedFirstFrame() in the playback listener. This method indicates that the callback is called when the first frame of the video is rendered. Call the "Add Scroll Listener Method" public void addOnScrollListener(@NonNullOnScrollListener listener) of the list control object to listen to the scrolling of the list control. In the scrolling listener, rewrite the "Scrolling State Change" method override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int). This rewritten method will be called back when the scrolling state of the list changes. Call the "Child Attachment State Change" method public void addOnChildAttachStateChangeListener(@NonNullOnChildAttachStateChangeListener listener) of the list control object to listen to the attachment and detachment state changes of the list sub-items during the scrolling of the list control. In the listener, rewrite the "Child detachment" method override funonChildViewDetachedFromWindow(view: View). This rewritten method will be called back when the sub-item is detached from the interface window during the scrolling of the list. For the method calling and overriding of the scrolling listener, the attachment status listener and the playing listener, please refer to the records of the above embodiments, which will not be repeated here.

[0087] S530: Monitor the scrolling status of the list on the page through a scrolling listener.

[0088] S540: Monitor the rendering completion status of the first frame of the video through the playback monitor.

[0089] S550: Monitor the attachment status of the list item through the attachment status listener.

[0090] After the scroll listener, play listener, and attachment status listener are initialized and bound to the list, real-time monitoring can be performed through the listeners.

[0091] S531: When it is detected that the list stops scrolling, the target position of the target list sub-item that needs to play the video in the current page is determined.

[0092] S532. According to the target position of the target list sub-item, search for the view holder object of the list at the target position; call the view property of the list sub-item in the view holder object to obtain the view of the target list sub-item.

[0093] S533. When it is monitored that the rendering of the first frame of the video is completed, obtain the cover placeholder from the view of the target list sub-item; delete the cover placeholder, set the property of the cover placeholder to be invisible, or cover the cover placeholder with the global video player.

[0094] S534: Use a global video player to play the video in the target list sub-item.

[0095] S535. When the page is in the destroyed state, remove the scroll listener, the attachment state listener, and the play listener; and release the global video player.

[0096] Call the "clear scroll listener" method public void clearOnScrollListeners() of the list control to remove the scroll listener of the list. Call the "remove listener" method voidremoveListener(Listener listener) of the global video player to remove the playback listener. Call the "remove attachment state listener" method public void removeOnChildAttachStateChangeListener(OnChildAttachStateChangeListener listener) of the list control to remove the attachment state listener. Call the "release" method void release() of the global video player to release the global video player.

[0097] S551. When it is detected that a target list item is separated from a current page, the video playback is paused and the global video player is removed from the view of the target list item.

[0098] S552. Redisplay the cover placeholder image in the view of the target list sub-item.

[0099] This embodiment provides a more detailed method for playing list videos. The video player does not need to be loaded in the initial second layout file, but a global video player is added to the second layout file after the target position is detected later. After the list sub-items are separated, the global video player is removed, and the global video player is released after the page is destroyed, which improves the life cycle of the global video player.

[0100] like Figure 6 As shown, an embodiment of the present application provides a terminal, including: at least one processor; and a memory communicatively connected to at least one processor; wherein, The memory stores instructions executable by at least one processor, and the instructions are executed by at least one processor so that at least one processor can perform the above method. At least one processor in the terminal can perform the above method, and thus has at least the same advantages as the above method.

[0101] Optionally, the terminal also includes interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. The various components are connected to each other using different buses and can be installed on a common mainboard or installed in other ways as needed. The processor can process instructions executed in the terminal, including instructions stored in or on a memory to display graphical information of a GUI (Graphical User Interface) on an external input / output device (such as a display device coupled to an interface). In other embodiments, if necessary, multiple processors can be used together with multiple memories, and / or multiple buses can be used together with multiple memories. Similarly, multiple electronic devices can be connected (for example, as a server array, a group of blade servers, or a multi-processor system), and each device provides some necessary operations. Figure 6 A processor 301 is taken as an example.

[0102] The memory 302 is a computer-readable storage medium that can be used to store software programs, computer executable programs and modules, such as program instructions / modules corresponding to the method for playing list videos in the embodiment of the present application. The processor 301 executes various functional applications and data processing of the terminal by running the software programs, instructions and modules stored in the memory 302, that is, realizing the above-mentioned method for playing list videos.

[0103] The memory 302 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system and at least one application required for a function; the data storage area may store data created according to the use of the terminal, etc. In addition, the memory 302 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some examples, the memory 302 may further include a memory remotely arranged relative to the processor 301, and these remote memories may be connected to the terminal via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0104] like Figure 7As shown, the terminal may further include: an input device 303 and an output device 304. The processor 301, the memory 302, the input device 303 and the output device 304 may be connected via a bus or other means. Figure 7 The example of connecting through bus is taken in the following.

[0105] The input device 303 can receive input digital or character information, and the output device 304 can include a display device, an auxiliary lighting device (e.g., LED), and a tactile feedback device (e.g., a vibration motor), etc. The display device can include, but is not limited to, a liquid crystal display (LCD), a light emitting diode (LED) display, and a plasma display. In some embodiments, the display device can be a touch screen.

[0106] Example 6 This embodiment provides a computer-readable storage medium, on which computer instructions are stored, and the computer instructions are used to enable the computer to execute the above method. The computer instructions on the computer-readable storage medium are used to enable the computer to execute the above method, and thus have at least the same advantages as the above method.

[0107] The computer-readable storage medium in this embodiment can adopt any combination of one or more computer-readable media. The medium can be a computer-readable signal medium or a computer-readable storage medium. The medium can be, for example, - but not limited to - an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of the medium (a non-exhaustive list) include: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this document, the medium can be any tangible medium containing or storing a program, which can be used by an instruction execution system, device or device or used in combination with it.

[0108] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, which carry computer-readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.

[0109] The program code contained on the computer-readable medium can be transmitted using any appropriate medium, including but not limited to wireless, wire, optical cable, RF (Radio Frequency), etc., or any suitable combination of the above.

[0110] Computer program code for performing the operation of the present application can be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computer (e.g., using an Internet service provider to connect through the Internet).

[0111] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this application can be executed in parallel, sequentially or in different orders, as long as the expected results of the technical solution disclosed in this application can be achieved, and this document is not limited here.

[0112] The above specific implementations do not constitute a limitation on the protection scope of this application. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of this application should be included in the protection scope of this application.

Claims

1. A method for playing a list video, It is characterized in that include: Monitor the scrolling status of the list on the page; When it is detected that the list stops scrolling, the target position of the target list sub-item on the current page where the video needs to be played is determined; According to the target position, the cover placeholder of the target list sub-item is replaced with a global video player; The global video player is used to play the video in the target list sub-item.

2. The method according to claim 1, It is characterized in that In the case where the list stops scrolling, determining the target position of the target list sub-item that needs to play the video in the current page includes: When it is detected that the list stops scrolling, find the first position of the top visible list item and the second position of the bottom visible list item in the current page; Traverse each list item from the first position to the second position; If the first list sub-item currently traversed includes a video, and the cover placeholder image of the first list sub-item is completely visible, the first list sub-item is determined as the target list sub-item, and the target position of the target list sub-item is determined; wherein, the first list sub-item is any list sub-item between the first position and the second position.

3. The method according to claim 2, It is characterized in that Before taking the first list item as the target list item, the method further includes: Determine a visible area of ​​the cover placeholder of the first list sub-item, and determine the heights of the cover placeholder and the visible area; When the height of the cover placeholder image is consistent with the height of the visible area, it is determined that the cover placeholder image of the first list sub-item is completely visible.

4. The method according to claim 1, It is characterized in that The step of replacing the cover placeholder image of the target list sub-item with a global video player according to the target position includes: According to the target position, searching for the view holder object of the list at the target position; Calling the view property of the list item in the view holder object to obtain the view of the target list item; the view of the target list item includes the cover placeholder image; According to the layout parameters of the cover placeholder image, the cover placeholder image is replaced with the global video player in the view of the target list sub-item.

5. The method according to claim 4, It is characterized in that Replace the cover placeholder with a global video player, including: Delete the cover placeholder or set it to be invisible, and add the global video player to the view of the target list subitem; or Add the global video player to the view of the target list subitem, covering the cover placeholder.

6. The method according to any one of claims 1 to 5, It is characterized in that Before replacing the cover placeholder image of the target list sub-item with the global video player, the method further includes: The rendering of the first frame of the video is monitored, and it is determined that the rendering of the first frame is completed.

7. The method according to any one of claims 1 to 5, It is characterized in that After replacing the cover placeholder of the target list sub-item with the global video player according to the target position, the method further includes: When it is detected that the target list item is separated from the current page, the video playback is paused; Remove the global video player from the view of the target list item; The cover placeholder image is redisplayed in the view of the target list subitem.

8. The method according to any one of claims 1 to 5, It is characterized in that After the global video player is used to play the video in the target list sub-item, the method further includes: When the page is in the destroyed state, remove the scroll listener, the attachment state listener and the play listener; Release the global video player.

9. A terminal, It is characterized in that include: at least one processor, and a memory communicatively coupled to at least one of the processors; The memory stores instructions that can be executed by at least one of the processors, and the instructions are executed by at least one of the processors so that at least one of the processors can execute the method for playing list videos described in any one of claims 1-8.

10. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores computer instructions, which can be executed by one or more processors to implement the method for playing list videos as described in any one of claims 1-8.

Citation Information

Patent Citations

  • Video playing control method and device, electronic device and storage medium

    CN110401877A

  • Video stream playing method and device

    CN116506695A

  • Video playing method and device, equipment and storage medium

    CN116668791A

  • Implementation method for reusable multi-module video playing component of iOS

    CN117492715A

  • Video preview method and apparatus

    WO2023103325A1

Cited By

  • Vehicle control community list page processing method and device and computer equipment

    CN120743273A

  • Webpage video playing optimization method and device, equipment and storage medium

    CN121284298A