HypervideoModel Module
I am the HypervideoModel which stores all data which make up the hypervideo.
Item Index
Methods
- exportIt
- getAnnotations
- getAnnotationSets
- getSubtitles
- getVideolinks
- initModel
- initModelOfAnnotations
- initModelOfOverlays
- initModelOfSubtitles
- initModelOfVideolinks
- leaveEditMode
- newAnnotation
- newOverlay
- newUnsavedChange
- newVideolink
- removeAnnotation
- removeOverlay
- removeVideolink
- save
- selectAnnotationSet
- updateHypervideo
Methods
exportIt
()
YET TO IMPLEMENT
Data exporting can be achieved in various ways.
getAnnotations
()
private
When the {{#crossLinks "HypervideoModel/annotations:attribute"}}attribute annotations{{/crossLinks}} is accessed, it needs to return an array of the currently selected annotation set (choosen by assigning the annotation's ownerId to {{#crossLinks "HypervideoModel/annotationSet:attribute"}}annotationSet{{/crossLinks}}). The array needs to be sorted by the start time.
Returns:
Array of Annotations
getAnnotationSets
()
Id: ownerId, name: ownerName
private
Needed for the {{#crossLinks "HypervideoModel/annotationSets:attribute"}}annotationSets attribute{{/crossLinks}}. This attribute' purpose is to tell, what users have an annotationfile for the current hypervideo.
I return an array of maps in the format
[ { id: ownerid, name: ownerName }, ... ]
Returns:
Array of
getSubtitles
()
private
When the {{#crossLinks "HypervideoModel/subtitles:attribute"}}attribute subtitles{{/crossLinks}} is accessed, it needs to return an array of the currently selected language subtitles (choosen by assigning the selected language to {{#crossLinks "HypervideoModel/selectedLang:attribute"}}selectedLang{{/crossLinks}}).
Returns:
Object containing the language label and an Array of Subtitles
getVideolinks
()
private
When the {{#crossLinks "HypervideoModel/videolinks:attribute"}}attribute videolinks{{/crossLinks}} is accessed, it needs to return the video link objects in an array, which is sorted by the start time. This is what I do.
Returns:
Array of Videolinks
initModel
-
callback
The data model is initialized after the Database is ready and before the different views (like ViewVideo) are created.
I do the following jobs:
- I read in the hypervideo metadata, and store them in my attributes (like name, description, creator)
- I read in the configuration of the hypervideo (hypervideo.config) and set the key-value-pairs as global state (FrameTrail.changeState())
- I read in the sequence data of the hypervideo, and set the video source file (webm and mp4), or – when their is no resourceId for a video – I set the duration attribute for a "null video".
- I call initModelOfOverlays, initModelOfVideolinks and initModelOfAnnotations.
- I return control to the callback.
Parameters:
-
callback
Function
initModelOfAnnotations
-
database
I create the Annotation objects from the data in the Database and store them in my videolinks attribute.
Also I select the the main annotation set (from the user who created the hypervideo) as the current one.
Parameters:
-
database
Database
initModelOfSubtitles
-
database
I create the Subtitle objects from the data in the Database and store them in my subtitles attribute.
Parameters:
-
database
Database
initModelOfVideolinks
-
database
I create the Videolink objects from the data in the Database and store them in my videolinks attribute.
Parameters:
-
database
Database
leaveEditMode
-
logoutAfterLeaving
The global state "editMode" can be set to false, to trigger all modules to leave their edit mode.
However, this global state should only be altered by me, because I check first if there were any unsaved changes, and offer the user the possibility to save them.
Parameters:
-
logoutAfterLeaving
Boolean
newAnnotation
-
protoData
I create a new annotation.
I am called from AnnotationsController.
Parameters:
-
protoData
Object
Returns:
Annotation
newOverlay
-
protoData
I create a new overlay.
I am called from OverlaysController.
Parameters:
-
protoData
Object
Returns:
Overlay
newUnsavedChange
-
category
I serve the purpose to set markers (both visually and in my data model), in which categories (overlays, videolinks, annotations) the user has unsaved changes.
Parameters:
-
category
String
newVideolink
-
protoData
I create a new video link.
I am called from VideolinksController.
Parameters:
-
protoData
Object
Returns:
Videolink
removeAnnotation
-
annotation
I remove all data of an annotation from the model and from the database.
I am called from AnnotationsController/deleteAnnotation.
Parameters:
-
annotation
Annotation
removeOverlay
-
overlay
I remove all data of an overlay from the model and from the database.
I am called from OverlaysController/deleteOverlay.
Parameters:
-
overlay
Overlay
removeVideolink
-
videolink
I remove all data of a video link from the model and from the database.
I am called from VideolinksController/deleteVideolink.
Parameters:
-
videolink
Videolink
save
-
callback
-
callbackCancel
I am the central function for saving changes back to the server.
I save only, what is necessary (overlays, videolinks, annotations).
When all saving requests to the server have completed, I check all their responses. If there where any errors I display them and abort. Otherwise I reset the "unsavedChanges"-markers back to false and the global state (FrameTrail.changeState('unsavedChanges', false)) and call the callback.
Note: The second parameter is optional and should not be needed because the user should already be logged in at this point (cancelCallback means, the user canceled the login).
selectAnnotationSet
-
anID
I am needed by the {{#crossLinks "HypervideoModel/annotationSet:attribute"}}annotationSet attribute{{/crossLinks}}.
My parameter can be set in three ways:
- when the argument is null, I select the main annotation file (from the hypervideo's _index.json entry)
- when the special string '#myAnnotationSet' is given as argument, I select the logged-in user's ID
- an all other cases, I take the literal string as the ID to select.
When my user changes the currently selected annotation sets, I have to assure, that both myself and the {{#crossLinks "Database"}}Database{{/crossLinks}} have under the respective attribute name an [Array] present, for manipulating annotation objects inside them.
Parameters:
-
anID
String or null
Returns:
String
Attributes
annotationAllSets
Object of Array of Annotation
All annotations sets of the hypervideo in a map of userIDs to their respective annotation set.
annotations
Array of Annotation
readonly
The currently selected annotations of the hypervideo (fetched via {{#crossLink "HypervideoModel/getAnnotations:method"}}getAnnotations(){{/crossLinks}}).
annotationSet
Array of Annotation
The currently selected userID, to decide which annotations should be displayed (setting this attribute is done via {{#crossLink "HypervideoModel/selectAnnotationSet:method"}}selectAnnotationSet(){{/crossLinks}}).
annotationSets
Array of id: String, name: String
readonly
The annotation sets of the hypervideo (fetched via {{#crossLink "HypervideoModel/getAnnotationSets:method"}}getAnnotationSets(){{/crossLinks}}).
duration
The hypervideo's duration.
This attribute must not be changed after the init process. It is either set to the duration of the "null video" ({{#crossLink "HypervideoModel/initModel:method"}}HypervideoModel/initModel(){{/crossLinks}}) or or after the video source file's meta data has loaded ({{#crossLink "HypervideoController/initController:method"}}HypervideoController/initController(){{/crossLinks}}).
hasHTML5Video
Boolean
readonly
Wether the current hypervideo has a playable html5 video source file, or (otherwise) only has a duration (then we are in "Null Player" mode).