88 ListenerManager ,
99} from "../CommonMethods/index" ;
1010import { buildUUID } from "../IdGenerationMethod/index" ;
11- import { createTimerWorker , inlineWorkerText } from "../Worker/index" ;
1211import { BufferMonitor , BufferProcessor } from "./VideoBufferMonitor" ;
1312import { ErrorManager } from "./ErrorManager" ;
1413import { PlaybackEventHandler } from "./PlayerEventHandler" ;
@@ -56,14 +55,15 @@ function nucleusState(
5655 disableCookies : actionableData . disableCookies ?? false ,
5756 respectDoNotTrack : actionableData . respectDoNotTrack ?? false ,
5857 allowRebufferTracking : false ,
59- disablePlayheadRebufferTracking : false ,
58+ disablePlayheadRebufferTracking :
59+ actionableData . disablePlayheadRebufferTracking ?? false ,
6060 errorConverter : function ( errAttr : any ) {
6161 return errAttr ;
6262 } ,
6363 } ;
6464 actionableData = {
65- actionableData,
6665 ...defaultConfig ,
66+ actionableData,
6767 } ;
6868 fileInstance . userConfigData = actionableData ;
6969 fileInstance . fetchPlayheadTime =
@@ -90,34 +90,7 @@ function nucleusState(
9090 fileInstance . data . view_sequence_number = 1 ;
9191 fileInstance . data . player_sequence_number = 1 ;
9292 fileInstance . lastCheckedEventTime = void 0 ;
93-
94- // Initiating web workers
95- fileInstance . worker = createTimerWorker ( inlineWorkerText ) ;
96-
97- // Message from web worker
98- fileInstance . worker . onmessage = function ( message : any ) {
99- let messageCommand : string = message . data . command ;
100-
101- switch ( messageCommand ) {
102- case "pulseStart" :
103- fileInstance . dispatch ( messageCommand ) ;
104- fileInstance . handlePulse . pulseInterval = true ;
105- break ;
106-
107- case "pulseEnd" :
108- fileInstance . playheadProgressing = false ;
109- fileInstance . dispatch ( messageCommand ) ;
110- fileInstance . handlePulse . pulseInterval = false ;
111- break ;
112-
113- case "emitPulse" :
114- fileInstance . dispatch ( "pulse" ) ;
115- break ;
116-
117- default :
118- return ;
119- }
120- } ;
93+ fileInstance . throbTimeoutId = undefined ;
12194
12295 fileInstance . dispatch = function (
12396 name : string ,
@@ -176,7 +149,10 @@ function nucleusState(
176149 fileInstance . demolishView ( ) ;
177150 } ;
178151
179- if ( window && typeof window !== "undefined" ) {
152+ if (
153+ typeof window !== "undefined" &&
154+ typeof window . addEventListener !== "undefined"
155+ ) {
180156 window . addEventListener (
181157 "pagehide" ,
182158 function ( event ) {
@@ -389,8 +365,6 @@ nucleusState.prototype.validateData = function () {
389365} ;
390366
391367nucleusState . prototype . filterData = function ( str : string ) {
392- const workerInstance = this ;
393-
394368 if ( this . data . view_id ) {
395369 if (
396370 this . data . player_source_duration > 0 ||
@@ -413,18 +387,29 @@ nucleusState.prototype.filterData = function (str: string) {
413387 this . eventsDispatcher . sendData ( str , updatedata ) ;
414388 this . data . view_sequence_number ++ ;
415389 this . data . player_sequence_number ++ ;
416- workerInstance . worker . postMessage ( {
417- command : "checkPulse" ,
418- pausestate : workerInstance . data . player_is_paused ,
419- errortracker : workerInstance . warning . hasErrorOccurred ,
420- } ) ;
390+
391+ this . handlePulseEvent ( this ) ;
421392
422393 if ( str === "viewCompleted" ) {
423394 delete this . data . view_id ;
424395 }
425396 }
426397} ;
427398
399+ nucleusState . prototype . handlePulseEvent = ( instance : any ) => {
400+ if ( instance . throbTimeoutId ) {
401+ clearTimeout ( instance . throbTimeoutId ) ;
402+ }
403+
404+ if ( ! instance . warning . hasErrorOccurred ) {
405+ instance . throbTimeoutId = setTimeout ( ( ) => {
406+ if ( ! instance . data . player_is_paused ) {
407+ instance . dispatch ( "pulse" ) ;
408+ }
409+ } , 10000 ) ;
410+ }
411+ } ;
412+
428413nucleusState . prototype . refreshViewData = function ( ) {
429414 const view = this ;
430415 Object . keys ( this . data ) . forEach ( function ( k ) {
0 commit comments