File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -83,8 +83,8 @@ export const SplitWordDialog = memo(() => {
8383 const splittedDuration = duration / splittedWords . length ;
8484 const newWords = splittedWords . map ( ( w , i ) => ( {
8585 ...newLyricWord ( ) ,
86- startTime : startTime + splittedDuration * i ,
87- endTime : startTime + splittedDuration * ( i + 1 ) ,
86+ startTime : ( startTime + splittedDuration * i ) | 0 ,
87+ endTime : ( startTime + splittedDuration * ( i + 1 ) ) | 0 ,
8888 word : w ,
8989 } ) ) ;
9090 line . words . splice ( splitState . wordIndex , 1 , ...newWords ) ;
Original file line number Diff line number Diff line change @@ -22,12 +22,14 @@ export function parseTimespan(timeSpan: string): number {
2222 throw new TypeError ( `时间戳字符串解析失败:${ timeSpan } ` ) ;
2323}
2424
25- export function msToTimestamp ( timeMS : number ) : string {
25+ export function msToTimestamp ( timeMS : number , skipSafeCheck = false ) : string {
2626 let t = timeMS ;
2727 if ( t === Number . POSITIVE_INFINITY ) {
2828 return "99:99.999" ;
2929 }
30- if ( ! Number . isSafeInteger ( t ) || t < 0 ) {
30+ if ( skipSafeCheck ) {
31+ t = t | 0 ;
32+ } else if ( ! Number . isSafeInteger ( t ) || t < 0 ) {
3133 throw new Error ( `Invalid timestamp: ${ t } ` ) ;
3234 }
3335 t = timeMS / 1000 ;
Original file line number Diff line number Diff line change 1515 * 但是可能会有信息会丢失
1616 */
1717
18- import { msToTimestamp } from "./timestamp" ;
18+ import { msToTimestamp as origMsToTimestamp } from "./timestamp" ;
1919import type { LyricLine , LyricWord , TTMLLyric } from "./ttml-types" ;
2020
21+ const msToTimestamp = ( time : number ) => origMsToTimestamp ( time , true ) ;
22+
2123export default function exportTTMLText (
2224 ttmlLyric : TTMLLyric ,
2325 pretty = false ,
You can’t perform that action at this time.
0 commit comments