()
| 29 | playerFoundTimeout: NodeJS.Timeout | null = null; |
| 30 | |
| 31 | start() { |
| 32 | const syncDuration = Number(api.settings.get('videoDuration')) / 100; |
| 33 | let playerFound = false; |
| 34 | |
| 35 | let discordTimeout; |
| 36 | |
| 37 | this.playerFoundTimeout = setTimeout( |
| 38 | (async () => { |
| 39 | if (this.errorListener) { |
| 40 | const errorDiv = videoStrategyErrorElement(await hasMissingPermissions()); |
| 41 | this.errorListener(errorDiv); |
| 42 | |
| 43 | const iframes = $('iframe') |
| 44 | .toArray() |
| 45 | .map( |
| 46 | el => utils.absoluteLink($(el).attr('src'), window.location.origin) as string | null, |
| 47 | ) |
| 48 | .filter(el => el) |
| 49 | .filter(el => !isIframeUrl(el!)); |
| 50 | |
| 51 | con.log('No Player found', iframes); |
| 52 | } |
| 53 | }) as () => void, |
| 54 | 5 * 60 * 1000, |
| 55 | ); |
| 56 | PlayerSingleton.getInstance() |
| 57 | .startTracking() |
| 58 | .addListener('VideoStrategy', item => { |
| 59 | const progress = item.current / item.duration; |
| 60 | if (this.trackingResolve && !item.paused && progress >= syncDuration) { |
| 61 | this.trackingResolve(); |
| 62 | this.trackingResolve = null; |
| 63 | } |
| 64 | if (this.listener) { |
| 65 | this.listener({ |
| 66 | progress, |
| 67 | progressTrigger: syncDuration, |
| 68 | current: item.current, |
| 69 | total: item.duration, |
| 70 | }); |
| 71 | } |
| 72 | if (!playerFound) { |
| 73 | playerFound = true; |
| 74 | clearTimeout(this.playerFoundTimeout!); |
| 75 | if (this.errorListener) { |
| 76 | this.errorListener(null); |
| 77 | } |
| 78 | } |
| 79 | this.discordState = { duration: item.duration, current: item.current, paused: item.paused }; |
| 80 | clearTimeout(discordTimeout); |
| 81 | discordTimeout = setTimeout(() => { |
| 82 | this.discordState = null; |
| 83 | }, 15 * 1000); |
| 84 | }); |
| 85 | } |
| 86 | |
| 87 | getResumeText(state: ProgressElement) { |
| 88 | if (!state.current) return null; |
nothing calls this directly
no test coverage detected