Subtitles module - SPSubsInterface
Module used to manipulate subtitles collections in SP.
Constants
Subtitles number
Used to specify whether the function should manipulate SP's first or
second subtitles. Use these values when specifying value of subs_no parameter in all functions in thes module.SUBS_FIRST = 1
SUBS_SECOND = 2
Property number
Use this to specify which property should be manipulated by a
particular getter or setter function - what_prop
parameter. Always use the constants, the actual numbers may change in
future versions of SP.
SUBS_STRING_TITLE=1
SUBS_STRING_AUTHOR=2
SUBS_STRING_TRANSLATED_BY=3
SUBS_STRING_EDITED_BY=4
SUBS_STRING_TIMED_BY=5
SUBS_STRING_CHECKED_BY=6
SUBS_STRING_SYNCH_POINT=7
SUBS_STRING_UPDATE_AUTHOR=8
SUBS_STRING_UPDATE_DETAILS=9
SUBS_STRING_DEFAULT_STYLE_OVERRIDE=10
SUBS_FLOAT_FPS = 101
SUBS_FLOAT_TIMER_SPEED = 102
SUBS_FLOAT_TIMER_SHIFT = 103
SUBS_INT_CHARSET = 201
SUBS_INT_PLAYRES_X = 202
SUBS_INT_PLAYRES_Y = 203
SUBS_INT_PLAYRES_BPP = 204
SUBS_INT_WORDWRAP = 205
SUBS_INT_COLLISIONS = 206
SUBS_BOOL_CHANGED = 301
Property getters and setters
These functions are used to set or get values of subtitles
collection's properties. Common parameters are:
- subs_no: select which subtitles
collection will be used
- what_prop: select what property shall
be used.
- prop_value: value of the property (for
setter function). Ensure that proper data type is passed, otherwise
access violations will occur!!!
Return value of getter function is either:
- nil: invalid subtitles collection or
property number was specified
- property value otherwise.
Return value of setter function can be either:
- true: property was successfully set
- false: invalid subtitles collection or
property number was specified.
Example:
puts "There are
#{SPSubsInterface.get_subtitles_count(SUBS_FIRST)} subtitles in First
subtitles collection."
get_subtitles_count(subs_no)
- return number of items in specified subtitles
get_subtitles_string_prop(subs_no,
what_prop)
- get value of string property
set_subtitles_string_prop(subs_no,
what_prop, prop_value)
- set value of string property
get_subtitles_float_prop(subs_no,
what_prop)
- get value of floating-point property
set_subtitles_float_prop(subs_no,
what_prop, prop_value)
- set value of floating-point property
get_subtitles_int_prop(subs_no,
what_prop)
- get value of integer property
set_subtitles_int_prop(subs_no,
what_prop, prop_value)
- set value of integer property
get_subtitles_time_mode(subs_no)
- get the time mode of subtitles collection
set_subtitles_time_mode(subs_no,
time_mode)
get_subtitles_bool_prop(subs_no,
what_prop)
- get value of boolean property
set_subtitles_bool_prop(subs_no,
what_prop, prop_value)
- set value of boolean property
Subtitles collection methods
These functions of SPSubsInterface enable to call corresponding
methods of TSubtitles collection in SP. Common parameter is subs_no with the same meaning as with property
getters.
add_subtitle(subs_no)
- add an empty subtitle to selected subtitles and return it's index
delete_subtitle(subs_no, sub_no)
- delete sub_no th subtitle
insert_subtitle(subs_no, where)
- insert subtitle at position where
- return the index of the inserted subtitle.
clear_subtitles(subs_no)
disable_index_updates(subs_no)
- disable search index recalculation before massive updates -
increase the disable count by 1
enable_index_updates(subs_no)
- enable search index recalculation after massive updates -
decrease the disable count by 1. When disable count reaches 0, the
index is recalculated
enable_index_updates_immediate(subs_no)
- enable search index recalculation after massive updates
regardless of the numbe of previous disables (set the number of
disables to 0)
sort_subtitles(subs_no, increasing)
- Sort subtitles according to their starting timestamp, in
increasing order if increasing is true
get_indices(subs_no, frame_no)
- get the current, previous and next subtitle's index
- Return values:
- 3-item array containing subtitle indices: [current,
previous, next]
- these indices can be -1 which
determines that the particular index is not available
- nil - bad 'subs_no' parameter
get_unsynced_cnt(subs_no)
- get number of unsynchronized subtitles
get_unsynced(subs_no, unsynced_index)
- get unsynced_index th
unsynchronized subtitle. The index specifies the number of the
unsynchronized subtitle, e.g. if there are 100 subtitles and 5 of them
are unsynchronized, 3rd unsynchronized subtitle can be physically 60th
subtitle.
- return value is the physical index of the unsynchronized subtitle.
get_next_unsynced(subs_no, index)
- get physical index of first unsynchronized subtitle after
the index th