Skip to content

Commit

Permalink
feat(player): danmaku font size offset
Browse files Browse the repository at this point in the history
Co-authored-by: lainio24 <[email protected]>
  • Loading branch information
WakelessSloth56 and lainio24 committed Oct 8, 2023
1 parent 47450aa commit 45611e2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
<input id="danmaku-time-offset" type="number" value="0" />
</td>
</tr>
<tr>
<td>Size Offset:</td>
<td><input id="danmaku-size-offset" type="number" value="-3" /></td>
</tr>
<tr>
<td>Auto Play:</td>
<td><input id="auto-play" type="checkbox" /></td>
Expand Down Expand Up @@ -77,6 +81,7 @@
fullscreen: id('fullscreen').checked,
muted: id('muted').checked,
danmakuTimeOffset: parseFloat(id('danmaku-time-offset').value),
danmakuSizeOffset: parseInt(id('danmaku-size-offset').value),
});
window.player = player;
id('start-panel').remove();
Expand Down
11 changes: 11 additions & 0 deletions src/player.player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,17 @@ const __player_metadata__: PlayerMetadata = {
.selfEvents({
create: (P, E) => {
P.commentManager = initDanmaku(E, P.danmakuUrl, () => P.firePlayerEvent('danmakuload'));
if (P.options.danmakuSizeOffset) {
P.commentManager.filter.addModifier(function (commentData: StrAnyKV) {
const override = commentData;
const size = commentData['size'];
if (size && !override['sizeOverridden']) {
override['size'] = size + P.options.danmakuSizeOffset;
override['sizeOverridden'] = true;
}
return override;
});
}
P._dyn.danmakuOn = true;
P.setContainerData('danmakuOn', true);
if (!P.options.danmakuTimeOffset) P.options.danmakuTimeOffset = 0;
Expand Down

0 comments on commit 45611e2

Please sign in to comment.