Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Background fix and Binge Watch fix for stremio-shell with stremio-web v5 #757

Open
wants to merge 7 commits into
base: development
Choose a base branch
from
Open
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
/yarn.lock
/npm-debug.log
.DS_Store
.prettierignore
.prettierignore
/.idea/
14 changes: 13 additions & 1 deletion src/routes/Player/Player.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ const Player = ({ urlParams, queryParams }) => {
}, [immersed, casting, video.state.paused, menusOpen, nextVideoPopupOpen]);

const nextVideoPopupDismissed = React.useRef(false);
const nextVideoInitialData = React.useRef(player.nextVideo);
nextVideoInitialData.current = player.nextVideo;
const defaultSubtitlesSelected = React.useRef(false);
const defaultAudioTrackSelected = React.useRef(false);
const [error, setError] = React.useState(null);
Expand All @@ -96,6 +98,7 @@ const Player = ({ urlParams, queryParams }) => {
}, [settings.subtitlesSize, settings.subtitlesOffset, settings.subtitlesTextColor, settings.subtitlesBackgroundColor, settings.subtitlesOutlineColor]);

const onEnded = React.useCallback(() => {
player.nextVideo = nextVideoInitialData.current;
ended();
if (player.nextVideo !== null) {
onNextVideoRequested();
Expand Down Expand Up @@ -463,6 +466,7 @@ const Player = ({ urlParams, queryParams }) => {
React.useLayoutEffect(() => {
const onKeyDown = (event) => {
switch (event.code) {
case 'MediaPlayPause':
case 'Space': {
if (!menusOpen && !nextVideoPopupOpen && video.state.paused !== null) {
if (video.state.paused) {
Expand All @@ -475,6 +479,8 @@ const Player = ({ urlParams, queryParams }) => {

break;
}
case 'Numpad6':
case 'MediaTrackNext':
case 'ArrowRight': {
if (!menusOpen && !nextVideoPopupOpen && video.state.time !== null) {
const seekDuration = event.shiftKey ? settings.seekShortTimeDuration : settings.seekTimeDuration;
Expand All @@ -484,6 +490,8 @@ const Player = ({ urlParams, queryParams }) => {

break;
}
case 'Numpad4':
case 'MediaTrackPrevious':
case 'ArrowLeft': {
if (!menusOpen && !nextVideoPopupOpen && video.state.time !== null) {
const seekDuration = event.shiftKey ? settings.seekShortTimeDuration : settings.seekTimeDuration;
Expand All @@ -493,13 +501,15 @@ const Player = ({ urlParams, queryParams }) => {

break;
}
case 'Numpad8':
case 'ArrowUp': {
if (!menusOpen && !nextVideoPopupOpen && video.state.volume !== null) {
onVolumeChangeRequested(video.state.volume + 5);
}

break;
}
case 'Numpad2':
case 'ArrowDown': {
if (!menusOpen && !nextVideoPopupOpen && video.state.volume !== null) {
onVolumeChangeRequested(video.state.volume - 5);
Expand Down Expand Up @@ -556,7 +566,7 @@ const Player = ({ urlParams, queryParams }) => {
}
};
const onKeyUp = (event) => {
if (event.code === 'ArrowRight' || event.code === 'ArrowLeft') {
if (event.code === 'ArrowRight' || event.code === 'ArrowLeft' || event.code === 'Numpad6' || event.code === 'Numpad4') {
setSeeking(false);
}
};
Expand Down Expand Up @@ -596,6 +606,8 @@ const Player = ({ urlParams, queryParams }) => {
video.events.off('subtitlesTrackLoaded', onSubtitlesTrackLoaded);
video.events.off('extraSubtitlesTrackLoaded', onExtraSubtitlesTrackLoaded);
video.events.off('implementationChanged', onImplementationChanged);
if (document.querySelector('body').style.background) document.querySelector('body').style.background = '';
if (document.getElementById('app').style.background) document.getElementById('app').style.background = '';
};
}, []);

Expand Down