CN113411683A - Video playing method and device - Google Patents

Video playing method and device Download PDF

Info

Publication number
CN113411683A
CN113411683A CN202110700053.4A CN202110700053A CN113411683A CN 113411683 A CN113411683 A CN 113411683A CN 202110700053 A CN202110700053 A CN 202110700053A CN 113411683 A CN113411683 A CN 113411683A
Authority
CN
China
Prior art keywords
player
video
main thread
thread
playing
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202110700053.4A
Other languages
Chinese (zh)
Other versions
CN113411683B (en
Inventor
王以建
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing QIYI Century Science and Technology Co Ltd
Original Assignee
Beijing QIYI Century Science and Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing QIYI Century Science and Technology Co Ltd filed Critical Beijing QIYI Century Science and Technology Co Ltd
Priority to CN202110700053.4A priority Critical patent/CN113411683B/en
Publication of CN113411683A publication Critical patent/CN113411683A/en
Application granted granted Critical
Publication of CN113411683B publication Critical patent/CN113411683B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/80Generation or processing of content or additional data by content creator independently of the distribution process; Content per se
    • H04N21/81Monomedia components thereof
    • H04N21/8166Monomedia components thereof involving executable data, e.g. software
    • H04N21/8173End-user applications, e.g. Web browser, game
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/43Processing of content or additional data, e.g. demultiplexing additional data from a digital video stream; Elementary client operations, e.g. monitoring of home network or synchronising decoder's clock; Client middleware
    • H04N21/443OS processes, e.g. booting an STB, implementing a Java virtual machine in an STB or power management in an STB
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/45Management operations performed by the client for facilitating the reception of or the interaction with the content or administrating data related to the end-user or to the client device itself, e.g. learning user preferences for recommending movies, resolving scheduling conflicts
    • H04N21/462Content or additional data management, e.g. creating a master electronic program guide from data received from the Internet and a Head-end, controlling the complexity of a video stream by scaling the resolution or bit-rate based on the client capabilities

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Software Systems (AREA)
  • Databases & Information Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Signal Processing For Digital Recording And Reproducing (AREA)

Abstract

The embodiment of the invention provides a video playing method and a video playing device, wherein the method comprises the following steps: playing a first video in a first Surface of a first player through a first sub-thread of a target application program; when a video jump playing instruction for playing a second video is detected, a second player is created through a main thread of a target application program, a second Surface is created in the second player, and the first player is released through a second sub-thread of the target application program; playing a second video in a second Surface through a third sub thread of the target application program; and releasing the first Surface through the main thread after the first player is released. Based on the processing, the time delay of the jump playing can be reduced, and the user experience is improved.

Description

Video playing method and device
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a video playing method and apparatus.
Background
With the rapid development of computer technology, users can browse various network resources (e.g., video network resources) through electronic devices. In the process of browsing the video, the user can execute the video jump playing operation in the electronic device, and correspondingly, the electronic device can jump to play other videos from the currently played video.
In the related art, the electronic device based on the android system needs to render an image in a Surface (Surface) provided by the system through a player to play a video. When a user selects video jump playing, the electronic device needs to release a player and a Surface for playing the current video, and after the player and the Surface are released, a new player and a new Surface can be created to play the new video in the new Surface through the new player.
However, releasing the player and the Surface for playing the current video consumes a longer time, which causes a longer delay for jumping to play, and reduces the user experience.
Disclosure of Invention
The embodiment of the invention aims to provide a video playing method and device so as to reduce the time delay of jump playing and improve the user experience. The specific technical scheme is as follows:
in a first aspect of the present invention, there is provided a video playing method, where the method includes:
playing a first video in a first Surface of a first player through a first sub-thread of a target application program;
when a video jump playing instruction for playing a second video is detected, a second player is created through a main thread of the target application program, a second Surface is created in the second player, and the first player is released through a second sub-thread of the target application program;
playing a second video in the second Surface through a third sub thread of the target application program;
and releasing the first Surface through the main thread after the first player is released.
Optionally, the method further includes:
and after the first player finishes releasing, through the main thread, the Surface view SurfaceView to which the first Surface belongs is unregistered in the corresponding Activity.
Optionally, the unregistering, by the main thread, the first Surface in the corresponding Activity includes:
acquiring a reverse registration function for deregistering the SurfaceView to which the first Surface belongs based on a reflection mechanism through the main thread;
and according to the anti-registration function, the SurfaceView of the first Surface is unregistered in the corresponding Activity.
Optionally, before the creating the second player by the main thread of the target application, the method further includes:
detecting whether the delayed release identifier of the first Surface is in an effective state or not through the main thread;
if the delayed release identifier of the first Surface is in an effective state, intercepting a release event of the first Surface triggered by the video skip playing instruction through the main thread;
the creating a second player by the main thread of the target application includes:
and under the condition that the delayed release identifier of the first Surface is in an effective state, creating a second player through the main thread of the target application program.
Optionally, before releasing the first Surface by the main thread, the method further includes:
when the first player is released, triggering a player release completion event through the second child thread, wherein the player release completion event is used for modifying the delayed release identifier of the first Surface into an invalid state;
when the player release completion event is monitored through the main thread, detecting whether the delayed release identifier of the first Surface is in an invalid state;
the releasing the first Surface by the main thread includes:
and when the delay release identifier of the first Surface is detected to be in an invalid state, releasing the first Surface through the main thread.
Optionally, the method further includes:
and after the second Surface is created, setting a delayed release identifier of an effective state for the second Surface through the main thread.
In a second aspect of the present invention, there is also provided a video playback apparatus, including:
the first playing module is used for playing a first video in a first Surface of a first player through a first sub-thread of a target application program;
the processing module is used for creating a second player through a main thread of the target application program, creating a second Surface in the second player and releasing the first player through a second sub-thread of the target application program when a video jump playing instruction for playing a second video is detected;
the second playing module is used for playing a second video in the second Surface through a third sub thread of the target application program;
and the releasing module is used for releasing the first Surface through the main thread after the first player is released.
Optionally, the apparatus further comprises:
and the registration canceling module is used for canceling the registration of the Surface view SurfaceView to which the first Surface belongs in the corresponding Activity through the main thread after the first player is released.
Optionally, the unregistering module includes:
a reverse registration function obtaining sub-module, configured to obtain, through the main thread and based on a reflection mechanism, a reverse registration function for deregistering the Surface view to which the first Surface belongs;
and the deregistration submodule is used for deregistering the SurfaceView to which the first Surface belongs in the corresponding Activity according to the reverse registration function.
Optionally, the apparatus further comprises:
a first detecting module, configured to detect, by the main thread of the target application program, before creating a second player, whether a delayed release identifier of the first Surface is in an active state;
the intercepting module is used for intercepting a release event of the first Surface triggered by the video skip playing instruction through the main thread if the delayed release identifier of the first Surface is in an effective state;
the processing module is specifically configured to create a second player through the main thread of the target application program under the condition that the delayed release identifier of the first Surface is in an active state.
Optionally, the apparatus further comprises:
an event triggering module, configured to trigger a player release completion event through the second child thread when the first player release is completed before the first Surface is released through the main thread, where the player release completion event is used to modify a delayed release identifier of the first Surface to an invalid state;
a second detecting module, configured to detect whether a delayed release identifier of the first Surface is in an invalid state when the main thread monitors the player release completion event;
the release module is specifically configured to release the first Surface through the main thread when it is detected that the delayed release identifier of the first Surface is in an invalid state.
Optionally, the apparatus further comprises:
and the setting module is used for setting a delayed release identifier of an effective state for the second Surface through the main thread after the second Surface is established.
In another aspect of the present invention, there is also provided an electronic device, including a processor, a communication interface, a memory and a communication bus, where the processor, the communication interface, and the memory complete communication with each other through the communication bus;
a memory for storing a computer program;
a processor, configured to implement the video playing method according to any one of the first aspect when executing a program stored in a memory.
In yet another aspect of the present invention, there is also provided a computer-readable storage medium, in which a computer program is stored, and the computer program, when executed by a processor, implements any of the video playing methods described above.
In yet another aspect of the present invention, there is also provided a computer program product containing instructions which, when run on a computer, cause the computer to perform any of the video playback methods described above.
According to the video playing method provided by the embodiment of the invention, a first video can be played in a first Surface of a first player of a target application program; when a video jump playing instruction for playing a second video is detected, a second player is created through a main thread of a target application program, a second Surface is created in the second player, and the first player is released through a second sub-thread of the target application program; playing a second video in a second Surface through a third sub thread of the target application program; and releasing the first Surface through the main thread after the first player is released.
Based on the above processing, when a video jump playing instruction is detected, a new player (i.e. a second player) and a corresponding Surface (i.e. a second Surface) can be created by the main thread to play a new video. And simultaneously, releasing the first player through the sub-thread, and releasing the first Surface through the main thread after the first player is released. That is to say, when the first Surface starts to be released, the second Surface is already created, so that the second video can be played in the second Surface simultaneously with the release of the first Surface, that is, the second video can be played without waiting for the release of the first Surface to be completed, and further, the time delay of the skip playing can be reduced, and the user experience can be improved.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below.
Fig. 1 is a flowchart of a video playing method provided in an embodiment of the present invention;
fig. 2 is a flowchart of another video playing method provided in the embodiment of the present invention;
fig. 3 is a flowchart of another video playing method provided in the embodiment of the present invention;
fig. 4 is a flowchart of another video playing method provided in the embodiment of the present invention;
fig. 5 is a flowchart of another video playing method provided in the embodiment of the present invention;
FIG. 6 is a diagram illustrating relationships between categories provided in an embodiment of the present invention;
fig. 7 is a timing diagram of video playing according to an embodiment of the present invention;
fig. 8 is a structural diagram of a video playback device according to an embodiment of the present invention;
fig. 9 is a structural diagram of an electronic device provided in an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be described below with reference to the drawings in the embodiments of the present invention.
In the related art, when a user selects a video jump play, the electronic device needs to release a player and a Surface for playing a current video, and after the player and the Surface are released, a new player and a new Surface can be created to play a new video in the new Surface through the new player.
However, releasing the player and the Surface for playing the current video consumes a longer time, which causes a longer delay for jumping to play, and reduces the user experience.
In order to solve the above problem, an embodiment of the present invention provides a video playing method, where the method may be applied to an electronic device, the electronic device may be an intelligent terminal based on an android system, and an application program for playing a video may be installed in the electronic device.
Referring to fig. 1, fig. 1 is a flowchart of a video playing method provided in an embodiment of the present invention, where the method may include the following steps:
s101: the first video is played in a first Surface of a first player through a first child thread of a target application.
S102: when a video jump playing instruction for playing the second video is detected, a second player is created through the main thread of the target application program, a second Surface is created in the second player, and the first player is released through the second sub-thread of the target application program.
S103: and playing the second video in the second Surface through the third sub thread of the target application program.
S104: and releasing the first Surface through the main thread after the first player is released.
According to the video playing method provided by the embodiment of the invention, when the video jump playing instruction is detected, a new player (namely, a second player) and a corresponding Surface (namely, a second Surface) can be created through the main thread so as to play a new video. And simultaneously, releasing the first player through the sub-thread, and releasing the first Surface through the main thread after the first player is released. That is to say, when the first Surface starts to be released, the second Surface is already created, so that the second video can be played in the second Surface simultaneously with the release of the first Surface, that is, the second video can be played without waiting for the release of the first Surface to be completed, and further, the time delay of the skip playing can be reduced, and the user experience can be improved.
In the electronic device based on the android system, a player needs to be created, a Surface is created in the player, and further, an image of a video can be rendered in the Surface. In addition, in the process of playing the video, the electronic device can only start one player instance, that is, when the skip playing is needed, the currently started player needs to be released first, and then a new player can be started.
In one embodiment, the first player may be stopped by the main thread of the target application when a video jump play instruction is detected. In one implementation, the main thread may call a corresponding sub-thread of the player (i.e., a second sub-thread in the embodiment of the present invention) through a first stop function (e.g., unilayer.stop ()), and stop running the first player through a second stop function (e.g., medialayer.stop ()).
Further, after stopping the operation of the first player, the release of the first player may be started. And releasing the first player, namely releasing the memory resource occupied by the first player.
In one implementation, the main thread may cancel the association between the first player and the first Surface through a first player release function (e.g., unilayer. The main thread may then call a second player release function (e.g., media release ()) to notify the second child thread that the current main thread has cancelled the association between the first player and the first Surface, and the second child thread may then begin releasing the first player.
Accordingly, for step S102, the main thread creating the second player and the second Surface may be performed asynchronously with the second sub-thread starting releasing the first player.
For step S104, the first Surface is released, that is, the memory resource occupied by the first Surface is released.
In one embodiment, referring to fig. 2, on the basis of fig. 1, the method may further include the steps of:
s105: and after the first player finishes releasing, canceling the registration of the SurfaceView to which the first Surface belongs in the corresponding Activity through the main thread.
In the android system, SurfaceView is derived from View. A Surface View may embed a Surface. The SurfaceView is used to show the data in the Surface, and is used to control the position and size of the View in the Surface.
In the embodiment of the present invention, after the first player is released, the main thread may release the first Surface. And when the first video is played based on the first Surface, the surfview (which may be referred to as the first surfview) to which the first Surface belongs is registered in the corresponding Activity, that is, is associated with the Activity. Because, in order to avoid that the corresponding Activity is still referenced after the first Surface is released, the association relationship between the first Surface view and the corresponding Activity needs to be broken, that is, the first Surface view is unregistered in the Activity. Furthermore, the condition that the memory is leaked due to the fact that the corresponding Activity has invalid references can be avoided.
In one embodiment, referring to fig. 3, on the basis of fig. 2, the step S105 may include the following steps:
s1051: and acquiring a reverse registration function for deregistering the Surface View to which the first Surface belongs on the basis of a reflection mechanism through the main thread.
S1052: and according to the anti-registration function, deregistering the SurfaceView to which the first Surface belongs in the corresponding Activity.
In the embodiment of the invention, because the anti-registration function for the Surface view is not disclosed, the corresponding anti-registration function can be called according to the source code of the Surface based on the reflection mechanism of Java.
In one embodiment, the deregistration function may include: proc stepped Window Stopped Callback (process separation Window Stopped Callback), proc stepped On Scroll Change (process separation change On scrolling), and proc stepped On PreDraw (process separation On pre-draw) functions.
In one embodiment, referring to fig. 4, on the basis of fig. 1, before the step S102, the method may further include the steps of:
s106: and detecting whether the delayed release identifier of the first Surface is in a valid state or not through the main thread.
S107: and if the delayed release identifier of the first Surface is in an effective state, intercepting a release event of the first Surface triggered by the video jump playing instruction through the main thread.
Accordingly, the step S102 may include:
s1021: when a video jump playing instruction for playing a second video is detected, under the condition that the delayed release identifier of the first Surface is in an effective state, a second player is created through a main thread of a target application program, a second Surface is created in the second player, and the first player is released through a second sub-thread of the target application program.
In the embodiment of the present invention, the status (including valid status or invalid status) of the delayed release flag may be set for each Surface.
For example, setting the status of the Surface-set delayed release flag to False may be denoted as an invalid status; the state of the Surface set delayed release flag is set to True, which can be expressed as a valid state.
If the status of the delayed release flag of the first Surface is set to True, it indicates that when a release event of the first Surface triggered by the video jump play instruction is detected, the first Surface needs to be released in a delayed manner, that is, in the process described in the above steps S101-S104, a new Surface (i.e., a second Surface) is created first, and then the first Surface is released, instead of directly releasing the first Surface when the release event of the first Surface is detected.
That is to say, in order to reduce the time delay of jumping to play a video, when a new Surface is generated, a delayed release flag in an active state may be set for the newly generated Surface.
Correspondingly, when the state of the delayed release identifier of the first Surface is detected to be an effective state, it can be determined that the first Surface needs to be released in a delayed manner currently, so that a release event of the first Surface triggered by a video jump playing instruction can be intercepted through the main thread to prevent the bottom layer from releasing the first Surface. Furthermore, a second player and a second Surface can be directly created to play a new video, so that the time delay of video jump playing is reduced.
On the contrary, if the status of the delayed release flag of the first Surface is set to False, it indicates that when the release event of the first Surface triggered by the video jump play instruction is detected, the first Surface does not need to be released in a delayed manner, and the first Surface can be released directly.
In one embodiment, referring to fig. 5, on the basis of fig. 4, before the step S104, the method may further include the steps of:
s108: when the first player release is completed, the player release completion event is triggered through the second sub-thread.
And the player release completion event is used for modifying the delayed release identifier of the first Surface into an invalid state.
S109: and when the player release completion event is monitored through the main thread, detecting whether the delayed release identifier of the first Surface is in an invalid state.
Accordingly, the step S104 may include the following steps:
s1041: and after the first player finishes releasing, when detecting that the delay release identifier of the first Surface is in an invalid state, releasing the first Surface through the main thread.
In one implementation, the player release completion event may be represented by unilayer.
See, for example, the code for the unilayer.
Figure BDA0003129856100000101
Figure BDA0003129856100000111
Based on the above codes, the unilayer.onrelease event can modify the delayed release identifier of the first Surface to be a Flase, i.e., an invalid state.
The main thread can listen to the unilayer. When the unilayer.OnRelease event is monitored and the delayed release identifier of the first Surface is detected to be in an invalid state, the fact that the second sub-thread completes the release of the first player is indicated, the main thread also completes the second player at the moment and the creation of the second Surface is indicated, at the moment, the main thread does not need to render the image of the second video in the second Surface, and only one sub-thread (namely, a third sub-thread) needs to render the image of the second video in the second Surface, so that the main thread can release the first Surface.
In one embodiment, the above-mentioned anti-registration function may also be called by a player release completion event.
In one implementation, referring to the code of the unilayer.onrelease event above, a viewgroup.removeview (surfaceView) function may also be called in the unilayer.onrelease event to trigger a surfaceView ex:: ontechedfromwindow event. In the SurfaceViewEx:: onDetachedFromWindow event, a ProcDetachedFromWindow function can be called, and in the ProcDetachedFromWindow function, a reverse registration function of the SurfaceView to which the first Surface belongs can be called.
In one implementation, the surfaceViewEx class can be set to inherit from the self surfaceView of the android through public class surfaceViewEx extensions surfaceView.
In addition, by:
public void setIgnoreWindowChange(boolean ignoreWindowChange){
mIgnoreWindowChange=ignoreWindowChange;
}
a delayed release flag (i.e., mignonewindowchange) may be added to the SurfaceViewEx class.
Further, by:
Figure BDA0003129856100000112
Figure BDA0003129856100000121
it can be detected whether a delayed release Surface is required. If the release needs to be delayed, the Surface is not released currently; if delayed release is not required, the Surface is released directly.
In addition, by:
Figure BDA0003129856100000123
Figure BDA0003129856100000122
the anti-registration function procdetachedwindowsuppedCallback can be obtained based on a reflection mechanism.
And by:
Figure BDA0003129856100000131
the anti-registration function procdetachedonsccollchanged may be obtained based on a reflection mechanism.
And by:
Figure BDA0003129856100000132
Figure BDA0003129856100000141
the anti-registration function procdetachedon predraw can be obtained based on the reflection mechanism.
In one embodiment, the method may further comprise the steps of:
and after the second Surface is created, setting a delayed release identifier of an effective state for the second Surface through the main thread.
In the embodiment of the present invention, a delayed release identifier in an effective state may also be set for the newly generated second Surface, and accordingly, when the user needs to jump from the second video to play another video, based on the video playing method of the embodiment of the present invention, delayed release of the second Surface may also be implemented, that is, a time delay of jumping to play another video is reduced, and user experience is improved.
Referring to fig. 6, fig. 6 is a diagram illustrating a relationship between categories according to an embodiment of the present invention.
In FIG. 6, the SurfaceViewEx is inherited from SurfaceView.
Specifically, the Surface view wEx is an extension of a Surface view of the system, and a delayed release identifier is added on the basis of the Surface view of the system to control release of the Surface and reverse registration of the Surface view.
unilayer represents an abstract class of imedia player, within which the general functions of the player are implemented. Based on the class, specific service players such as LivePlayer, CarouselPlayer and the like can be derived, a calling interface is provided for the application, the external is set with Surface, the playing method called by the application is transmitted to the media layer of the bottom layer Player, and the event of the bottom layer Player is transmitted to the application.
Onstate releaselistener represents an event listener, which is used to listen to the onstate event of the underlying player medialayer. The specific calling is as follows: setonstate releasedlistener (onstate releasedlistener).
The unilayer holds a SurfaceViewEx object and a medialayer object. The unilayer creates an OnStateReleaseListener instance to be transmitted to the medialayer to monitor the OnRelease event of the medialayer.
Referring to fig. 7, fig. 7 is a timing diagram of a video playing method according to an embodiment of the present invention.
In fig. 7, when a video jump play instruction is detected, the main thread may call a corresponding sub-thread of the player through a first stop function (e.g., unilayer. stop ()), and stop running the current first player (i.e., a player) through a second stop function (e.g., medialayer. stop ()).
Then, the main thread may cancel the association between the first player and the first Surface through a first player release function (e.g., unilayer release ()), and call a second player release function (e.g., medialayer release ()), to notify the sub-thread that the association between the first player and the first Surface has been cancelled, and the sub-thread may start releasing the first player.
Further, the main thread may call the sub thread through a first player creation function (e.g., unilayer. create ()), and create a second player (i.e., B-player) through a second player creation function (e.g., medialayer. create ()).
The main thread may then call the child thread through a first Surface creation function (e.g., unilayer. setSurface) and create a second Surface (i.e., Surface for B-player) through a second Surface creation function (e.g., medialayer. setSurface).
When the child thread releases the first player to complete, a player release completion event (e.g., unilayer.
In addition, the child thread may play the new video in the Surface of the B-player through a video play function (e.g., mediaplayer. start ()).
The main thread can listen to the unilayer. When the unilayer.onrelease event is monitored and the delay release identifier of the first Surface is detected to be in an invalid state, the main thread can release the Surface of the player a and unregister the Surface view to which the Surface of the player a belongs in the corresponding Activity.
Based on the same inventive concept, an embodiment of the present invention further provides a video playing apparatus, referring to fig. 8, where fig. 8 is a structural diagram of a video playing apparatus provided in an embodiment of the present invention, the apparatus may include:
a first playing module 801, configured to play a first video in a first Surface of a first player through a first sub-thread of a target application;
a processing module 802, configured to, when a video jump playing instruction for playing a second video is detected, create a second player through a main thread of the target application, create a second Surface in the second player, and release the first player through a second sub-thread of the target application;
a second playing module 803, configured to play a second video in the second Surface through a third child thread of the target application;
a releasing module 804, configured to release the first Surface through the main thread after the first player is released.
Optionally, the apparatus further comprises:
and the registration canceling module is used for canceling the registration of the Surface view SurfaceView to which the first Surface belongs in the corresponding Activity through the main thread after the first player is released.
Optionally, the unregistering module includes:
a reverse registration function obtaining sub-module, configured to obtain, through the main thread and based on a reflection mechanism, a reverse registration function for deregistering the Surface view to which the first Surface belongs;
and the deregistration submodule is used for deregistering the SurfaceView to which the first Surface belongs in the corresponding Activity according to the reverse registration function.
Optionally, the apparatus further comprises:
a first detecting module, configured to detect, by the main thread of the target application program, before creating a second player, whether a delayed release identifier of the first Surface is in an active state;
the intercepting module is used for intercepting a release event of the first Surface triggered by the video skip playing instruction through the main thread if the delayed release identifier of the first Surface is in an effective state;
the processing module 802 is specifically configured to create a second player through the main thread of the target application program when the delayed release identifier of the first Surface is in an active state.
Optionally, the apparatus further comprises:
an event triggering module, configured to trigger a player release completion event through the second child thread when the first player release is completed before the first Surface is released through the main thread, where the player release completion event is used to modify a delayed release identifier of the first Surface to an invalid state;
a second detecting module, configured to detect whether a delayed release identifier of the first Surface is in an invalid state when the main thread monitors the player release completion event;
the releasing module 804 is specifically configured to release the first Surface through the main thread when it is detected that the delayed release identifier of the first Surface is in an invalid state.
Optionally, the apparatus further comprises:
and the setting module is used for setting a delayed release identifier of an effective state for the second Surface through the main thread after the second Surface is established.
An embodiment of the present invention further provides an electronic device, as shown in fig. 9, which includes a processor 901, a communication interface 902, a memory 903, and a communication bus 904, where the processor 901, the communication interface 902, and the memory 903 complete mutual communication through the communication bus 904,
a memory 903 for storing computer programs;
the processor 901 is configured to implement the following steps when executing the program stored in the memory 903:
playing a first video in a first Surface of a first player through a first sub-thread of a target application program;
when a video jump playing instruction for playing a second video is detected, a second player is created through a main thread of the target application program, a second Surface is created in the second player, and the first player is released through a second sub-thread of the target application program;
playing a second video in the second Surface through a third sub thread of the target application program;
and releasing the first Surface through the main thread after the first player is released.
The communication bus mentioned in the electronic device may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The communication bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown, but this does not mean that there is only one bus or one type of bus.
The communication interface is used for communication between the electronic equipment and other equipment.
The Memory may include a Random Access Memory (RAM) or a non-volatile Memory (non-volatile Memory), such as at least one disk Memory. Optionally, the memory may also be at least one memory device located remotely from the processor.
The Processor may be a general-purpose Processor, and includes a Central Processing Unit (CPU), a Network Processor (NP), and the like; the device can also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, a discrete Gate or transistor logic device, or a discrete hardware component.
In another embodiment of the present invention, a computer-readable storage medium is further provided, in which a computer program is stored, and the computer program, when executed by a processor, implements the video playing method in any of the above embodiments.
In yet another embodiment of the present invention, there is also provided a computer program product containing instructions which, when run on a computer, cause the computer to perform the video playback method of any of the above embodiments.
In the above embodiments, the implementation may be wholly or partially realized by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When loaded and executed on a computer, cause the processes or functions described in accordance with the embodiments of the invention to occur, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a network of computers, or other programmable device. The computer instructions may be stored in a computer readable storage medium or transmitted from one computer readable storage medium to another, for example, from one website site, computer, server, or data center to another website site, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device, such as a server, a data center, etc., that incorporates one or more of the available media. The usable medium may be a magnetic medium (e.g., floppy Disk, hard Disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., Solid State Disk (SSD)), among others.
It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
All the embodiments in the present specification are described in a related manner, and the same and similar parts among the embodiments may be referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the apparatus, the electronic device, the computer-readable storage medium, and the computer program product embodiments, since they are substantially similar to the method embodiments, the description is relatively simple, and for the relevant points, reference may be made to the partial description of the method embodiments.
The above description is only for the preferred embodiment of the present invention, and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention shall fall within the protection scope of the present invention.

Claims (10)

1. A video playback method, the method comprising:
playing a first video in a first Surface of a first player through a first sub-thread of a target application program;
when a video jump playing instruction for playing a second video is detected, a second player is created through a main thread of the target application program, a second Surface is created in the second player, and the first player is released through a second sub-thread of the target application program;
playing a second video in the second Surface through a third sub thread of the target application program;
and releasing the first Surface through the main thread after the first player is released.
2. The method of claim 1, further comprising:
and after the first player finishes releasing, through the main thread, the Surface view SurfaceView to which the first Surface belongs is unregistered in the corresponding Activity.
3. The method according to claim 2, wherein said unregistering, by the main thread, the first Surface in the corresponding Activity comprises:
acquiring a reverse registration function for deregistering the SurfaceView to which the first Surface belongs based on a reflection mechanism through the main thread;
and according to the anti-registration function, the SurfaceView of the first Surface is unregistered in the corresponding Activity.
4. The method of claim 1, wherein prior to the creating of the second player by the main thread of the target application, the method further comprises:
detecting whether the delayed release identifier of the first Surface is in an effective state or not through the main thread;
if the delayed release identifier of the first Surface is in an effective state, intercepting a release event of the first Surface triggered by the video skip playing instruction through the main thread;
the creating a second player by the main thread of the target application includes:
and under the condition that the delayed release identifier of the first Surface is in an effective state, creating a second player through the main thread of the target application program.
5. The method of claim 4, wherein prior to said releasing the first Surface by the main thread, the method further comprises:
when the first player is released, triggering a player release completion event through the second child thread, wherein the player release completion event is used for modifying the delayed release identifier of the first Surface into an invalid state;
when the player release completion event is monitored through the main thread, detecting whether the delayed release identifier of the first Surface is in an invalid state;
the releasing the first Surface by the main thread includes:
and when the delay release identifier of the first Surface is detected to be in an invalid state, releasing the first Surface through the main thread.
6. The method of claim 4, further comprising:
and after the second Surface is created, setting a delayed release identifier of an effective state for the second Surface through the main thread.
7. A video playback apparatus, comprising:
the first playing module is used for playing a first video in a first Surface of a first player through a first sub-thread of a target application program;
the processing module is used for creating a second player through a main thread of the target application program, creating a second Surface in the second player and releasing the first player through a second sub-thread of the target application program when a video jump playing instruction for playing a second video is detected;
the second playing module is used for playing a second video in the second Surface through a third sub thread of the target application program;
and the releasing module is used for releasing the first Surface through the main thread after the first player is released.
8. The apparatus of claim 7, further comprising:
and the registration canceling module is used for canceling the registration of the Surface view SurfaceView to which the first Surface belongs in the corresponding Activity through the main thread after the first player is released.
9. An electronic device is characterized by comprising a processor, a communication interface, a memory and a communication bus, wherein the processor and the communication interface are used for realizing mutual communication by the memory through the communication bus;
a memory for storing a computer program;
a processor for implementing the method steps of any of claims 1-6 when executing a program stored in the memory.
10. A computer-readable storage medium, characterized in that a computer program is stored in the computer-readable storage medium, which computer program, when being executed by a processor, carries out the method steps of any one of claims 1 to 6.
CN202110700053.4A 2021-06-23 2021-06-23 Video playing method and device Active CN113411683B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110700053.4A CN113411683B (en) 2021-06-23 2021-06-23 Video playing method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110700053.4A CN113411683B (en) 2021-06-23 2021-06-23 Video playing method and device

Publications (2)

Publication Number Publication Date
CN113411683A true CN113411683A (en) 2021-09-17
CN113411683B CN113411683B (en) 2022-07-22

Family

ID=77682746

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110700053.4A Active CN113411683B (en) 2021-06-23 2021-06-23 Video playing method and device

Country Status (1)

Country Link
CN (1) CN113411683B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114071229A (en) * 2021-12-08 2022-02-18 四川启睿克科技有限公司 Method for solving recovery delay when surface View renderer reloads video for decoding

Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103648037A (en) * 2013-11-15 2014-03-19 乐视致新电子科技(天津)有限公司 Intelligent television media player and search response method thereof, and intelligent television
WO2017113856A1 (en) * 2015-12-31 2017-07-06 乐视控股(北京)有限公司 Barrage display method and device
WO2018001218A1 (en) * 2016-06-27 2018-01-04 北京奇虎科技有限公司 Video playing method, device, program and medium
CN109194986A (en) * 2018-08-24 2019-01-11 深圳市酷开网络科技有限公司 A kind of resource control method, smart television and storage medium
CN110147512A (en) * 2019-05-16 2019-08-20 腾讯科技(深圳)有限公司 Player preloading, operation method, device, equipment and medium
CN110300328A (en) * 2018-03-21 2019-10-01 腾讯科技(深圳)有限公司 A kind of video playing control method, device and readable storage medium storing program for executing
CN110708602A (en) * 2019-10-15 2020-01-17 北京字节跳动网络技术有限公司 Video starting method and device, electronic equipment and storage medium
CN111641864A (en) * 2019-03-01 2020-09-08 腾讯科技(深圳)有限公司 Video information acquisition method, device and equipment
US20210029410A1 (en) * 2017-08-03 2021-01-28 Live.Me Inc. Method and apparatus for looping a video file
CN112416461A (en) * 2020-11-25 2021-02-26 百度在线网络技术(北京)有限公司 Video resource processing method and device, electronic equipment and computer readable medium

Patent Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103648037A (en) * 2013-11-15 2014-03-19 乐视致新电子科技(天津)有限公司 Intelligent television media player and search response method thereof, and intelligent television
WO2017113856A1 (en) * 2015-12-31 2017-07-06 乐视控股(北京)有限公司 Barrage display method and device
WO2018001218A1 (en) * 2016-06-27 2018-01-04 北京奇虎科技有限公司 Video playing method, device, program and medium
US20210029410A1 (en) * 2017-08-03 2021-01-28 Live.Me Inc. Method and apparatus for looping a video file
CN110300328A (en) * 2018-03-21 2019-10-01 腾讯科技(深圳)有限公司 A kind of video playing control method, device and readable storage medium storing program for executing
CN109194986A (en) * 2018-08-24 2019-01-11 深圳市酷开网络科技有限公司 A kind of resource control method, smart television and storage medium
CN111641864A (en) * 2019-03-01 2020-09-08 腾讯科技(深圳)有限公司 Video information acquisition method, device and equipment
CN110147512A (en) * 2019-05-16 2019-08-20 腾讯科技(深圳)有限公司 Player preloading, operation method, device, equipment and medium
CN110708602A (en) * 2019-10-15 2020-01-17 北京字节跳动网络技术有限公司 Video starting method and device, electronic equipment and storage medium
CN112416461A (en) * 2020-11-25 2021-02-26 百度在线网络技术(北京)有限公司 Video resource processing method and device, electronic equipment and computer readable medium

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114071229A (en) * 2021-12-08 2022-02-18 四川启睿克科技有限公司 Method for solving recovery delay when surface View renderer reloads video for decoding

Also Published As

Publication number Publication date
CN113411683B (en) 2022-07-22

Similar Documents

Publication Publication Date Title
EP2747373A1 (en) Method and apparatus for managing audio file
CN109840418B (en) Jump control method and device for application program, storage medium and terminal
CN113411683B (en) Video playing method and device
WO2001004743A2 (en) Methods and apparatus for managing an application according to an application lifecycle
CN111782416A (en) Data reporting method, device, system, terminal and computer readable storage medium
CN113467981A (en) Exception handling method and device
KR20140055897A (en) User terminal, reliability management server, and method and program for preventing unauthorized remote operation
CN112702647A (en) Play control method, smart television and computer readable storage medium
CN116244471A (en) Player instance management method and device, electronic equipment and storage medium
CN114238021A (en) SDK interface positioning method, device, equipment and computer storage medium
CN112822322B (en) Mobile terminal muting method and device, mobile terminal and storage medium
CN110888822B (en) Memory processing method, device and storage medium
JP2004094374A (en) Logging system
CN108650544B (en) Media playing method, device and system
CN111356006B (en) Video playing method, device, server and storage medium
CN114025170A (en) Video playing method and device, computer equipment and computer readable storage medium
CN110309647B (en) Processing method and device for application program, electronic equipment and storage medium
CN111580740A (en) Intelligent device control method and device, intelligent device and storage medium
CN110209461B (en) Interface display method and device
KR20080017420A (en) Automatic updating of variables in a data language
CN111639007B (en) Data processing method, device, terminal and computer readable storage medium
CN113225495A (en) Method and device for eliminating video playing noise
CN113867822A (en) Equipment control method and device, electronic equipment and storage medium
WO2017181537A1 (en) Method and device for processing notification message
CN113365112B (en) Remote assistance method and device, electronic equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant