TarPackage
Summary
Defines a TarPackage to manage publication of a tar file.
A tar file may contain :
- A video file
- A list of image files
- A .session file describing the package content
Constructor
TarPackage
Syntax
TarPackage
-
mediaPackage
-
videoProvider
Summary
Parameters:
-
mediaPackage
ObjectThe media description object
-
videoProvider
VideoProviderA video provider
Example:
// tar package object example
{
"id": "13465465", // Id of the package
"type": "vimeo", // Platform type
"title": "2015-03-09_16-53-10_rich-media", // Package title
"originalPackagePath": "/tmp/2015-03-09_16-53-10_rich-media.tar" // Package file
}
// ".session" file example contained in a tar package
{
"date": 1425916390, // Unix epoch time of the video record
"rich-media": true, // true if package contains presentation images
"filename": "video.mp4", // The name of the video file in the package
"duration": 30, // Duration of the video in seconds
"indexes": [ // The list of indexes in the video
{
"type": "image", // Index type (could be "image" or "tag")
"timecode": 0, // Index time (in ms) from the beginning of the video
"data": { // Index data (only for "image" type)
"filename": "slide_00000.jpeg" // The name of the image file in the tar
}
},
{
"type": "tag", // Index type (could be "image" or "tag")
"timecode": 3208 // Index time (in ms) from the beginning of the video
},
...
]
}
Item Index
Methods
Properties
- mediaPackage
- publishConf
- stateMachine static
- STATES static
- stateTransitions static
- TRANSITIONS static
- videoPlatformConf
- videoProvider
Events
Methods
cleanDirectory
Syntax
cleanDirectory
()
Summary
Removes extracted tar files from temporary directory.
This is a transition.
copyPackage
Syntax
copyPackage
()
Summary
Copies package from its submitted directory to temporary directory.
This is a transition.
executeTransition
Syntax
executeTransition
-
transition
Summary
Starts executing at the given transition.
The rest of the transitions stack will be executed.
Parameters:
-
transition
StringThe transition to launch
extractPackage
Syntax
extractPackage
()
Summary
Extracts package into temporary directory.
This is a transition.
getMediaFilePath
Syntax
Summary
Gets the media file path of the package.
Returns:
System path of the media file
getStateMachine
Syntax
Summary
Gets the list of transitions states corresponding to the package.
Returns:
The list of states/transitions
getTransitions
Syntax
Summary
Gets the stack of transitions corresponding to the package.
Returns:
The stack of transitions
init
Syntax
init
-
initialState
-
initialTransition
Summary
Creates a state machine to publish the package.
initPackage
Syntax
initPackage
()
Summary
Initializes and stores the package.
This is a transition.
removeOriginalPackage
Syntax
removeOriginalPackage
()
Summary
Removes original package.
This is a transition.
saveTimecodes
Syntax
saveTimecodes
-
xmlTimecodeFilePath
-
destinationFilePath
-
callback
Summary
Saves the XML timecode file into a JSON equivalent. This will check if the file exists first.
- Test if timecode xml file exists
- Transcode XML file to a JSON equivalent e.g.
- Format JSON e.g.
Parameters:
Example:
// Transform XML timecodes into JSON
// From :
{
"player": {
"synchro":
[
{
"id": ["slide_00000.jpeg"],
"timecode": ["0"]
}, {
"id": ["slide_00001.jpeg"],
"timecode": ["1200"]
}
]
}
}
// To :
[
{
"timecode": 0,
"type": "image"
"data": {
"filename": "slide_00000.jpeg"
}
},
{
"timecode": 1200,
"type": "image"
"data": {
"filename": "slide_00001.jpeg"
}
}
]
saveTimecodes
Syntax
saveTimecodes
()
Summary
Saves package timecodes into a JSON file.
This is a transition.
setError
Syntax
setError
-
error
Summary
Sets a package as in error.
Parameters:
-
error
PublishErrorThe package error
synchronizeMedia
Syntax
synchronizeMedia
()
Summary
Synchronizes uploaded media information with the media platform.
This is a transition.
updateState
Syntax
updateState
-
id
-
state
-
callback
Summary
Updates media state and sends an event to inform about state changed.
uploadMedia
Syntax
uploadMedia
()
Summary
Uploads the media to the video platform.
This is a transition.
validatePackage
Syntax
validatePackage
()
Summary
Validates the package by analyzing its content.
This is a transition.
validatePackage
Syntax
validatePackage
-
callback
Summary
Validates package content.
A video package must contain, at least a valid package information file and a video file.
Parameters:
-
callback
FunctionThe function to call when done
- Error The error if an error occurred, null otherwise
- Object The package information object
Example:
// mediaPackage example
{
"id" : 1422731934859, // Internal video id
"type" : "vimeo", // The video platform to use
"path" : "C:/Temp/", // The path of the hot folder
"originalPackagePath" : "C:/Temp/video-package.tar", // The original package path in hot folder
}
Properties
stateMachine
Syntax
Summary
Define machine state authorized transitions depending on previous and next states.
stateTransitions
Syntax
Summary
Define the order in which transitions will be executed for a TarPackage.
TRANSITIONS
Syntax
Summary
Tar package process transitions (from one state to another).
videoPlatformConf
Syntax
Summary
Video platforms configuration object from videoPlatformConf.json file.
Events
complete
Syntax
complete
Summary
Fired when package processing has succeed.
Event Payload:
-
The
Objectprocessed package
error
Syntax
error
Summary
Fired when an error occurred while processing the package.
Event Payload:
-
The
Errorerror
stateChanged
Syntax
stateChanged
Summary
Fired when package state has changed.
Event Payload:
-
The
Objectprocessed package