Player library
Tracky for JW Player is a plugin providing a basic API for Tracks (captions/chapters/thumbnails).
Get Tracky for JW Player
You can get Tracky for JW Player here.
Or you can link directly to Tracky by including the following in your JW "plugins" setup block:
plugins: {
"http://dev.powered-by-haiku.co.uk/solutions/tracky/code/tracky.js":{}
}
The "track" object
By default, the bulk of Tracky API calls will return track data in the form of a JavaScript Object (or an Array of Objects).
The track object takes the following form:
{
begin: "00:00:00,000", // The track's beginning time as a String
beginPosition: 0, // The track's beginning time represented as seconds
chapter: "1", // The WebVTT chapter title (if included) or a String indicating the track number
end: "00:01:42,000", // The track's end time as a String
endPosition: 102, // The track's end time represented as seconds
info: "Opening credits", // The track's information - could be a Chapter heading, Caption text or an Image URL + offsets
num: 0 // zero-based Array index of this track
}
Most API methods allow you to request a specific property from the track object by passing the property String as a parameter.
Captions
jwplayer().plugins.tracky.getCaptions()
Returns an array representing the current set of captions, for the current item.
Parameters: - getCaptions(item_number, set)
- item_number - An integer, relating to a different playlist item from which you wish to retrieve data. Set to
null
to indicate the current item. - set - A string, relating to an alternative set of captions that exist for this item
- item_number - An integer, relating to a different playlist item from which you wish to retrieve data. Set to
jwplayer().plugins.tracky.getCurrentCaption()
Returns an object representing the current caption, in the current set, for the current item. If no caption is displayed at this time, returns
null
.Parameters: - getCurrentCaption(property, set, item_number)
- property - A string, relating to a specific "track" property you wish to return - see above. Set to
null
to return the full object. - set - A string, relating to an alternative set of captions that exist for this item. Set to
null
to indicate the current set of captions. - item_number - An integer, relating to a different playlist item from which you wish to retrieve data. Set to
null
to indicate the current item.
- property - A string, relating to a specific "track" property you wish to return - see above. Set to
jwplayer().plugins.tracky.getFirstCaption()
Returns an object representing the first caption, in the current set, for the current item.
Parameters: - getFirstCaption(property, set, item_number)
- property - A string, relating to a specific "track" property you wish to return - see above. Set to
null
to return the full object. - set - A string, relating to an alternative set of captions that exist for this item. Set to
null
to indicate the current set of captions. - item_number - An integer, relating to a different playlist item from which you wish to retrieve data. Set to
null
to indicate the current item.
- property - A string, relating to a specific "track" property you wish to return - see above. Set to
jwplayer().plugins.tracky.getLastCaption()
Returns an object representing the last caption, in the current set, for the current item.
Parameters: - getLastCaption(property, set, item_number)
- property - A string, relating to a specific "track" property you wish to return - see above. Set to
null
to return the full object. - set - A string, relating to an alternative set of captions that exist for this item. Set to
null
to indicate the current set of captions. - item_number - An integer, relating to a different playlist item from which you wish to retrieve data. Set to
null
to indicate the current item.
- property - A string, relating to a specific "track" property you wish to return - see above. Set to
jwplayer().plugins.tracky.getNextCaption()
Returns an object representing the next caption, in the current set, for the current item - based on the current time position.
Parameters: - getNextCaption(property, set, item_number)
- property - A string, relating to a specific "track" property you wish to return - see above. Set to
null
to return the full object. - set - A string, relating to an alternative set of captions that exist for this item. Set to
null
to indicate the current set of captions. - item_number - An integer, relating to a different playlist item from which you wish to retrieve data. Set to
null
to indicate the current item.
- property - A string, relating to a specific "track" property you wish to return - see above. Set to
jwplayer().plugins.tracky.getPreviousCaption()
Returns an object representing the previous caption, in the current set, for the current item - based on the current time position.
Parameters: - getPreviousCaption(property, set, item_number)
- property - A string, relating to a specific "track" property you wish to return - see above. Set to
null
to return the full object. - set - A string, relating to an alternative set of captions that exist for this item. Set to
null
to indicate the current set of captions. - item_number - An integer, relating to a different playlist item from which you wish to retrieve data. Set to
null
to indicate the current item.
- property - A string, relating to a specific "track" property you wish to return - see above. Set to
jwplayer().plugins.tracky.getCaptionAt(42)
Returns an object representing the caption that exists at the specified time position, in the current set, for the current item. Returns
null
if no caption exists at the specified time position.Parameters: - getCaptionAt(position, property, set, item_number)
- position - An integer, relating to the time position (in seconds) you wish to get the caption for. Required.
- property - A string, relating to a specific "track" property you wish to return - see above. Set to
null
to return the full object. - set - A string, relating to an alternative set of captions that exist for this item. Set to
null
to indicate the current set of captions. - item_number - An integer, relating to a different playlist item from which you wish to retrieve data. Set to
null
to indicate the current item.
Chapters
jwplayer().plugins.tracky.getChapters()
Returns an array representing the chapters for the current item.
Parameters: - getChapters(item_number)
- item_number - An integer, relating to a different playlist item from which you wish to retrieve data. Set to
null
to indicate the current item.
- item_number - An integer, relating to a different playlist item from which you wish to retrieve data. Set to
jwplayer().plugins.tracky.getCurrentChapter()
Returns an object representing the current chapter for the current item.
Parameters: - getCurrentChapter(property, item_number)
- property - A string, relating to a specific "track" property you wish to return - see above. Set to
null
to return the full object. - item_number - An integer, relating to a different playlist item from which you wish to retrieve data. Set to
null
to indicate the current item.
- property - A string, relating to a specific "track" property you wish to return - see above. Set to
jwplayer().plugins.tracky.getFirstChapter()
Returns an object representing the first chapter for the current item.
Parameters: - getFirstChapter(property, item_number)
- property - A string, relating to a specific "track" property you wish to return - see above. Set to
null
to return the full object. - item_number - An integer, relating to a different playlist item from which you wish to retrieve data. Set to
null
to indicate the current item.
- property - A string, relating to a specific "track" property you wish to return - see above. Set to
jwplayer().plugins.tracky.getLastChapter()
Returns an object representing the last chapter for the current item.
Parameters: - getLastChapter(property, item_number)
- property - A string, relating to a specific "track" property you wish to return - see above. Set to
null
to return the full object. - item_number - An integer, relating to a different playlist item from which you wish to retrieve data. Set to
null
to indicate the current item.
- property - A string, relating to a specific "track" property you wish to return - see above. Set to
jwplayer().plugins.tracky.getNextChapter()
Returns an object representing the next chapter for the current item.
Parameters: - getNextChapter(property, item_number)
- property - A string, relating to a specific "track" property you wish to return - see above. Set to
null
to return the full object. - item_number - An integer, relating to a different playlist item from which you wish to retrieve data. Set to
null
to indicate the current item.
- property - A string, relating to a specific "track" property you wish to return - see above. Set to
jwplayer().plugins.tracky.getPreviousChapter()
Returns an object representing the previous chapter for the current item.
Parameters: - getPreviousChapter(property, item_number)
- property - A string, relating to a specific "track" property you wish to return - see above. Set to
null
to return the full object. - item_number - An integer, relating to a different playlist item from which you wish to retrieve data. Set to
null
to indicate the current item.
- property - A string, relating to a specific "track" property you wish to return - see above. Set to
jwplayer().plugins.tracky.getChapterAt(280)
Returns an object representing the chapter that exists at the specified time position, for the current item.
Parameters: - getChapterAt(position, property, item_number)
- position - An integer, relating to the time position (in seconds) you wish to get the chapter for. Required.
- property - A string, relating to a specific "track" property you wish to return - see above. Set to
null
to return the full object. - item_number - An integer, relating to a different playlist item from which you wish to retrieve data. Set to
null
to indicate the current item.
jwplayer().plugins.tracky.seekToFirstChapter()
Seeks the current item to the start of the first chapter.
Parameters: - None
jwplayer().plugins.tracky.seekToLastChapter()
Seeks the current item to the start of the last chapter.
Parameters: - None
jwplayer().plugins.tracky.seekToNextChapter()
Seeks the current item to the start of the next chapter - based on the current time position.
Parameters: - None
jwplayer().plugins.tracky.seekToPreviousChapter()
Seeks the current item to the start of the previous chapter - based on the current time position.
Parameters: - None
jwplayer().plugins.tracky.seekToChapterAt(280)
Seeks the current item to the start of the chapter that corresponds to the specified position.
Parameters: - seekToChapterAt(position)
- position - An integer, relating to the time position (in seconds) you wish to find the chapter for. The current item will then seek to the start of this chapter. Required.
Thumbnails
jwplayer().plugins.tracky.getThumbnails()
Returns an array representing the thumbnails for the current item.
Parameters: - getThumbnails(item_number)
- item_number - An integer, relating to a different playlist item from which you wish to retrieve data. Set to
null
to indicate the current item.
- item_number - An integer, relating to a different playlist item from which you wish to retrieve data. Set to
jwplayer().plugins.tracky.getCurrentThumbnail()
Returns an object representing the current thumbnail for the current item.
Parameters: - getCurrentThumbnail(property, item_number)
- property - A string, relating to a specific "track" property you wish to return - see above. Set to
null
to return the full object. - item_number - An integer, relating to a different playlist item from which you wish to retrieve data. Set to
null
to indicate the current item.
- property - A string, relating to a specific "track" property you wish to return - see above. Set to
jwplayer().plugins.tracky.getFirstThumbnail()
Returns an object representing the first thumbnail for the current item.
Parameters: - getFirstThumbnail(property, item_number)
- property - A string, relating to a specific "track" property you wish to return - see above. Set to
null
to return the full object. - item_number - An integer, relating to a different playlist item from which you wish to retrieve data. Set to
null
to indicate the current item.
- property - A string, relating to a specific "track" property you wish to return - see above. Set to
jwplayer().plugins.tracky.getLastThumbnail()
Returns an object representing the last thumbnail for the current item.
Parameters: - getLastThumbnail(property, item_number)
- property - A string, relating to a specific "track" property you wish to return - see above. Set to
null
to return the full object. - item_number - An integer, relating to a different playlist item from which you wish to retrieve data. Set to
null
to indicate the current item.
- property - A string, relating to a specific "track" property you wish to return - see above. Set to
jwplayer().plugins.tracky.getNextThumbnail()
Returns an object representing the next thumbnail for the current item.
Parameters: - getNextThumbnail(property, item_number)
- property - A string, relating to a specific "track" property you wish to return - see above. Set to
null
to return the full object. - item_number - An integer, relating to a different playlist item from which you wish to retrieve data. Set to
null
to indicate the current item.
- property - A string, relating to a specific "track" property you wish to return - see above. Set to
jwplayer().plugins.tracky.getPreviousThumbnail()
Returns an object representing the previous thumbnail for the current item.
Parameters: - getPreviousThumbnail(property, item_number)
- property - A string, relating to a specific "track" property you wish to return - see above. Set to
null
to return the full object. - item_number - An integer, relating to a different playlist item from which you wish to retrieve data. Set to
null
to indicate the current item.
- property - A string, relating to a specific "track" property you wish to return - see above. Set to
jwplayer().plugins.tracky.getThumbnailAt(380)
Returns an object representing the thumbnail that exists at the specified time position, for the current item.
Parameters: - getThumbnailAt(position, property, item_number)
- position - An integer, relating to the time position (in seconds) you wish to get the thumbnail for. Required.
- property - A string, relating to a specific "track" property you wish to return - see above. Set to
null
to return the full object. - item_number - An integer, relating to a different playlist item from which you wish to retrieve data. Set to
null
to indicate the current item.
Extras
jwplayer().plugins.tracky.timeToSeconds("06:32")
Returns an integer representing the number of seconds that a common time format equates to.
Parameters: - timeToSeconds(time_string)
- time_string - A string representation of a time in the format hh:mm:ss.
jwplayer().plugins.tracky.getTracks(null,"chapters",null)
This is a lower level API method which allows other track types to be handled.
Returns an array representing all the "tracks" (of a specified type/set) for the specified item.
Parameters: - getTracks(item_number, track_type, track_set)
- item_number - An integer, relating to a different playlist item from which you wish to retrieve data. Set to
null
to indicate the current item. - track_type - A string, relating to the type of track.
- track_set - A string, relating to the particular set of "tracks" that exist for this item.
- item_number - An integer, relating to a different playlist item from which you wish to retrieve data. Set to
jwplayer().plugins.tracky.getTrack(null, "next", "chapters", null, "info", null)
This is a lower level API method which allows other track types to be handled.
Returns an object (or property) representing the track, of a specified type/set, for the specified item, at the specified position.
Parameters: - getTrack(item_number, selector, track_type, track_set, property, position)
- item_number - An integer, relating to a different playlist item from which you wish to retrieve data. Set to
null
to indicate the current item. - selector - A string, indicating the particular track you are wishing to return in relation to the current time position. Allowed values:
current
,next
,previous
,first
,last
orposition
. Set tonull
to default tocurrent
. - track_type - A string, relating to the type of track. Set to
null
to default tocaptions
. - track_set - A string, relating to the particular set of "tracks" that exist for this item. Set to
null
to default to the current captions set or-
. - property - A string, relating to a specific "track" property you wish to return - see above. Set to
null
to return the full object. - position - An integer, relating to the time position (in seconds) you wish to get the "track" for. Set to
null
to use the current item's time position.
- item_number - An integer, relating to a different playlist item from which you wish to retrieve data. Set to