File tree 3 files changed +18
-7
lines changed
3 files changed +18
-7
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,9 @@ import { SUBTITLE_DEFAULT_FONT } from "../../constants/font"
17
17
import { tryBase64ToUint8Array } from "../../utils/string"
18
18
import { getAribb24Configuration } from "../../utils/subtitle"
19
19
20
- export const CoiledSubtitleRenderer : React . VFC < { } > = memo ( ( ) => {
20
+ export const CoiledSubtitleRenderer : React . VFC < {
21
+ internalPlayingTimeRef : React . MutableRefObject < number >
22
+ } > = memo ( ( { internalPlayingTimeRef } ) => {
21
23
const canvasRef = useRef < HTMLCanvasElement > ( null )
22
24
23
25
const speed = useRecoilValue ( contentPlayerSpeedAtom )
@@ -58,7 +60,8 @@ export const CoiledSubtitleRenderer: React.VFC<{}> = memo(() => {
58
60
const decoded = tryBase64ToUint8Array ( aribSubtitleData . data )
59
61
if ( ! decoded ) return
60
62
const fromZero = ( ( aribSubtitleData . pts * 9 ) / 100 - firstPcr ) / 90_000
61
- const pts = fromZero - playingTime / 1000
63
+ const pts =
64
+ fromZero - ( internalPlayingTimeRef . current || playingTime ) / 1000
62
65
const provider = new CanvasProvider ( decoded , pts )
63
66
const estimate = provider . render ( )
64
67
if ( ! estimate ) return
Original file line number Diff line number Diff line change @@ -39,7 +39,9 @@ import { getAribb24Configuration } from "../../utils/subtitle"
39
39
import { VideoRenderer } from "../../utils/videoRenderer"
40
40
import { VLCLogFilter } from "../../utils/vlc"
41
41
42
- export const CoiledVideoPlayer : React . VFC < { } > = memo ( ( ) => {
42
+ export const CoiledVideoPlayer : React . VFC < {
43
+ internalPlayingTimeRef : React . MutableRefObject < number >
44
+ } > = memo ( ( { internalPlayingTimeRef } ) => {
43
45
const canvasRef = useRef < HTMLCanvasElement > ( null )
44
46
45
47
const [ aspect , setAspect ] = useState ( 16 / 9 )
@@ -306,10 +308,11 @@ export const CoiledVideoPlayer: React.VFC<{}> = memo(() => {
306
308
let pcr_i_first = 0
307
309
let last = 0
308
310
window . Preload . webchimera . onTimeChanged ( ( time ) => {
309
- if ( 300 < Math . abs ( time - last ) ) {
311
+ if ( 100 < Math . abs ( time - last ) ) {
310
312
setPlayingTime ( time )
311
313
last = time
312
314
}
315
+ internalPlayingTimeRef . current = time
313
316
} )
314
317
window . Preload . webchimera . onLogMessage ( ( _level , message ) => {
315
318
const parsed = VLCLogFilter ( message )
Original file line number Diff line number Diff line change 1
- import React , { useEffect } from "react"
1
+ import React , { useEffect , useRef } from "react"
2
2
import { useRecoilValue , useSetRecoilState } from "recoil"
3
3
import pkg from "../../package.json"
4
4
import {
@@ -22,6 +22,7 @@ export const CoiledContentPlayer: React.VFC<{}> = () => {
22
22
globalActiveContentPlayerIdAtom
23
23
)
24
24
const setIsPlaying = useSetRecoilState ( contentPlayerIsPlayingAtom )
25
+ const internalPlayingTimeRef = useRef ( - 1 )
25
26
26
27
useEffect ( ( ) => {
27
28
// 16:9以下の比率になったら戻し、ウィンドウサイズを保存する
@@ -92,7 +93,9 @@ export const CoiledContentPlayer: React.VFC<{}> = () => {
92
93
id = "VideoPlayer"
93
94
className = "absolute top-0 left-0 w-full h-full flex items-center justify-center"
94
95
>
95
- < CoiledVideoPlayer />
96
+ < CoiledVideoPlayer
97
+ internalPlayingTimeRef = { internalPlayingTimeRef }
98
+ />
96
99
</ div >
97
100
< div
98
101
id = "OnPlayerComponents"
@@ -104,7 +107,9 @@ export const CoiledContentPlayer: React.VFC<{}> = () => {
104
107
id = "SubtitleRenderer"
105
108
className = "absolute top-0 left-0 w-full h-full flex items-center justify-center"
106
109
>
107
- < CoiledSubtitleRenderer />
110
+ < CoiledSubtitleRenderer
111
+ internalPlayingTimeRef = { internalPlayingTimeRef }
112
+ />
108
113
</ div >
109
114
< div
110
115
id = "OnSubtitleComponents"
You can’t perform that action at this time.
0 commit comments