Skip to content

Commit

Permalink
feat: add flag to stop fast forward
Browse files Browse the repository at this point in the history
  • Loading branch information
Nerixyz committed Jul 21, 2022
1 parent 74cee65 commit b92eef0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "TTV-Tools",
"version": "0.5.2",
"version": "0.5.4",
"description": "Common helpers when watching twitch",
"background": {
"scripts": [
Expand Down
11 changes: 10 additions & 1 deletion src/context/twitch-player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export function initWorkerHandler(connector: Lazy<ReactConnector>) {

if (Reflect.get(worker, 'ad:known')) return;
Reflect.set(worker, 'ad:known', true);
initNoFfwd();

console.log('Listening on worker messages.');

Expand All @@ -60,7 +61,7 @@ export function initWorkerHandler(connector: Lazy<ReactConnector>) {
const args: AnalyticsEventArgs = {properties: {...data.arg.properties}};
if(args.properties.sink_buffer_size)
args.properties.sink_buffer_size *= 1000;
if (args.properties.sink_buffer_size && args.properties.sink_buffer_size > MinLatencySpeedup() * 1000) {
if (!isNoFfwd() && args.properties.sink_buffer_size && args.properties.sink_buffer_size > MinLatencySpeedup() * 1000) {
if (args.properties.sink_buffer_size > MinLatencyReload() * 1000) resetPlayer(connector);
else {
const latencyToSkip = args.properties.sink_buffer_size - (KeepBuffer() * 1000);
Expand Down Expand Up @@ -115,3 +116,11 @@ function overwriteMonitor(monitor: PlaybackMonitor) {
};
monitor.setPlaybackRate.known = true;
}

function initNoFfwd() {
(globalThis as any).__noFfwd ??= false;
}

function isNoFfwd() {
return !!(globalThis as any).__noFfwd;
}

0 comments on commit b92eef0

Please sign in to comment.