@@ -174,7 +174,6 @@ var SubtitlesOctopus = function (options) {
174
174
self . setVideo = function ( video ) {
175
175
self . video = video ;
176
176
if ( self . video ) {
177
- // hack, for testing
178
177
if ( self . renderAhead > 0 ) {
179
178
window . requestAnimationFrame ( oneshotRender ) ;
180
179
tryRequestOneshot ( ) ;
@@ -268,6 +267,8 @@ var SubtitlesOctopus = function (options) {
268
267
}
269
268
270
269
function tryRequestOneshot ( currentTime ) {
270
+ if ( ! self . renderAhead || self . renderAhead <= 0 ) return ;
271
+
271
272
if ( typeof currentTime === 'undefined' ) {
272
273
if ( ! self . video ) return ;
273
274
currentTime = self . video . currentTime + self . timeOffset ;
@@ -590,6 +591,7 @@ var SubtitlesOctopus = function (options) {
590
591
width : self . canvas . width ,
591
592
height : self . canvas . height
592
593
} ) ;
594
+ resetRenderAheadCache ( ) ;
593
595
}
594
596
} ;
595
597
@@ -625,19 +627,22 @@ var SubtitlesOctopus = function (options) {
625
627
target : 'set-track-by-url' ,
626
628
url : url
627
629
} ) ;
630
+ resetRenderAheadCache ( ) ;
628
631
} ;
629
632
630
633
self . setTrack = function ( content ) {
631
634
self . worker . postMessage ( {
632
635
target : 'set-track' ,
633
636
content : content
634
637
} ) ;
638
+ resetRenderAheadCache ( ) ;
635
639
} ;
636
640
637
641
self . freeTrack = function ( content ) {
638
642
self . worker . postMessage ( {
639
643
target : 'free-track'
640
644
} ) ;
645
+ resetRenderAheadCache ( ) ;
641
646
} ;
642
647
643
648
0 commit comments