Skip to main content

Player

                            
                              
                                class 
                                Player
                              
                              

The player logic used by the editor and embeddable player.

This class builds on top of the PlaybackManager to provide a simpleinterface similar to other media players. It plays through the animationusing a real-time update loop and optionally synchronises it with audio.

Constructors

constructor

                            
                              
                                public 
                                new
                                Player
                                
                                  
                                    
                                      project
                                      : 
                                      Project
                                    
                                    
                                      settings
                                      : 
                                      Partial
                                      
                                        
                                          
                                            PlayerSettings
                                          
                                        
                                      
                                       = 
                                      {}
                                    
                                    
                                      initialState
                                      : 
                                      Partial
                                      
                                        
                                          
                                            PlayerState
                                          
                                        
                                      
                                       = 
                                      {}
                                    
                                    
                                      initialFrame
                                      : 
                                      number
                                       = 
                                      -1
                                    
                                  
                                
                                : 
                                Player
                              
                              

Parameters

Properties

audio

                            
                              
                                readonly 
                                public 
                                audio
                                : 
                                AudioManager
                              
                              

logger

                            
                              
                                readonly 
                                public 
                                logger
                                : 
                                Logger
                              
                              

playback

                            
                              
                                readonly 
                                public 
                                playback
                                : 
                                PlaybackManager
                              
                              

status

                            
                              
                                readonly 
                                public 
                                status
                                : 
                                PlaybackStatus
                              
                              

Accessors

onDurationChanged

                            
                              
                                public 
                                get 
                                onDurationChanged
                                (): 
                                SubscribableValueEvent
                                
                                  
                                    
                                      number
                                    
                                  
                                
                              
                              

onFrameChanged

                            
                              
                                public 
                                get 
                                onFrameChanged
                                (): 
                                SubscribableValueEvent
                                
                                  
                                    
                                      number
                                    
                                  
                                
                              
                              

onStateChanged

                            
                              
                                public 
                                get 
                                onStateChanged
                                (): 
                                SubscribableValueEvent
                                
                                  
                                    
                                      PlayerState
                                    
                                  
                                
                              
                              

Events

onRecalculated

                            
                              
                                public 
                                get 
                                onRecalculated
                                (): 
                                Subscribable
                                
                                  
                                    
                                      void
                                    
                                    
                                      EventHandler
                                      
                                        
                                          
                                            void
                                          
                                        
                                      
                                    
                                  
                                
                              
                              

Triggered right after recalculation finishes.

Can be used to provide visual feedback.


onRender

                            
                              
                                public 
                                get 
                                onRender
                                (): 
                                Subscribable
                                
                                  
                                    
                                      void
                                    
                                    
                                      AsyncEventHandler
                                      
                                        
                                          
                                            void
                                          
                                        
                                      
                                    
                                  
                                
                              
                              

Triggered during each iteration of the update loop when the frame is readyto be rendered.

Player does not perform any rendering on its own. For the animation to bevisible, another class must subscribe to this event and perform therendering itself. Stage can be used to display the animation.

Methods

activate

                            
                              
                                public 
                                activate
                                (): 
                                void
                              
                              

Activate the player.

A player needs to be active in order for the update loop to run. Eachplayer is active by default.


configure

                            
                              
                                public 
                                configure
                                
                                  
                                    
                                      settings
                                      : 
                                      PlayerSettings
                                    
                                  
                                
                                : 
                                Promise
                                
                                  
                                    
                                      void
                                    
                                  
                                
                              
                              

Parameters


deactivate

                            
                              
                                public 
                                deactivate
                                (): 
                                void
                              
                              

Deactivate the player.

Deactivating the player prevents its update loop from running. This shouldbe done before disposing the player, to prevent it from running in thebackground.

Just pausing the player does not stop the loop.


requestNextFrame

                            
                              
                                public 
                                requestNextFrame
                                (): 
                                void
                              
                              

requestPreviousFrame

                            
                              
                                public 
                                requestPreviousFrame
                                (): 
                                void
                              
                              

requestReset

                            
                              
                                public 
                                requestReset
                                (): 
                                void
                              
                              

requestSeek

                            
                              
                                public 
                                requestSeek
                                
                                  
                                    
                                      value
                                      : 
                                      number
                                    
                                  
                                
                                : 
                                void
                              
                              

Parameters


setSpeed

                            
                              
                                public 
                                setSpeed
                                
                                  
                                    
                                      value
                                      : 
                                      number
                                    
                                  
                                
                                : 
                                void
                              
                              

Parameters


setVariables

                            
                              
                                public 
                                setVariables
                                
                                  
                                    
                                      variables
                                      : 
                                      Record
                                      
                                        
                                          
                                            string
                                          
                                          
                                            unknown
                                          
                                        
                                      
                                    
                                  
                                
                                : 
                                void
                              
                              

Parameters


toggleAudio

                            
                              
                                public 
                                toggleAudio
                                
                                  
                                    
                                      value
                                      : 
                                      boolean
                                       = 
                                      ...
                                    
                                  
                                
                                : 
                                void
                              
                              

Parameters


toggleLoop

                            
                              
                                public 
                                toggleLoop
                                
                                  
                                    
                                      value
                                      : 
                                      boolean
                                       = 
                                      !this.playerState.current.loop
                                    
                                  
                                
                                : 
                                void
                              
                              

Parameters

  • value : boolean = !this.playerState.current.loop

togglePlayback

                            
                              
                                public 
                                togglePlayback
                                
                                  
                                    
                                      value
                                      : 
                                      boolean
                                       = 
                                      ...
                                    
                                  
                                
                                : 
                                void
                              
                              

Parameters