At the moment, we have a very simple Video
class that caches an element and then attaches multiple events that are defined by the media element specification for HTML5. We have defined the essentials of a video player and now need to abstract it a bit further so it can be reused and managed much better. Following some conventions and creating a flexible framework will help us move faster and more effectively.
First, let's think about some things we may want from this class:
An events method that attaches the proper events
Callback methods that can be defined, for example,
onPlay
,onPause
, andonEnded
Public methods that can be called from outside the instance
Chainable methods similar to jQuery where you can call one method after another, for example,
fadeIn().fadeOut().show().hide()
Having a list of items that abstract the behavior of a class is a step in the right direction for establishing a solid framework or library. Now let's start by creating callbacks...