Class s7sdk.video.VideoTime
The VideoTime
component can be associated with a VideoPlayer
component to display the duration and elapsed time in a video.
The component can be added to ControlBar
and grouped with other video UI components.
Customizing Behavior Using Modifiers
Modifiers change VideoTime
default behavior. They are passed to the component by the ParameterManager
instance
specified in the constructor.
The following modifiers are supported:
Modifier | Syntax | Description | Default |
showduration | 0|1 | If set to 1 , both the played time and the total time--or duration-- is displayed. To show only the currently played time, set to 0 . | 1 |
timepattern | [h:]m|mm:s|ss | Sets the pattern for the time to displays in the timecode area. Setting h represents hours, m represents minutes, and s represents seconds. The number of letters used for each time unit determines the number of digits to display for the unit. If the number cannot fit into the given digits, the equivalent value is displayed in the subsequent unit. For example, if the current movie time is 67 minutes and 5 seconds, the time pattern m:ss displays as 67:05. The same time appears as 1:07:5 when the given time pattern is h:mm:s . | m:ss |
Defining the Appearance using CSS
You can define the appearance of the VideoTime
component using CSS rules. All HTML5 Viewer SDK components use class selectors for styling. You can style the VideoTime
component by using
the .s7videotime
class selector. The styles that are associated with this class selector are applied to all instances of the VideoTime
component. You can style particular instances by prefixing
the class rule with the instance #id. For example, styling rules for #myComp.s7videotime
are applied only to the particular VideoTime
instance.
For more information on component styling see the HTML5 Viewer SDK User Guide and the examples in this document.
CSS Class | Attribute Selector | Description |
.s7videotime | (None) | Defines the appearance of the VideoTime component. |
.s7tooltip | (None) | A global class selector that defines appearance for the tooltips. To disable tooltips set the display style to none . |
Localizable Symbols
VideoTime
also has s text symbol that you can localize either in a preset or in the viewer page though the mechanisms
provided by the ParameterManager
. For more information on localization consult the ParameterManager
API documentation and HTML5 Viewers SDK User Guide.
Symbol | Description |
VideoTime.TOOLTIP | Defines a localized tooltip for the VideoTime component. |
Constructor Attributes | Constructor Name and Description |
---|---|
s7sdk.video.VideoTime(container, settings, compId)
|
Method Attributes | Method Name and Description |
---|---|
autoSize()
Sets the natural component size based on the inner text content, without truncation or wrapping.
|
|
dispose()
Dispose is used to remove itself and all sub-elements from the DOM
|
|
Returns the time displayed as the video duration, in milliseconds.
|
|
Returns the current inner height of the component.
|
|
Returns the time displayed as the video elapsed time, in milliseconds.
|
|
getWidth()
Returns the current inner width of the component.
|
|
resize(w, h)
Resizes the
VideoTime component to the specified width and height. |
|
setCSS(classname, property, value)
Sets a particular CSS class and property on a component
|
|
setDuration(ms)
Sets the time displayed as the video duration
|
|
setModifier(modObj)
Sets 1-N # of modifiers for the component.
|
|
setPlayedTime(ms)
Sets the time displayed as the video elapsed time, in milliseconds
|
Example Code
This example demonstrates how to use the VideoTime component in a simple video viewer. In this example a Container object,
a VideoPlayer object, and a VideoTime object are created. Every time a user clicks the VideoPlayer, video playback starts or
pauses. The VideoTime object updates to display the current video time and video duration as the video plays.
The code below does the following:
- The Scene7 HTML5 SDK is linked to the page and the required s7sdk components are included in the document head.
- CSS Styles are defined in the document head to control the appearance of the SDK components.
- The s7sdk.Util.init() method is called to initialize the SDK.
- A ParameterManager object is created to handle component modifiers for the viewer.
- An initViewer() function is defined. This function initializes a number of modifiers (hard coded for example purposes),
then creates the component objects required for this simple example. The initViewer() function also adds event listeners
that designate functions to handle relevant component events (which might be dispatched by the components as a result of
user interactions, changes in a component's state, etc.).
- Handler functions are defined to respond to the component event listeners added in the initViewer() function.
- An event listener is added to the ParameterManager object that designates the initViewer() function as the handler
to call when the Scene7 SDK is loaded and ready.
- Finally, the init() method is called on the ParameterManager object to start the viewer.
ERROR: could not open zoom/examples/VideoTime.html.
Default styles for VideoTime:
.s7videotime {
position:absolute;
width:57px;
height:15px;
-webkit-user-select:none;
-moz-user-select:none;
-ms-user-select:none;
user-select:none;
-webkit-tap-highlight-color:rgba(0,0,0,0);
font-family:Arial, Helvetica, sans-serif;
font-size:12px;
padding:4px;
}
.s7tooltip {
position:absolute;
padding:5px;
line-height:100%;
text-align:center;
background-color:rgb(224, 224, 224);
color:rgb(26,26,26);
font-family:Helvetica, sans-serif;
font-size:11px;
z-index:10000;
border:1px solid rgb(191,191,191);
}
- Parameters:
- {String|Container} container
- The reference to
Container
instance,ControlBar
instance or the ID of the parent DOM element to which the component is added as a child - {s7sdk.ParameterManager} settings
- A parameter manager instance that represents the desired configuration.
- {String} compId
- An optional parameter that specifies the ID of the component DOM element.
- Returns:
- video duration
- Returns:
- {Number} the inner height of the component, in pixels.
- Returns:
- current played time
- Returns:
- {Number} the inner width of the component, in pixels.
VideoTime
component to the specified width and height.
- Parameters:
- {Number} w
- The width of the component, in pixels.
- {Number} h
- The height of the component, in pixels. .
- Parameters:
- {String} classname
- The CSS classname to use for this style. i.e. .s7videotime
- {String} property
- The CSS property that is being set. i.e. background-color
- {String} value
- The CSS property value being set. i.e. #FF0000
- Parameters:
- {Number} ms
- video duration, in milliseconds.
- Parameters:
- {Object} modObj
- A simple JSON object with name:value pairs of valid modifiers for a particular component
- Parameters:
- {Number} ms
- video playback time, in milliseconds.