CN115334345A - Animation playing method and device, terminal equipment and storage medium - Google Patents

Animation playing method and device, terminal equipment and storage medium Download PDF

Info

Publication number
CN115334345A
CN115334345A CN202210844452.2A CN202210844452A CN115334345A CN 115334345 A CN115334345 A CN 115334345A CN 202210844452 A CN202210844452 A CN 202210844452A CN 115334345 A CN115334345 A CN 115334345A
Authority
CN
China
Prior art keywords
animation
playing
progress
frame
object model
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.)
Pending
Application number
CN202210844452.2A
Other languages
Chinese (zh)
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 58 Information Technology Co Ltd
Original Assignee
Beijing 58 Information 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 58 Information Technology Co Ltd filed Critical Beijing 58 Information Technology Co Ltd
Priority to CN202210844452.2A priority Critical patent/CN115334345A/en
Publication of CN115334345A publication Critical patent/CN115334345A/en
Pending legal-status Critical Current

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/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/431Generation of visual interfaces for content selection or interaction; Content or additional data rendering
    • H04N21/4312Generation of visual interfaces for content selection or interaction; Content or additional data rendering involving specific graphical features, e.g. screen layout, special fonts or colors, blinking icons, highlights or animations
    • 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/433Content storage operation, e.g. storage operation in response to a pause request, caching operations

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Processing Or Creating Images (AREA)

Abstract

The invention provides an animation playing method, an animation playing device, terminal equipment and a storage medium, and relates to the technical field of image processing. The method comprises the following steps: acquiring a first playing progress corresponding to a first animation frame which is being played in the document object model animation, and an animation playing direction aiming at the document object model animation; determining a second playing progress based on the animation playing direction, the first playing progress and the frame interval progress of the document object model animation; and generating a second animation frame corresponding to the document object model animation according to the second playing progress, and playing the second animation frame. The method and the device can determine the second playing progress corresponding to the animation frame to be played next according to the playing direction of the animation, and enable the target player to start playing the document object model animation from the second playing progress.

Description

Animation playing method and device, terminal equipment and storage medium
Technical Field
The present invention relates to the field of image processing technologies, and in particular, to a method and an apparatus for playing an animation, a terminal device, and a storage medium.
Background
With the continuous progress of the technology, more pages are started to apply the document object model animation, so that more dynamic elements are shown in the pages, and the interaction experience of a user is improved.
When the document object model animation is played, the animation parameters in the document object model animation are read, the animation elements in the document object model animation are rendered frame by frame based on the animation parameters to obtain animation frames, and the animation frames are played in sequence to realize a coherent animation effect.
However, the existing playing method can only render animation frames according to a fixed sequence preset by the document object model, and cannot adjust the playing direction of the animation.
Disclosure of Invention
The embodiment of the invention provides an animation playing method, an animation playing device, terminal equipment and a storage medium, and aims to solve the problem that the playing direction cannot be adjusted when a document object model is played.
In order to solve the technical problem, the invention is realized as follows:
in a first aspect, a method for playing animation includes:
acquiring a first playing progress corresponding to a first animation frame which is being played in a document object model animation and an animation playing direction aiming at the document object model animation, wherein the animation playing direction comprises positive sequence playing and reverse sequence playing;
determining a second playing progress based on the animation playing direction, the first playing progress and a frame interval progress of the document object model animation, wherein the frame interval progress indicates a playing progress difference value corresponding to two adjacent frames in the document object model animation;
and generating a second animation frame of the document object model animation according to the second playing progress, and playing the second animation frame.
Optionally, the method further comprises:
acquiring the total animation duration and the frame interval duration of the document object model animation;
and determining the frame interval progress of the document object model animation according to the total animation duration and the frame interval duration.
Optionally, the method further comprises:
acquiring the frame refreshing interval duration of the page where the document object model animation is located;
and determining the frame interval duration according to the picture refreshing interval duration.
Optionally, the method further comprises:
acquiring a preset playing frame rate for playing the document object model animation;
and determining the frame interval duration according to the preset play frame rate.
Optionally, the method further comprises:
acquiring the initial playing time of the document object model animation and the current playing time corresponding to the first animation frame;
and determining the first playing progress according to the starting playing time, the current playing time and the total animation duration of the document object model animation.
Optionally, the determining a second playing progress based on the animation playing direction, the first playing progress and the frame interval progress of the document object model animation includes:
under the condition that the animation playing direction is the forward playing, calculating a second playing progress according to the sum of the first playing progress and the frame interval progress;
and under the condition that the animation playing direction is the reverse playing, calculating a second playing progress according to the difference value of the first playing progress and the frame interval progress.
Optionally, the generating a second animation frame of the document object model animation according to the second playing progress includes:
acquiring a parameter mapping function corresponding to the animation of the document object model;
inputting the second playing progress into the parameter mapping function to obtain an animation frame parameter output by the parameter mapping function;
and inputting the animation frame parameters and animation elements corresponding to the document object model animation into a renderer to obtain a second animation frame output by the renderer.
Optionally, the method further comprises:
stopping playing the document object model animation when the animation playing direction is the forward playing and the second playing progress is greater than or equal to a first progress threshold;
and stopping playing the document object model animation under the condition that the animation playing direction is the reverse playing and the second playing progress is less than or equal to a second progress threshold.
In a second aspect, an embodiment of the present invention additionally provides an animation playback apparatus, including:
the first obtaining module is used for obtaining a first playing progress corresponding to a first animation frame which is being played in the document object model animation and an animation playing direction aiming at the document object model animation, wherein the animation playing direction comprises forward-order playing and reverse-order playing;
the first progress module is used for determining a second playing progress based on the animation playing direction, the first playing progress and the frame interval progress of the document object model animation, wherein the frame interval progress indicates a playing progress difference value corresponding to two adjacent frames in the document object model animation;
and the playing module is used for generating a second animation frame of the document object model animation according to the second playing progress and playing the second animation frame.
Optionally, the apparatus further comprises:
the second acquisition module is used for acquiring the total animation duration and the frame interval duration of the document object model animation;
and the frame interval progress module is used for determining the frame interval progress of the document object model animation according to the total animation duration and the frame interval duration.
Optionally, the apparatus further comprises:
the page obtaining module is used for obtaining the frame refreshing interval duration of the page where the document object model animation is located;
and the first frame interval duration module is used for determining the frame interval duration according to the picture refreshing interval duration.
Optionally, the apparatus further comprises:
the frame rate acquisition module is used for acquiring a preset playing frame rate for playing the document object model animation;
and the first frame interval duration module is used for determining the frame interval duration according to the preset play frame rate.
Optionally, the apparatus further comprises:
a third obtaining module, configured to obtain an initial playing time of the document object model animation and a current playing time corresponding to the first animation frame;
and the second progress module is used for determining the first playing progress according to the starting playing time, the current playing time and the total animation duration of the document object model animation.
Optionally, the first progress module includes:
the forward playing degree sub-module is used for calculating a second playing progress according to the sum of the first playing progress and the frame interval progress under the condition that the animation playing direction is the forward playing;
and the reverse playing progress sub-module is used for calculating a second playing progress according to the difference value of the first playing progress and the frame interval progress under the condition that the animation playing direction is the reverse playing.
Optionally, the playing module includes:
the function obtaining submodule is used for obtaining a parameter mapping function corresponding to the document object model animation;
the animation frame parameter submodule is used for inputting the second playing progress into the parameter mapping function to obtain animation frame parameters output by the parameter mapping function;
and the animation frame submodule is used for inputting the animation frame parameters and animation elements corresponding to the document object model animation into a renderer to obtain a second animation frame output by the renderer.
Optionally, the apparatus further comprises:
the first stopping module is used for stopping playing the document object model animation under the condition that the animation playing direction is the forward playing and the second playing progress is greater than or equal to a first progress threshold;
and the second stopping module is used for stopping playing the document object model animation under the condition that the animation playing direction is the reverse playing and the second playing progress is less than or equal to a second progress threshold.
In a third aspect, an embodiment of the present invention additionally provides a terminal device, including: a memory, a processor and a computer program stored on the memory and executable on the processor, the computer program, when executed by the processor, implementing the steps of the animation playing method as described in the first aspect.
In a fourth aspect, the embodiment of the present invention further provides a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when executed by a processor, the computer program implements the steps of the animation playing method according to the first aspect.
In the embodiment of the invention, a first playing progress corresponding to a first animation frame which is being played in the document object model animation is obtained, and an animation playing direction aiming at the document object model animation is obtained, wherein the animation playing direction comprises forward-order playing and reverse-order playing; determining a second playing progress based on the animation playing direction, the first playing progress and the frame interval progress of the document object model animation, wherein the frame interval progress indicates a playing progress difference value corresponding to two adjacent frames in the document object model animation; and generating a second animation frame corresponding to the document object model animation according to the second playing progress, and playing the second animation frame. The method and the device can determine the second playing progress corresponding to the animation frame to be played next according to the playing direction of the animation, and enable the target player to start playing the document object model animation from the second playing progress.
The foregoing description is only an overview of the technical solutions of the present invention, and the embodiments of the present invention are described below in order to make the technical means of the present invention more clearly understood and to make the above and other objects, features, and advantages of the present invention more clearly understandable.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the description of the embodiments of the present invention will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art that other drawings can be obtained based on these drawings without inventive labor.
FIG. 1 is a flowchart illustrating steps of a method for playing an animation according to an embodiment of the present invention;
FIG. 2 is a flowchart illustrating specific steps of another animation playing method according to an embodiment of the present invention;
fig. 3 is a schematic structural diagram of an animation playback device according to an embodiment of the present invention;
fig. 4 is a schematic diagram of a hardware structure of a terminal device according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, not all, embodiments of the present invention. All other embodiments, which can be obtained by a person skilled in the art without inventive step based on the embodiments of the present invention, are within the scope of protection of the present invention.
Example one
The animation playing method provided by the embodiment of the invention is described in detail.
Referring to fig. 1, a flowchart illustrating steps of a method for playing an animation according to an embodiment of the present invention is shown.
Step 101, obtaining a first playing progress corresponding to a first animation frame being played in a document object model animation, and an animation playing direction aiming at the document object model animation, wherein the animation playing direction comprises forward-order playing and reverse-order playing.
A Document Object Model (DOM) animation is an animation composed of animation elements and animation frame parameters, such as a control animation in a web page. The document object model can be an animation element, the document object model animation can be obtained by defining animation frame parameters such as transition effect, transition time, transition function, ending condition and the like of the document object model, a renderer (such as a browser animation renderer and a cascading style sheet renderer) can convert and render the document object model by using the animation frame parameters to obtain a plurality of playable animation frames, and the playable animation of the document object model can be realized by displaying the obtained animation frames.
In the embodiment of the present invention, a first playing progress of a first animation frame in the document object model animation, which is being played by the document object model animation, may be obtained, where the first playing progress is used to indicate a progress of the first animation frame in frames completely constituting the document object model animation. For example, if 100 frames of pictures are required for completely playing the document object model animation, and the first animation frame being played at the current time is the 50 th frame, the first playing progress corresponding to the first animation frame is 50%.
The playing direction of the document object model animation refers to whether the document object model animation is currently played in a forward order (namely, in a forward playing mode) or in a reverse order (in a reverse playing mode), it should be noted that the playing direction of the document object model animation may be a preset value or a user-defined value. When the document object model animation is played, a user can adjust the playing direction of the document object model animation through a playing control, a playing instruction and the like, and the playing direction of the document object model animation is set to be played in a positive sequence or played in a reverse sequence according to requirements. For example, a reverse variable may be set in the memory, the playing direction of the document object model animation may be changed by adjusting the value of reverse, setting reverse to false indicates forward, and setting reverse to future indicates reverse.
In the embodiment of the present invention, when each first animation frame of the document object model animation is played, the current playing direction may be obtained, so as to obtain the animation playing direction corresponding to the document object model animation at the moment of playing the first animation frame.
And 102, determining a second playing progress based on the animation playing direction, the first playing progress and the frame interval progress of the document object model animation, wherein the frame interval progress indicates a playing progress difference value corresponding to two adjacent frames in the document object model animation.
The frame interval progress of the document object model animation refers to a difference value of corresponding playing progress of two adjacent animation frames in the document object model animation. For example, if the document object model animation has 100 frames, the playing progress is 0% when the document object model animation is not started to play, the corresponding playing progress is 1% when the first frame is played, the corresponding playing progress is 99% when the 99 th frame is played, the corresponding playing progress is 100% when the 100 th frame is played, and the frame interval progress of the document object model animation can be determined to be 1% because the 99 th frame and the 100 th frame are adjacent frames in the document object model animation.
In the embodiment of the invention, the second playing progress corresponding to the next picture frame to be played can be calculated according to the first playing progress, the frame interval progress and the animation playing direction. Specifically, the second playing progress can be obtained by adding or subtracting the frame interval progress from the first playing progress based on the animation playing direction. That is, when the animation playing direction is forward playing, the next frame should play the frame following the progress of the currently playing frame in the document object model animation, and when the animation playing direction is reverse playing, in order to achieve the reverse playing effect, the next frame should play the frame preceding the progress of the currently playing frame in the document object model animation.
For example, if the frame interval progress of the document object model animation is 1%, the first playing progress corresponding to the current playing frame is 10%, and in the case that the animation playing direction is positive order playing, the second playing progress corresponding to the animation frame that needs to be played next frame is 10% +1% =11%. Under the condition that the animation playing direction is reverse playing, the second playing progress corresponding to the animation frame needing to be played in the next frame is 10% -1% =9%.
And 103, generating a second animation frame of the document object model animation according to the second playing progress, and playing the second animation frame.
In order to enable a user to adjust the playing direction of the document object model animation, in the embodiment of the invention, the animation frame parameter corresponding to the second playing progress can be determined according to the progress-parameter conversion relation corresponding to the document object model animation, so that the animation element of the document object model animation is rendered according to the animation frame parameter to obtain the second animation frame.
The progress-parameter conversion relation comprises a corresponding relation between the playing progress and the animation frame parameters. The corresponding relation may be in a list form, a plurality of playing schedules may be defined in the corresponding relation at fixed intervals, and animation frame parameters corresponding to each playing schedule are set.
For example, the animation element of a document object model animation is a small sphere, and the corresponding progress-parameter transformation relationship includes 100 playing progress values n%, where n is an integer of [0,100], and each playing progress value corresponds to a small sphere radius, for example, a small sphere radius corresponding to a playing progress value of 10% is 1.1, a small sphere radius corresponding to a playing progress value of 20% is 1.2, and so on. Under the condition that the second playing progress is 20%, the corresponding radius of the small ball is determined to be 1.2 through the progress-parameter conversion relation, and at the moment, the small ball can be rendered according to the radius of the small ball being 1.2 to obtain a second animation frame, and the second animation frame is played.
It should be noted that after playing a second animation frame corresponding to the second playing progress in the document object model animation, subsequent animation frames also need to be played, so that after playing the second animation frame, the first animation frame being played changes, and at this time, the second animation frame is a new first animation frame. That is to say, in the embodiment of the present invention, each time a new animation frame is played, a playing progress corresponding to an animation frame to be played next needs to be calculated according to the new animation frame, and the next animation frame is generated, so as to implement continuous playing of the document object model animation.
In summary, the animation playing method provided by the present invention includes: acquiring a first playing progress corresponding to a first animation frame which is being played in the document object model animation, and an animation playing direction aiming at the document object model animation, wherein the animation playing direction comprises forward-order playing and reverse-order playing; determining a second playing progress based on the animation playing direction, the first playing progress and the frame interval progress of the document object model animation, wherein the frame interval progress indicates a playing progress difference value corresponding to two adjacent frames in the document object model animation; and generating a second animation frame corresponding to the document object model animation according to the second playing progress, and playing the second animation frame. The method and the device can determine the second playing progress corresponding to the animation frame to be played next according to the playing direction of the animation, and enable the target player to start playing the document object model animation from the second playing progress.
Example two
Another animation playing method provided by the embodiment of the invention is described in detail.
Referring to fig. 2, fig. 2 is a flowchart illustrating specific steps of another animation playing method according to an embodiment of the present invention, which may include the following steps:
step 201, obtaining the total animation duration and the frame interval duration of the document object model animation.
In general, the total animation duration of the animation of the document object model animation is stored as an attribute of the animation in a file of the document object model animation. For example, in the case where the document object model animation is a DOM animation, the animation-duration attribute of the document object model animation may be acquired to acquire the animation total duration of the document object model animation.
In the embodiment of the present invention, the frame interval duration may be calculated from the total animation duration and the total frame number of the document object model animation. For example, if the total animation time of the document object model animation is 5 seconds and the total frame number is 100 frames, the frame interval time thereof can be calculated to be 5/100=0.05 seconds.
For some document object model animations composed of graphic elements and animation frame parameters, since the animation frames are calculated according to the graphic elements and animation frame parameters during playing, the total frame number cannot be obtained in advance, and the frame interval duration can be determined by the following method in sub-steps 2011 to 2012, or in sub-step 2013 or sub-step 2014.
Optionally, step 201 may further include:
in the sub-step 2011, the frame refresh interval duration of the page where the document object model animation is located is obtained.
Because the document object model animation is an animation object in the pages such as the browser page, the application page and the like, in order to achieve the optimal display effect and smoothness, the frame rate of the document object model animation during playing can be the same as the refresh rate of the page where the document object model animation is located.
Therefore, the screen refresh interval duration of the page where the document object model animation is located can be acquired at the beginning of the document object model animation. Specifically, the time points of two adjacent image refreshes of the current page may be obtained, and the difference between the two time points may be calculated to obtain the image refresh interval duration of the page where the document object model animation is located.
Furthermore, because the frame refreshing interval duration of the current page is not stable and constant due to reasons such as the operational load, in order to enable the frame rate of the document object model animation during playing to adapt to the refreshing rate of the current page in real time, the frame refreshing interval duration of the current page can be obtained again every time a new frame is played. Specifically, a first time corresponding to playing of the first animation frame may be recorded, a second time corresponding to the latest refreshing of the current page before the playing of the first animation frame is recorded, and the frame refreshing interval duration may be calculated according to a difference between the first time and the second time.
And a substep 2012 of determining said frame interval duration according to said picture refresh interval duration.
In the embodiment of the present invention, the obtained frame refreshing interval duration may be directly determined as the frame interval duration, and the frame rate of playing the animation may be synchronized with the frame refreshing rate of the current page by rendering and playing the second animation frame according to the frame interval duration subsequently.
Further, since the frame refresh rate of the current page is generally high, the frequency of rendering animation frames is high, and in order to reduce the amount of operation for playing the document object model animation, the product of the frame refresh interval duration and the preset fixed coefficient may also be used as the frame interval duration. For example, under the condition that the preset fixed coefficient is 2, the frame interval duration is 2 times of the picture refreshing interval duration, and the animation frame needs to be rendered again every time the picture of the current page is refreshed twice, so that the operation amount of playing the document object model animation is reduced.
Optionally, step 201 may further include:
and a substep 2013 of obtaining a preset playing frame rate for playing the document object model animation.
In the embodiment of the present invention, the frame interval duration may also be determined according to a preset play frame rate set by a user or a system, before playing the document object model animation, the user may set the preset play frame rate as needed, for example, 20 frames/second, 30 frames/second, and the like, and also, in the process of playing the document object model animation, an adjustment control for adjusting the preset play frame rate may be provided to the user, for example, an adjustment slider of the preset play frame rate may be provided to the user.
If the preset play frame rate is not adjustable in the process of playing the document object model animation, the preset play frame rate can be obtained once only before the document object model is played, and if the preset play frame rate is adjustable in the process of playing the document object model animation, the preset play frame rate can be obtained once after the preset play frame rate is adjusted each time or after each frame of animation frame is played.
And a sub-step 2014 of determining the frame interval duration according to the preset play frame rate.
After the preset play frame rate is obtained, the reciprocal of the preset play frame rate may be calculated, and the reciprocal is determined as the frame interval duration. For example, in the case that the preset playback frame rate is 20 frames/second, 1/20, that is, 0.05, may be determined as the frame interval duration.
In the embodiment of the invention, a plurality of methods for determining the frame interval duration of the played document object model animation are provided, the frame interval duration can be determined according to the refresh rate of the current page, the frame interval duration can also be determined according to the preset playing frame rate, the frequency of subsequent rendered animation frames can be adjusted according to actual needs, and the effect of reducing the operation amount consumed by playing the document object model animation can be achieved.
Step 202, determining the frame interval progress of the document object model animation according to the total animation duration and the frame interval duration.
After the total animation duration and the frame interval duration of the document object model animation are obtained, the frame interval progress of the document object model animation can be obtained. Specifically, the quotient of the frame interval duration and the animation total duration may be used as the frame interval progress of the document object model animation. For example, if the frame interval duration of a document object model animation is 0.05 seconds and the total animation duration is 5 seconds, the frame interval progress is 0.05/5=1%.
In the embodiment of the invention, under the condition that the document object model animation is composed of graphic elements and animation frame parameters, as the total frame number cannot be obtained, the frame interval progress can be calculated through the frame interval duration and the animation total duration of the document object model animation, and the application range of the frame interval progress calculating method is wider.
Step 203, obtaining a first playing progress corresponding to a first animation frame being played in the document object model animation, and an animation playing direction aiming at the document object model animation.
In the embodiment of the present invention, in order to render a next frame of the first animation frame, that is, the second animation frame, a first playing progress corresponding to the first animation frame needs to be obtained. In one embodiment, after the animation is started to play, the number of accumulated animation frames to play may be recorded, and the first playing progress corresponding to the first animation frame currently playing may be determined according to the product of the number and the frame interval progress. For example, in the case where the frame interval progress is 1% and the playback is in the forward order, if the first animation frame is the 20 th frame of the cumulative playback, the first playback progress corresponding to the first animation frame is 20%.
It should be noted that, in the embodiment of the present invention, the playing progress corresponding to the animation frame refers to a playing progress when the animation frame is played in the forward direction. If the current playing is the reverse playing, the animation frame corresponding to the maximum playing progress is played from the animation frame corresponding to the maximum playing progress to the animation frame corresponding to the minimum playing progress, and in this case, if the frame interval progress is 1% and the first animation frame is the 20 th frame of the accumulated playing, the first playing progress corresponding to the first animation frame is 80%.
When the document object model animation is started to be played, the playing direction of the document object model animation can be obtained, if the playing direction of the document object model animation is positive order playing, the document object model animation can be played from the position of 0 playing progress, and at the moment, the first animation frame which is played at the beginning is the first frame of the document object model animation; if the playing direction of the document object model animation is the reverse playing, the document object model animation can be played from the position of 100% playing progress, and the first animation frame played at the beginning is the last frame of the document object model animation.
Further, if the document object model animation is in a paused state before the playback is started, the document object model animation may be played from the playback progress corresponding to the paused position.
In the embodiment of the invention, when the document object model animation is started to be played, if the playing direction is read to be played in a positive sequence, a playing progress of 0 can be transmitted to the target player, so that the target player can play the first frame animation frame of the document object model animation from the beginning; if the playing direction is read to be played in the reverse order, the playing progress of 100% can be transferred to the target player, so that the target player starts playing the last animation frame of the document object model animation from the end. The initial play progress set by the user or the play progress at the current animation pause position may also be sent to the document object model animation frame, so that the target player starts playing the document object model animation from the initial play progress or the play progress at the current animation pause position.
After the document object model animation starts to play, a first playing progress corresponding to a first animation frame playing in the document object model animation and an animation playing direction aiming at the document object model animation can be obtained.
Optionally, step 203 may further include:
in the sub-step 2031, the starting playing time of the animation of the document object model and the current playing time corresponding to the first animation frame are obtained.
In the embodiment of the present invention, the first playing progress may be further determined according to the starting playing time of the document object model animation, the current playing time corresponding to the first animation frame, and the total animation duration of the document object model animation.
Specifically, when the document starts to be played, the current time may be recorded as the start playing time, and when the first animation frame is played, the current playing time is recorded.
And a substep 2032 of determining the first playing progress according to the starting playing time, the current playing time and the total animation duration of the document object model animation.
In the case that the animation playing direction is the forward playing, the following formula 1 may be adopted to calculate the first playing progress corresponding to the first animation frame.
Figure BDA0003751552100000131
Wherein t1 is the current playing time corresponding to the first animation frame, t0 is the initial playing time, duration is the total animation duration, and nowProgress is the first playing progress corresponding to the first animation frame.
In the case that the animation playing direction is reverse playing, the following formula 2 may be used to calculate the first playing progress corresponding to the first animation frame.
Figure BDA0003751552100000132
Wherein t1 is the current playing time corresponding to the first animation frame, t0 is the initial playing time, duration is the total animation duration, and nowProgress is the first playing progress corresponding to the first animation frame.
And 204, under the condition that the animation playing direction is the forward playing, calculating a second playing progress according to the sum of the first playing progress and the frame interval progress.
After a first playing progress corresponding to the first animation frame in the document object model animation is obtained, a playing direction corresponding to the document object model animation at present can be obtained, and if the playing direction is positive order playing, a second playing progress can be determined according to the sum of the first playing progress and the frame interval progress.
For example, if the first playing progress corresponding to the first animation frame is 20%, the frame interval progress is 1%, and the current playing direction is in the forward direction, the second playing progress is 20% +1% =21%.
Step 205, calculating a second playing progress according to the difference between the first playing progress and the frame interval progress under the condition that the animation playing direction is the reverse playing.
If the playing direction is reverse playing, the second playing progress can be determined according to the difference between the first playing progress and the frame interval progress.
For example, if the first playing progress corresponding to the first animation frame is 20%, the frame interval progress is 1%, and the current playing direction is reverse, the second playing progress is 20% -1% =19%.
In the embodiment of the invention, the second playing progress corresponding to the next frame of target picture to be played in the document object model animation can be calculated according to the playing state of the current document object model animation, and the second playing progress is transmitted to the target player in the subsequent steps, so that the forward playing and reverse playing effects of the document object model animation are realized, whether the target player has a reverse playing function or not is not required to be considered, and the flexibility of playing the document object model animation is improved.
And step 206, generating a second animation frame of the document object model animation according to the second playing progress.
This step can be referred to as step 103, and is not described in detail in the embodiments of the present invention.
Optionally, step 206 may further include:
in sub-step 2061, a parameter mapping function corresponding to the animation of the document object model is obtained.
In the embodiment of the present invention, the progress-parameter conversion relationship may also be defined by a parameter mapping function, and the corresponding play frame parameter may be directly calculated according to the play progress by setting the parameter mapping function in which the animation frame parameter changes along with the play progress.
Different document object model animations may correspond to different one or more parameter mapping functions, and the parameter mapping functions may be bound to the corresponding document object model animations, and the corresponding parameter mapping functions are invoked when the document object model is played.
For example, the animation element of a certain document object model animation is a small ball, and the corresponding progress-parameter conversion relationship may include a parameter mapping function for describing the relationship between the radius of the small ball and the change of the playing progress: y = X +1, wherein X represents the playing progress, the value range of X is [0,1], Y represents the radius of the small ball, and the value range is [1,2].
And a substep 2062 of inputting the second playing progress into the parameter mapping function to obtain the animation frame parameters output by the parameter mapping function.
For example, the animation element of a document object model animation is a small sphere, and the corresponding progress-parameter conversion relationship includes a function for describing the relationship between the radius of the small sphere and the change of the playing progress: y = X +1, wherein X represents the playing progress, the value range of X is [0,1], Y represents the radius of the small ball, and the value range is [1,2], in the process that the playing progress is changed from 0 to 100%, the radius of the small ball is increased from 1 to 2, the animation effect of the document object model animation is a small ball which is gradually increased when the document object model animation is played in a forward sequence, and the animation effect is a small ball which is gradually decreased when the document object model animation is played in a reverse sequence. In the process of playing the document object model animation, if the calculated second playing progress is 10%, the diameter of the animation frame parameter corresponding to the second playing progress can be calculated to be 1.1 through the function, and the diameter can be transmitted to the renderer, so that the renderer renders the small balls according to the diameter to obtain a second animation frame corresponding to the second playing progress, and the second animation frame is played.
In sub-step 2063, the animation frame parameters and the animation elements corresponding to the animation of the document object model are input into the renderer, and the second animation frame output by the renderer is obtained.
Because the renderer renders all objects in the page when the page is refreshed, wherein the objects include the document object model animation in the page, under the condition that the frame interval duration is the same as the picture refreshing interval duration of the page, the animation frame parameters can be immediately sent to the renderer after the animation frame parameters are obtained, and a second animation frame is rendered when the renderer renders the page next time, so that the effect of synchronizing the frame rate of the second animation frame and the page is achieved.
Furthermore, when some renderers render the animation of the document object model, if the fact that the frame parameters of the image animation to be rendered currently are the same as the frame parameters of the animation rendered in the previous frame is detected, the rendering is skipped, and resource waste caused by repeated rendering is avoided. Therefore, in the embodiment of the present invention, if the frame interval duration is greater than the frame refresh interval duration of the page, after obtaining the animation frame parameter, the animation frame parameter may not be sent to the renderer temporarily, but the animation frame parameter may be sent to the renderer after the duration of playing the first animation frame reaches the frame interval duration, so as to meet the requirement of the user for playing the document object model animation at a lower frame rate.
In the embodiment of the invention, the energy-saving mechanism of the renderer can be utilized to enable the renderer to render the animation frame of the document object model animation at a lower frequency, so that the resource consumption of the renderer to render the animation frame of the document object model animation is reduced, and the cruising ability of the mobile equipment is improved.
It should be noted that after the step 206 is completed, the second animation frame is played, and the first animation frame being played is updated, and the step 203 may be skipped to re-determine the second animation frame to be played for the next frame, so that the document object model animation may be continuously played.
And step 207, stopping playing the document object model animation when the animation playing direction is the forward playing and the second playing progress is greater than or equal to a first progress threshold.
In the embodiment of the invention, after the animation of the document object model is played according to the animation playing direction, the animation of the document object model can be controlled to stop playing.
Specifically, if the playing direction is forward-order playing, the second playing progress calculated at the time of playing each first animation frame is continuously increased while the document object model animation is played, and if the second playing progress exceeds 100%, it indicates that the forward-order playing of the document object model animation has been completed, and at this time, the playing of the document object model animation may be stopped.
It should be noted that the first progress threshold may be 100% to stop playing when the document object model animation is completely played in the forward order, and the first progress threshold may also be less than 100%, for example, the first progress threshold may be 10% to stop playing after 10% of the content of the document object model animation is played in the forward order, so as to implement the function of previewing the document object model animation. The first progress threshold may be flexibly adjusted by a user and/or a technician according to actual needs, which is not specifically limited in the embodiment of the present invention.
In addition, each document object model animation can be provided with a corresponding playing stopping method, when the playing of the animation needs to be stopped, the playing stopping method corresponding to the document object model animation can be called, and the playing of the document object model animation can be finished according to the mode required by a user through the playing stopping method.
For example, the method for stopping playing may be to hide the document object model animation, call other document object model animations, call other pictures, or the like.
And 208, stopping playing the document object model animation when the animation playing direction is the reverse playing and the second playing progress is less than or equal to a second progress threshold.
If the playing direction is reverse playing, the second playing progress calculated during the playing of each first animation frame is continuously reduced when the document object model animation is played, if the second playing progress is less than 0, the reverse playing of the document object model animation is completed, and at this time, the playing of the document object model animation can be stopped.
It should be noted that the second progress threshold may be 0 to stop playing when the document object model animation is played in the complete reverse order, and the second progress threshold may also be greater than 0, for example, the second progress threshold may be 10% to stop playing after 10% of the content of the document object model animation is played in the forward order, so as to implement the function of previewing the document object model animation. The first progress threshold may be flexibly adjusted by a user and/or a technician according to actual needs, which is not specifically limited in the embodiment of the present invention.
In summary, another animation playing method provided by the present invention obtains a first playing progress corresponding to a first animation frame being played in a document object model animation in the document object model animation, and an animation playing direction for the document object model animation, wherein the animation playing direction includes forward playing and reverse playing; determining a second playing progress based on the animation playing direction, the first playing progress and the frame interval progress of the document object model animation, wherein the frame interval progress indicates a playing progress difference value corresponding to two adjacent frames in the document object model animation; and generating a second animation frame corresponding to the document object model animation according to the second playing progress, and playing the second animation frame. The method and the device can determine the second playing progress corresponding to the animation frame to be played next according to the playing direction of the animation, and enable the target player to start playing the document object model animation from the second playing progress.
EXAMPLE III
An animation playback device according to an embodiment of the present invention is described in detail.
Referring to fig. 3, a schematic structural diagram of an animation playback device according to an embodiment of the present invention is shown, as shown in fig. 3:
the animation playing device of the embodiment of the invention comprises: a first obtaining module 501, a first progress module 502 and a playing module 503.
The functions of the modules and the interaction relationship between the modules are described in detail below.
The first obtaining module is used for obtaining a first playing progress corresponding to a first animation frame which is being played in the document object model animation and an animation playing direction aiming at the document object model animation, wherein the animation playing direction comprises forward-order playing and reverse-order playing;
the first progress module is used for determining a second playing progress based on the animation playing direction, the first playing progress and the frame interval progress of the document object model animation, wherein the frame interval progress indicates a playing progress difference value corresponding to two adjacent frames in the document object model animation;
and the playing module is used for generating a second animation frame of the document object model animation according to the second playing progress and playing the second animation frame.
Optionally, the apparatus further comprises:
the second acquisition module is used for acquiring the total animation duration and the frame interval duration of the document object model animation;
and the frame interval progress module is used for determining the frame interval progress of the document object model animation according to the total animation duration and the frame interval duration.
Optionally, the apparatus further comprises:
the page acquisition module is used for acquiring the frame refreshing interval duration of the page where the document object model animation is located;
and the first frame interval time length module is used for determining the frame interval time length according to the picture refreshing interval time length.
Optionally, the apparatus further comprises:
the frame rate acquisition module is used for acquiring a preset playing frame rate for playing the document object model animation;
and the first frame interval duration module is used for determining the frame interval duration according to the preset play frame rate.
Optionally, the apparatus further comprises:
a third obtaining module, configured to obtain an initial playing time of the document object model animation and a current playing time corresponding to the first animation frame;
and the second progress module is used for determining the first playing progress according to the starting playing time, the current playing time and the total animation duration of the document object model animation.
Optionally, the first progress module includes:
the forward playing degree submodule is used for calculating a second playing progress according to the sum of the first playing progress and the frame interval progress under the condition that the animation playing direction is the forward playing;
and the reverse playing progress sub-module is used for calculating a second playing progress according to the difference value of the first playing progress and the frame interval progress under the condition that the animation playing direction is the reverse playing.
Optionally, the playing module includes:
the function obtaining submodule is used for obtaining a parameter mapping function corresponding to the document object model animation;
the animation frame parameter submodule is used for inputting the second playing progress into the parameter mapping function to obtain animation frame parameters output by the parameter mapping function;
and the animation frame submodule is used for inputting the animation frame parameters and animation elements corresponding to the document object model animation into a renderer to obtain a second animation frame output by the renderer.
Optionally, the apparatus further comprises:
the first stopping module is used for stopping playing the document object model animation under the condition that the animation playing direction is the forward playing and the second playing progress is greater than or equal to a first progress threshold;
and the second stopping module is used for stopping playing the document object model animation under the condition that the animation playing direction is the reverse playing and the second playing progress is less than or equal to a second progress threshold.
To sum up, the present invention provides an animation playback device, comprising: the first obtaining module is used for obtaining a corresponding first playing progress of a first animation frame which is playing in the document object model animation and an animation playing direction aiming at the document object model animation, wherein the animation playing direction comprises forward playing and reverse playing; the first progress module is used for determining a second playing progress based on the animation playing direction, the first playing progress and the frame interval progress of the document object model animation, wherein the frame interval progress indicates a playing progress difference value corresponding to two adjacent frames in the document object model animation; and the playing module is used for generating a second animation frame corresponding to the document object model animation according to the second playing progress and playing the second animation frame. The invention can determine the second playing progress corresponding to the next animation frame to be played according to the animation playing direction, and enables the target player to play the document object model animation from the second playing progress.
Example four
Fig. 4 is a schematic diagram of a hardware structure of a terminal device for implementing various embodiments of the present invention.
The terminal device 600 includes but is not limited to: radio frequency unit 601, network module 602, audio output unit 603, input unit 604, sensor 605, display unit 606, user input unit 607, interface unit 608, memory 609, processor 610, and power 611. Those skilled in the art will appreciate that the terminal device configuration shown in fig. 4 does not constitute a limitation of the terminal device, and that the terminal device may include more or fewer components than shown, or some components may be combined, or a different arrangement of components. In the embodiment of the present invention, the terminal device includes, but is not limited to, a mobile phone, a tablet computer, a notebook computer, a palm computer, a vehicle-mounted terminal, a wearable device, a pedometer, and the like.
It should be understood that, in the embodiment of the present invention, the radio frequency unit 601 may be used for receiving and sending signals during a message sending and receiving process or a call process, and specifically, receives downlink data from a base station and then processes the received downlink data to the processor 610; in addition, uplink data is transmitted to the base station. Generally, radio frequency unit 601 includes, but is not limited to, an antenna, at least one amplifier, a transceiver, a coupler, a low noise amplifier, a duplexer, and the like. Further, the radio frequency unit 601 may also communicate with a network and other devices through a wireless communication system.
The terminal device provides the user with wireless broadband internet access through the network module 602, such as helping the user send and receive e-mails, browse webpages, access streaming media, and the like.
The audio output unit 603 may convert audio data received by the radio frequency unit 601 or the network module 602 or stored in the memory 609 into an audio signal and output as sound. Also, the audio output unit 603 can also provide audio output related to a specific function performed by the terminal apparatus 600 (e.g., a call signal reception sound, a message reception sound, etc.). The audio output unit 603 includes a speaker, a buzzer, a receiver, and the like.
The input unit 604 is used to receive audio or video signals. The input Unit 604 may include a Graphics Processing Unit (GPU) 6041 and a microphone 6042, and the Graphics processor 6041 processes image data of a still picture or video obtained by an image capturing apparatus (such as a camera) in a video capture mode or an image capture mode. The processed image frames may be displayed on the display unit 606. The image frames processed by the graphic processor 6041 may be stored in the memory 609 (or other storage medium) or transmitted via the radio frequency unit 601 or the network module 602. The microphone 6042 can receive sound, and can process such sound into audio data. The processed audio data may be converted into a format output transmittable to a mobile communication base station via the radio frequency unit 601 in case of the phone call mode.
The terminal device 600 further comprises at least one sensor 605, such as a light sensor, a motion sensor, and other sensors. Specifically, the light sensor includes an ambient light sensor that can adjust the luminance of the display panel 6061 according to the brightness of ambient light, and a proximity sensor that can turn off the display panel 6061 and/or the backlight when the terminal apparatus 600 is moved to the ear. As one of the motion sensors, the accelerometer sensor can detect the magnitude of acceleration in each direction (generally three axes), detect the magnitude and direction of gravity when stationary, and can be used to identify the attitude of the terminal device (such as horizontal and vertical screen switching, related games, magnetometer attitude calibration), and vibration identification related functions (such as pedometer and tapping); the sensors 605 may also include fingerprint sensors, pressure sensors, iris sensors, molecular sensors, gyroscopes, barometers, hygrometers, thermometers, infrared sensors, etc., which are not described in detail herein.
The display unit 606 is used to display information input by the user or information provided to the user. The Display unit 606 may include a Display panel 6061, and the Display panel 6061 may be configured by a Liquid Crystal Display (LCD), an Organic Light-Emitting Diode (OLED), or the like.
The user input unit 607 may be used to receive input numeric or character information and generate key signal inputs related to user settings and function control of the terminal device. Specifically, the user input unit 607 includes a touch panel 6071 and other input devices 6072. Touch panel 6071, also referred to as a touch screen, may collect touch operations by a user on or near it (e.g., operations by a user on or near touch panel 6071 using a finger, stylus, or any suitable object or accessory). The touch panel 6071 may include two parts of a touch detection device and a touch controller. The touch detection device detects the touch direction of a user, detects a signal brought by touch operation and transmits the signal to the touch controller; the touch controller receives touch information from the touch sensing device, converts the touch information into touch point coordinates, sends the touch point coordinates to the processor 610, receives a command from the processor 610, and executes the command. In addition, the touch panel 6071 can be implemented by various types such as a resistive type, a capacitive type, an infrared ray, and a surface acoustic wave. The user input unit 607 may include other input devices 6072 in addition to the touch panel 6071. Specifically, the other input devices 6072 may include, but are not limited to, a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a track ball, a mouse, and a joystick, which are not described herein again.
Further, the touch panel 6071 can be overlaid on the display panel 6061, and when the touch panel 6071 detects a touch operation thereon or nearby, the touch operation can be transmitted to the processor 610 to determine the type of the touch event, and then the processor 610 can provide a corresponding visual output on the display panel 6061 according to the type of the touch event. Although in fig. 4, the touch panel 6071 and the display panel 6061 are two independent components to implement the input and output functions of the terminal device, in some embodiments, the touch panel 6071 and the display panel 6061 may be integrated to implement the input and output functions of the terminal device, which is not limited herein.
The interface unit 608 is an interface through which an external device is connected to the terminal apparatus 600. For example, the external device may include a wired or wireless headset port, an external power supply (or battery charger) port, a wired or wireless data port, a memory card port, a port for connecting a device having an identification module, an audio input/output (I/O) port, a video I/O port, an earphone port, and the like. The interface unit 608 may be used to receive input (e.g., data information, power, etc.) from an external device and transmit the received input to one or more elements within the terminal apparatus 600 or may be used to transmit data between the terminal apparatus 600 and an external device.
The memory 609 may be used to store software programs as well as various data. The memory 609 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application program required by at least one function (such as a sound playing function, an image playing function, etc.), and the like; the storage data area may store data (such as audio data, a phonebook, etc.) created according to the use of the cellular phone, etc. Further, the memory 609 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device.
The processor 610 is a control center of the terminal device, connects various parts of the entire terminal device by using various interfaces and lines, and performs various functions of the terminal device and processes data by running or executing software programs and/or modules stored in the memory 609 and calling data stored in the memory 609, thereby performing overall monitoring of the terminal device. Processor 610 may include one or more processing units; preferably, the processor 610 may integrate an application processor, which mainly handles operating systems, user interfaces, application programs, etc., and a modem processor, which mainly handles wireless communications. It will be appreciated that the modem processor described above may not be integrated into the processor 610.
The terminal device 600 may further include a power supply 611 (such as a battery) for supplying power to various components, and preferably, the power supply 611 may be logically connected to the processor 610 through a power management system, so as to implement functions of managing charging, discharging, and power consumption through the power management system.
In addition, the terminal device 600 includes some functional modules that are not shown, and are not described in detail here.
Preferably, an embodiment of the present invention further provides a terminal device, including: the processor 610, the memory 609, and a computer program stored in the memory 609 and capable of running on the processor 610, where the computer program, when executed by the processor 610, implements each process of the above animation playing method embodiment, and can achieve the same technical effect, and in order to avoid repetition, details are not described here again.
The embodiment of the present invention further provides a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when being executed by a processor, the computer program implements each process of the above animation playing method embodiment, and can achieve the same technical effect, and in order to avoid repetition, details are not repeated here. The computer-readable storage medium may be a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk.
It should be noted that, in this document, 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 one of 8230, and" comprising 8230does not exclude the presence of additional like elements in a process, method, article, or apparatus comprising the element.
Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such understanding, the technical solutions of the present invention may be embodied in the form of a software product, which is stored in a storage medium (such as ROM/RAM, magnetic disk, optical disk) and includes instructions for enabling a terminal (such as a mobile phone, a computer, a server, an air conditioner, or a network device) to execute the method according to the embodiments of the present invention.
While the present invention has been described with reference to the embodiments shown in the drawings, the present invention is not limited to the embodiments, which are illustrative and not restrictive, and it will be apparent to those skilled in the art that various changes and modifications can be made therein without departing from the spirit and scope of the invention as defined in the appended claims.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the technical solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described systems, apparatuses and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the embodiments provided in the present invention, it should be understood that the disclosed apparatus and method may be implemented in other manners. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the units is only one logical division, and other divisions may be realized in practice, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one position, or may be distributed on multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit.
The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention or a part thereof which substantially contributes to the prior art may be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: various media capable of storing program codes, such as a U disk, a removable hard disk, a ROM, a RAM, a magnetic disk, or an optical disk.
The above description is only for the specific embodiments of the present invention, but the scope of the present invention is not limited thereto, and any person skilled in the art can easily think of the changes or substitutions within the technical scope of the present invention, and shall cover the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

Claims (18)

1. An animation playing method, characterized in that the method comprises:
acquiring a first playing progress corresponding to a first animation frame which is being played in the document object model animation and an animation playing direction aiming at the document object model animation, wherein the animation playing direction comprises forward-order playing and reverse-order playing;
determining a second playing progress based on the animation playing direction, the first playing progress and the frame interval progress of the document object model animation, wherein the frame interval progress indicates a playing progress difference value corresponding to two adjacent frames in the document object model animation;
and generating a second animation frame of the document object model animation according to the second playing progress, and playing the second animation frame.
2. The method of claim 1, further comprising:
acquiring the total animation duration and the frame interval duration of the document object model animation;
and determining the frame interval progress of the document object model animation according to the total animation duration and the frame interval duration.
3. The method of claim 2, further comprising:
acquiring the frame refreshing interval duration of the page where the document object model animation is located;
and determining the frame interval duration according to the picture refreshing interval duration.
4. The method of claim 2, further comprising:
acquiring a preset playing frame rate for playing the document object model animation;
and determining the frame interval duration according to the preset play frame rate.
5. The method of claim 1, further comprising:
acquiring the initial playing time of the document object model animation and the current playing time corresponding to the first animation frame;
and determining the first playing progress according to the starting playing time, the current playing time and the total animation duration of the document object model animation.
6. The method of claim 1, wherein determining a second playback progress based on the animation playback direction, the first playback progress, and the frame interval progress of the document object model animation comprises:
under the condition that the animation playing direction is the forward playing, calculating a second playing progress according to the sum of the first playing progress and the frame interval progress;
and under the condition that the animation playing direction is the reverse playing, calculating a second playing progress according to the difference value of the first playing progress and the frame interval progress.
7. The method of claim 1, wherein generating a second animation frame of the document object model animation according to the second playback progress comprises:
acquiring a parameter mapping function corresponding to the animation of the document object model;
inputting the second playing progress into the parameter mapping function to obtain an animation frame parameter output by the parameter mapping function;
inputting the animation frame parameters and animation elements corresponding to the document object model animation into a renderer to obtain a second animation frame output by the renderer.
8. The method of claim 1, further comprising:
stopping playing the document object model animation under the condition that the animation playing direction is the forward playing and the second playing progress is greater than or equal to a first progress threshold;
and stopping playing the document object model animation under the condition that the animation playing direction is the reverse playing and the second playing progress is less than or equal to a second progress threshold.
9. An animation playback apparatus, characterized in that the apparatus comprises:
the device comprises a first acquisition module, a second acquisition module and a display module, wherein the first acquisition module is used for acquiring a first playing progress corresponding to a first animation frame which is playing in a document object model animation and an animation playing direction aiming at the document object model animation, and the animation playing direction comprises forward playing and reverse playing;
the first progress module is used for determining a second playing progress based on the animation playing direction, the first playing progress and the frame interval progress of the document object model animation, wherein the frame interval progress indicates a playing progress difference value corresponding to two adjacent frames in the document object model animation;
and the playing module is used for generating a second animation frame of the document object model animation according to the second playing progress and playing the second animation frame.
10. The apparatus of claim 9, further comprising:
the second acquisition module is used for acquiring the total animation duration and the frame interval duration of the document object model animation;
and the frame interval progress module is used for determining the frame interval progress of the document object model animation according to the total animation duration and the frame interval duration.
11. The apparatus of claim 10, further comprising:
the page obtaining module is used for obtaining the frame refreshing interval duration of the page where the document object model animation is located;
and the first frame interval duration module is used for determining the frame interval duration according to the picture refreshing interval duration.
12. The apparatus of claim 10, further comprising:
a frame rate obtaining module, configured to obtain a preset play frame rate for playing the document object model animation;
and the first frame interval duration module is used for determining the frame interval duration according to the preset play frame rate.
13. The apparatus of claim 9, further comprising:
a third obtaining module, configured to obtain an initial playing time of the document object model animation and a current playing time corresponding to the first animation frame;
and the second progress module is used for determining the first playing progress according to the starting playing time, the current playing time and the total animation duration of the document object model animation.
14. The apparatus of claim 9, wherein the first schedule module comprises:
the forward playing degree submodule is used for calculating a second playing progress according to the sum of the first playing progress and the frame interval progress under the condition that the animation playing direction is the forward playing;
and the reverse playing progress sub-module is used for calculating a second playing progress according to the difference value of the first playing progress and the frame interval progress under the condition that the animation playing direction is the reverse playing.
15. The apparatus of claim 9, wherein the playback module comprises:
the function obtaining sub-module is used for obtaining a parameter mapping function corresponding to the document object model animation;
the animation frame parameter submodule is used for inputting the second playing progress into the parameter mapping function to obtain animation frame parameters output by the parameter mapping function;
and the animation frame submodule is used for inputting the animation frame parameters and animation elements corresponding to the document object model animation into a renderer to obtain a second animation frame output by the renderer.
16. The apparatus of claim 9, further comprising:
the first stopping module is used for stopping playing the document object model animation under the condition that the animation playing direction is the forward playing and the second playing progress is greater than or equal to a first progress threshold;
and the second stopping module is used for stopping playing the document object model animation under the condition that the animation playing direction is the reverse playing and the second playing progress is less than or equal to a second progress threshold.
17. A terminal device, comprising: memory, processor and computer program stored on the memory and executable on the processor, which computer program, when executed by the processor, carries out the steps of the animation playback method as claimed in any one of claims 1 to 8.
18. A computer-readable storage medium, characterized in that a computer program is stored thereon, which computer program, when being executed by a processor, carries out the steps of the animation playback method as claimed in one of the claims 1 to 8.
CN202210844452.2A 2022-07-18 2022-07-18 Animation playing method and device, terminal equipment and storage medium Pending CN115334345A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210844452.2A CN115334345A (en) 2022-07-18 2022-07-18 Animation playing method and device, terminal equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210844452.2A CN115334345A (en) 2022-07-18 2022-07-18 Animation playing method and device, terminal equipment and storage medium

Publications (1)

Publication Number Publication Date
CN115334345A true CN115334345A (en) 2022-11-11

Family

ID=83918434

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210844452.2A Pending CN115334345A (en) 2022-07-18 2022-07-18 Animation playing method and device, terminal equipment and storage medium

Country Status (1)

Country Link
CN (1) CN115334345A (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106385635A (en) * 2016-09-18 2017-02-08 福建天泉教育科技有限公司 GIF animation real-time control method and player
CN111726683A (en) * 2019-03-20 2020-09-29 海信视像科技股份有限公司 Media playing method and device, electronic equipment and storage medium
WO2021073293A1 (en) * 2019-10-16 2021-04-22 广州华多网络科技有限公司 Animation file generating method and device, and storage medium
CN112911389A (en) * 2021-01-18 2021-06-04 浙江大华技术股份有限公司 Video playing switching method, electronic equipment and computer storage medium
CN113706671A (en) * 2021-08-30 2021-11-26 康键信息技术(深圳)有限公司 Animation implementation method, device, equipment and storage medium
CN113973225A (en) * 2020-07-22 2022-01-25 阿里巴巴集团控股有限公司 Video reverse playing method and device, computer storage medium and electronic equipment

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106385635A (en) * 2016-09-18 2017-02-08 福建天泉教育科技有限公司 GIF animation real-time control method and player
CN111726683A (en) * 2019-03-20 2020-09-29 海信视像科技股份有限公司 Media playing method and device, electronic equipment and storage medium
WO2021073293A1 (en) * 2019-10-16 2021-04-22 广州华多网络科技有限公司 Animation file generating method and device, and storage medium
CN113973225A (en) * 2020-07-22 2022-01-25 阿里巴巴集团控股有限公司 Video reverse playing method and device, computer storage medium and electronic equipment
CN112911389A (en) * 2021-01-18 2021-06-04 浙江大华技术股份有限公司 Video playing switching method, electronic equipment and computer storage medium
CN113706671A (en) * 2021-08-30 2021-11-26 康键信息技术(深圳)有限公司 Animation implementation method, device, equipment and storage medium

Similar Documents

Publication Publication Date Title
CN109992231B (en) Screen projection method and terminal
CN111031108B (en) Synchronization method and electronic equipment
CN108600668B (en) Screen recording frame rate adjusting method and mobile terminal
CN110784771B (en) Video sharing method and electronic equipment
CN110174993B (en) Display control method, terminal equipment and computer readable storage medium
CN111324235A (en) Screen refreshing frequency adjusting method and electronic equipment
CN110062273B (en) Screenshot method and mobile terminal
CN111147919A (en) Play adjustment method, electronic equipment and computer readable storage medium
CN109407920B (en) Status icon display method, status icon processing method and related equipment
CN111726525A (en) Video recording method, video recording device, electronic equipment and storage medium
CN109618218B (en) Video processing method and mobile terminal
CN111050070A (en) Video shooting method and device, electronic equipment and medium
CN109101151B (en) Information display processing method and terminal equipment
CN108718395B (en) Segmented video recording method and automobile data recorder
CN110753201A (en) Video recording method and device, electronic equipment and storage medium
CN110933494A (en) Picture sharing method and electronic equipment
CN110941378B (en) Video content display method and electronic equipment
CN108366171B (en) Temperature rise control method and mobile terminal
CN111050214A (en) Video playing method and electronic equipment
CN112416278B (en) Screen sharing method and device, electronic equipment and storage medium
CN107872584A (en) A kind of multi-media processing method, multimedia equipment and terminal
CN110213437B (en) Editing method and mobile terminal
CN108536272B (en) Method for adjusting frame rate of application program and mobile terminal
CN111314639A (en) Video recording method and electronic equipment
CN108449560B (en) Video recording method and terminal

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