Skip to content

Commit

Permalink
Merge pull request #1642 from MohamedLebda/PIP-improve
Browse files Browse the repository at this point in the history
  • Loading branch information
ImprovedTube committed Mar 27, 2023
2 parents a708483 + 920587e commit e716723
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 1 deletion.
1 change: 1 addition & 0 deletions js&css/web-accessible/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ ImprovedTube.pageType = function () {

ImprovedTube.pageOnFocus = function () {
ImprovedTube.playerAutopauseWhenSwitchingTabs();
ImprovedTube.playerAutoPip();
};

ImprovedTube.videoPageUpdate = function () {
Expand Down
18 changes: 18 additions & 0 deletions js&css/web-accessible/www.youtube.com/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,24 @@ ImprovedTube.playerAutopauseWhenSwitchingTabs = function () {
};


/*------------------------------------------------------------------------------
4.4.2 AUTO PIP WHEN SWITCHING TABS
------------------------------------------------------------------------------*/

ImprovedTube.playerAutoPip = function () {
const video = ImprovedTube.elements.video;

if (this.storage.player_autoPip === true && video) {
(async () => {
try {
await video.requestPictureInPicture();
} catch (error) {
console.error('Failed to enter Picture-in-Picture mode', error);
}
})();
}
};

/*------------------------------------------------------------------------------
4.4.3 FORCED PLAYBACK SPEED
------------------------------------------------------------------------------*/
Expand Down
1 change: 0 additions & 1 deletion js&css/web-accessible/www.youtube.com/shortcuts.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@ ImprovedTube.shortcutPictureInPicture = function () {
}
};


/*------------------------------------------------------------------------------
4.7.3 TOGGLE CONTROLS
------------------------------------------------------------------------------*/
Expand Down
5 changes: 5 additions & 0 deletions menu/skeleton-parts/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,11 @@ extension.skeleton.main.layers.section.player.on.click = {
text: 'loudnessNormalization',
value: true
},
player_autoPip: {
component: 'switch',
text: 'autoPip',
value: false
},
player_forced_playback_speed: {
component: 'switch',
text: 'forcedPlaybackSpeed',
Expand Down
5 changes: 5 additions & 0 deletions menu/skeleton-parts/shortcuts.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,11 @@ extension.skeleton.main.layers.section.shortcuts = {
text: 'pictureInPicture',
storage: 'shortcut_picture_in_picture'
},
auto_picture_in_picture: {
component: 'shortcut',
text: 'autoPictureInPicture',
storage: 'shortcut_auto_picture_in_picture'
},
shortcut_screenshot: {
component: 'shortcut',
text: 'screenshot'
Expand Down

0 comments on commit e716723

Please sign in to comment.