Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 27 additions & 16 deletions plugins/AudioPlayerLite/AudioPlayerLite.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,35 @@
}
}

// patch.instead() appends to a list of patches, so registering on every
// navigation stacks up copies of this patch and breaks the patch chain.
let patched = false;

PluginApi.Event.addEventListener("stash:location", async (e) => {
if (patched) return;

const path = e.detail.data.location.pathname;
const idRegExp = /.*\/scenes\/(\d+)/;
if (idRegExp.test(path)) {
await PluginApi.utils.loadComponents([
PluginApi.loadableComponents.ScenePlayer
]);
PluginApi.patch.instead("ScenePlayer", function (props, _, originalComponent) {
const file = props.scene.files[0];
let scene = props.scene;
if (file.video_codec === "") {
scene = { ...scene,
sceneStreams: props.scene.sceneStreams.filter((ss) => ss.label.toUpperCase() === 'HSL')
};
poster()
}
return originalComponent({ ...props, scene });
});
}
if (!idRegExp.test(path)) return;

await PluginApi.utils.loadComponents([
PluginApi.loadableComponents.ScenePlayer
]);

// re-check: another navigation event may have been handled while awaiting
if (patched) return;
patched = true;

PluginApi.patch.instead("ScenePlayer", function (props, _, originalComponent) {
const file = props.scene && props.scene.files && props.scene.files[0];
let scene = props.scene;
if (file && file.video_codec === "") {
scene = { ...scene,
sceneStreams: props.scene.sceneStreams.filter((ss) => ss.label.toUpperCase() === 'HSL')
};
setStyle()
}
return React.createElement(originalComponent, { ...props, scene });
});
});
})();
2 changes: 1 addition & 1 deletion plugins/AudioPlayerLite/AudioPlayerLite.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: AudioPlayerLite
description: This plugin identifies files with no video codec and plays them as audio.
version: 0.1
version: 0.2
url: https://discourse.stashapp.cc/t/audioplayerlite/1329
ui:
javascript:
Expand Down
Loading