Adjust story duration
This commit is contained in:
parent
f9c2e9b0af
commit
f09b214016
1 changed files with 8 additions and 3 deletions
|
@ -14,7 +14,6 @@ import { SECOND } from './durations';
|
||||||
|
|
||||||
const DEFAULT_DURATION = 5 * SECOND;
|
const DEFAULT_DURATION = 5 * SECOND;
|
||||||
const MAX_VIDEO_DURATION = 30 * SECOND;
|
const MAX_VIDEO_DURATION = 30 * SECOND;
|
||||||
const MIN_TEXT_DURATION = 3 * SECOND;
|
|
||||||
|
|
||||||
export async function getStoryDuration(
|
export async function getStoryDuration(
|
||||||
attachment: AttachmentType
|
attachment: AttachmentType
|
||||||
|
@ -58,7 +57,7 @@ export async function getStoryDuration(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (attachment.textAttachment && attachment.textAttachment.text) {
|
if (attachment.textAttachment && attachment.textAttachment.text) {
|
||||||
// Minimum 3 seconds. +1 second for every 15 characters past the first
|
// Minimum 5 seconds. +1 second for every 15 characters past the first
|
||||||
// 15 characters (round up).
|
// 15 characters (round up).
|
||||||
// For text stories that include a link, +2 seconds to the playback time.
|
// For text stories that include a link, +2 seconds to the playback time.
|
||||||
const length = count(attachment.textAttachment.text);
|
const length = count(attachment.textAttachment.text);
|
||||||
|
@ -66,7 +65,13 @@ export async function getStoryDuration(
|
||||||
const linkPreviewSeconds = attachment.textAttachment.preview
|
const linkPreviewSeconds = attachment.textAttachment.preview
|
||||||
? 2 * SECOND
|
? 2 * SECOND
|
||||||
: 0;
|
: 0;
|
||||||
return MIN_TEXT_DURATION + additionalSeconds + linkPreviewSeconds;
|
return DEFAULT_DURATION + additionalSeconds + linkPreviewSeconds;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (attachment.caption) {
|
||||||
|
const length = count(attachment.caption);
|
||||||
|
const additionalSeconds = (Math.ceil(length / 15) - 1) * SECOND;
|
||||||
|
return DEFAULT_DURATION + additionalSeconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
return DEFAULT_DURATION;
|
return DEFAULT_DURATION;
|
||||||
|
|
Loading…
Reference in a new issue