make duration proportional to length of segment
This commit is contained in:
parent
fa21a06856
commit
07034fe8dc
2 changed files with 24 additions and 8 deletions
|
|
@ -137,3 +137,18 @@ function onVisibilityChange(el, callback) {
|
|||
function parseTime(value) {
|
||||
return value.split(":").map(p => parseFloat(p)).reduce((c, p) => { return c*60 + p}, 0)
|
||||
}
|
||||
|
||||
|
||||
function splitText(text, duration) {
|
||||
var parts = []
|
||||
text = text.replace(/<br\ \/>/g, '<br>').replace(/<br\/>/g, '<br>')
|
||||
var length = text.replace(/<br>/g, '').length
|
||||
var texts = text.split('<br>')
|
||||
texts.forEach(part => {
|
||||
parts.push({
|
||||
value: part.trim(),
|
||||
duration: duration / length * part.length
|
||||
})
|
||||
})
|
||||
return parts
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue