Video Class
Video
Instantiation
- scrawl.getVideoById()
- scrawl.makeVideo()
Purpose
- Wraps DOM <video> elements imported into the scrawl-canvas library
- Used by Picture entitys and Pattern designs
Access
- scrawl.video.VIDEONAME - for the Video object
- scrawl.asset.IMAGENAME - for a link to the original <video> element
Constructor
Video
-
[items]
Parameters:
-
[items]
Object optionalKey:value Object argument for setting attributes
Item Index
Methods
addImageByUrl
-
[items]
Import a video using the supplied url string - not yet coded
Parameters:
-
[items]
Object optionalKey:value Object argument for setting attributes
Returns:
true; false on failure
addVideoByElement
-
[items]
Adds a DOM <video> element to the library
- items.element MUST be a reference to the element, and the element MUST be present in the DOM
- items.readyState is the readystate value (integer between 0 and 4) which must be reached before dimensions are set and any callback function triggered - default: 1 (HAVE_METADATA, loadedmetadata)
Parameters:
-
[items]
Object optionalKey:value Object argument for setting attributes
Returns:
always true
clone
-
items
Clone a Scrawl.js object, optionally altering attribute values in the cloned object
Note that any callback or fn attribute functions will be referenced by the clone, not copied to the clone; these can be overwritten with new anonymous functions by including them in the items argument object
(This function is replaced by the path extension)
Parameters:
-
items
ObjectObject containing attribute key:value pairs; will overwrite existing values in the cloned, but not the source, Object
Returns:
Cloned object
Example:
var box = scrawl.makeBlock({
width: 50,
height: 50
});
var newBox = box.clone({
height: 100
});
newBox.get('width'); //returns 50
newBox.get('height'); //returns 100
get
-
item
Retrieve an attribute value. If the attribute value has not been set, then the default value for that attribute will be returned.
Parameters:
-
item
StringAttribute key
Returns:
Attribute value
Example:
var box = scrawl.makeBlock({
width: 50,
});
box.get('width'); //returns 50
box.get('height'); //returns 0
box.get('favouriteAnimal'); //returns undefined
numberConvert
-
val
-
dim
Stamp helper function - convert string percentage values to numerical values
Parameters:
-
val
Stringcoordinate String
-
dim
Numberdimension value
Returns:
Number - value
parse
()
Turn the object into a JSON String
Returns:
object of object's currently set attributes
set
-
items
Set attribute values. Multiple attributes can be set in the one call by including the attribute key:value pair in the argument object.
An attribute value will only be set if the object already has a default value for that attribute. This restricts the ability of coders to add attributes to Scrawl objects.
Parameters:
-
items
ObjectObject containing attribute key:value pairs
Returns:
This
Example:
var box = scrawl.makeBlock({
width: 50,
height: 50
});
box.set({
height: 100,
favouriteAnimal: 'cat'
});
box.get('width'); //returns 50
box.get('height'); //returns 100
box.get('favouriteAnimal'); //returns undefined
setIntrinsicDimensions
()
private
Video constructor helper function
Returns:
always true
Properties
callback
Function
Constructor/clone function - some functions can call the Video constructor with a callback function
This attribute is not retained by the object
Default: undefined - callback is always removed once run
comment
String
Comment, for accessibility
Default: ''
element
Object
Constructor argument attribute - a DOM <video> element
This attribute is not retained by the object
Default: undefined
height
Number
DOM image actual height, in pixels
Default: 0
name
String
Unique identifier for each object; default: computer-generated String based on Object's type
timestamp
String
Creation timestamp
Default: ''
title
String
Title, for accessibility
Default: ''
type
String
final
Default: 'Video'
width
Number
DOM image actual width, in pixels
Default: 0