Skip to content

Commit e0770ff

Browse files
authoredApr 7, 2025··
fix: Cancel trick play when current time catch the seek range (#8410)
1 parent b93303c commit e0770ff

File tree

3 files changed

+28
-19
lines changed

3 files changed

+28
-19
lines changed
 

‎lib/player.js

+18-19
Original file line numberDiff line numberDiff line change
@@ -7434,26 +7434,25 @@ shaka.Player = class extends shaka.util.FakeEventTarget {
74347434
*/
74357435
setupTrickPlayEventListeners_(rate) {
74367436
this.trickPlayEventManager_.removeAll();
7437-
if (this.isLive()) {
7438-
this.trickPlayEventManager_.listen(this.video_, 'timeupdate', () => {
7439-
const currentTime = this.video_.currentTime;
7440-
const seekRange = this.seekRange();
7441-
const safeSeekOffset = this.config_.streaming.safeSeekOffset;
7442-
7443-
// Cancel trick play if we hit the beginning or end of the seekable
7444-
// (Sub-second accuracy not required here)
7445-
if (rate > 0) {
7446-
if (Math.floor(currentTime) >= Math.floor(seekRange.end)) {
7447-
this.cancelTrickPlay();
7448-
}
7449-
} else {
7450-
if (Math.floor(currentTime) <=
7451-
Math.floor(seekRange.start + safeSeekOffset)) {
7452-
this.cancelTrickPlay();
7453-
}
7437+
this.trickPlayEventManager_.listen(this.video_, 'timeupdate', () => {
7438+
const currentTime = this.video_.currentTime;
7439+
const seekRange = this.seekRange();
7440+
const safeSeekOffset = this.isLive() ?
7441+
this.config_.streaming.safeSeekOffset : 0;
7442+
7443+
// Cancel trick play if we hit the beginning or end of the seekable
7444+
// (Sub-second accuracy not required here)
7445+
if (rate > 0) {
7446+
if (Math.floor(currentTime) >= Math.floor(seekRange.end)) {
7447+
this.cancelTrickPlay();
74547448
}
7455-
});
7456-
}
7449+
} else {
7450+
if (Math.floor(currentTime) <=
7451+
Math.floor(seekRange.start + safeSeekOffset)) {
7452+
this.cancelTrickPlay();
7453+
}
7454+
}
7455+
});
74577456
}
74587457

74597458
/**

‎ui/fast_forward_button.js

+5
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ shaka.ui.FastForwardButton = class extends shaka.ui.Element {
5858
}
5959
this.fastForward_();
6060
});
61+
62+
this.eventManager.listen(this.player, 'ratechange', () => {
63+
this.button_.setAttribute(
64+
'shaka-status', this.player.getPlaybackRate() + 'x');
65+
});
6166
}
6267

6368
/**

‎ui/rewind_button.js

+5
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ shaka.ui.RewindButton = class extends shaka.ui.Element {
5959
}
6060
this.rewind_();
6161
});
62+
63+
this.eventManager.listen(this.player, 'ratechange', () => {
64+
this.button_.setAttribute(
65+
'shaka-status', this.player.getPlaybackRate() + 'x');
66+
});
6267
}
6368

6469
/**

0 commit comments

Comments
 (0)
Please sign in to comment.