HTML and CSS Reference
In-Depth Information
modify the Video model, which could have an adverse effect on your
application. By creating an association with a video source, you don't need to
worry about modifying your code if new formats appear, as you can simply
create new instances for the new video formats, and then add them to the
association with the Video model. To make life even easier, you can create a
loop in your view (which will be discussed further into this chapter) so that you
don't have to modify the application to support the new video formats.
To begin, create a new JavaScript file, called videosource.js , for the video
source model within the js/app/model/ folder. You can now begin to define your
model's structure using the following code.
var app = app || {};
app.model = app.model || {};
/**
* A video source used within a video
* You must add this object to a video once instantiated
* @param {String} url
* @param {app.type.format} format
*/
app.model.videosource = function appModelVideoSource(url, format){
// Your implementation goes here
}
As you can see, the model is declared in much the same way as the pets model,
except you use the app.model namespace for all of your models.
The constructor accepts a URL for the video, and a format that could be webm,
ogv, mp4, and so forth.
The next thing to do will be to declare the instance variables. Just to recap, an
instance variable is a variable that exists only within the scope of the object
instance. The instance variables aren't accessible or modifiable outside of the
instance, unless a getter or setter is created for the instance variable.
...
app.model.videosource = function appModelVideoSource(url, format){
/**
* The video source's instance variables
*/
var _url,
_format,
_self = this;
}
 
Search WWH ::




Custom Search