Skip to content

Commit d0d3b11

Browse files
authored
Update shaka-player to 5.0.6 (#8772)
* Update shaka-player to 5.0.4 * Update shaka-player to 5.0.5 * Update shaka-player to 5.0.6 * Clean up CSS
1 parent 64a000b commit d0d3b11

16 files changed

+88
-41
lines changed

_scripts/webpack.renderer.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,8 @@ const config = {
196196

197197
'youtubei.js$': 'youtubei.js/web',
198198

199-
// change to "shaka-player.ui.debug.js" to get debug logs (update jsconfig to get updated types)
200-
'shaka-player$': 'shaka-player/dist/shaka-player.ui.js',
199+
// change to "shaka-player.ui-es2021.debug.js" to get debug logs (update jsconfig to get updated types)
200+
'shaka-player$': 'shaka-player/dist/shaka-player.ui-es2021.js',
201201

202202
// Make @fortawesome/vue-fontawesome use the trimmed down API instead of the original @fortawesome/fontawesome-svg-core
203203
'@fortawesome/fontawesome-svg-core$': path.resolve(__dirname, '../src/renderer/fontawesome-minimal.js'),

_scripts/webpack.web.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,8 @@ const config = {
173173
alias: {
174174
DB_HANDLERS_ELECTRON_RENDERER_OR_WEB$: path.resolve(__dirname, '../src/datastores/handlers/web.js'),
175175

176-
// change to "shaka-player.ui.debug.js" to get debug logs (update jsconfig to get updated types)
177-
'shaka-player$': 'shaka-player/dist/shaka-player.ui.js',
176+
// change to "shaka-player.ui-es2021.debug.js" to get debug logs (update jsconfig to get updated types)
177+
'shaka-player$': 'shaka-player/dist/shaka-player.ui-es2021.js',
178178

179179
// Make @fortawesome/vue-fontawesome use the trimmed down API instead of the original @fortawesome/fontawesome-svg-core
180180
'@fortawesome/fontawesome-svg-core$': path.resolve(__dirname, '../src/renderer/fontawesome-minimal.js')

jsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"src/datastores/handlers/web"
1414
],
1515
"shaka-player": [
16-
"./node_modules/shaka-player/dist/shaka-player.ui"
16+
"./node_modules/shaka-player/dist/shaka-player.ui-es2021"
1717
]
1818
}
1919
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
"googlevideo": "^4.0.4",
6464
"marked": "^17.0.4",
6565
"process": "^0.11.10",
66-
"shaka-player": "^4.16.20",
66+
"shaka-player": "^5.0.6",
6767
"swiper": "^12.1.2",
6868
"vue": "^3.5.30",
6969
"vue-i18n": "^11.3.0",

src/renderer/components/ft-shaka-video-player/ft-shaka-video-player.css

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -197,11 +197,7 @@
197197
opacity: 1;
198198
}
199199

200-
:deep(.shaka-controls-container > .shaka-play-button-container > .shaka-play-button) {
201-
padding: min(calc(15% / 2), 55px);
202-
}
203-
204-
:deep(.shaka-controls-button-panel>.ft-shaka-skip-button .material-svg-icon) {
200+
:deep(.shaka-controls-button-panel>.ft-shaka-skip-button .shaka-ui-icon) {
205201
font-size: 32px;
206202
}
207203

src/renderer/components/ft-shaka-video-player/ft-shaka-video-player.js

Lines changed: 42 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ export default defineComponent({
259259

260260
watch(displayVideoPlayButton, (newValue) => {
261261
ui.configure({
262-
addBigPlayButton: newValue
262+
bigButtons: newValue ? ['play_pause'] : []
263263
})
264264
})
265265

@@ -616,7 +616,6 @@ export default defineComponent({
616616
// This only affects the "auto" quality, users can still manually select whatever quality they want.
617617
restrictToElementSize: true
618618
},
619-
autoShowText: shaka.config.AutoShowText.NEVER,
620619

621620
// Prioritise variants that are predicted to play:
622621
// - `smooth`: without dropping frames
@@ -908,9 +907,21 @@ export default defineComponent({
908907
volumeBarColors: {
909908
level: 'var(--primary-color)'
910909
},
910+
mediaSession: {
911+
// The WatchVideoInfo component handles that
912+
handleMetadata: false,
913+
// Need to override the default list so it doesn't override the next and previous video handlers in the WatchVideoPlaylist component.
914+
supportedActions: [
915+
'pause',
916+
'play',
917+
'seekbackward',
918+
'seekforward',
919+
'seekto'
920+
]
921+
},
911922

912923
// these have their own watchers
913-
addBigPlayButton: displayVideoPlayButton.value,
924+
bigButtons: displayVideoPlayButton.value ? ['play_pause'] : [],
914925
enableFullscreenOnRotation: enterFullscreenOnDisplayRotate.value,
915926
playbackRates: playbackRates.value,
916927
tapSeekDistance: defaultSkipInterval.value,
@@ -920,7 +931,13 @@ export default defineComponent({
920931

921932
// TODO: enable this when electron gets document PiP support
922933
// https://github.com/electron/electron/issues/39633
923-
preferDocumentPictureInPicture: false
934+
documentPictureInPicture: {
935+
enabled: false
936+
}
937+
}
938+
939+
if (document.pictureInPictureEnabled) {
940+
firstTimeConfig.mediaSession.supportedActions.push('enterpictureinpicture')
924941
}
925942

926943
// Combine the config objects so we only need to do one configure call
@@ -2321,16 +2338,23 @@ export default defineComponent({
23212338
showValueChange(message, messageIcon)
23222339
}
23232340
break
2324-
case KeyboardShortcuts.VIDEO_PLAYER.GENERAL.CAPTIONS:
2341+
case KeyboardShortcuts.VIDEO_PLAYER.GENERAL.CAPTIONS: {
23252342
// Toggle caption/subtitles
2326-
if (player.getTextTracks().length > 0) {
2343+
2344+
const textTracks = player.getTextTracks()
2345+
if (textTracks.length > 0) {
23272346
event.preventDefault()
23282347

2329-
const currentlyVisible = player.isTextTrackVisible()
2330-
player.setTextTrackVisibility(!currentlyVisible)
2348+
if (textTracks.some(track => track.active)) {
2349+
player.selectTextTrack(null)
2350+
} else {
2351+
player.selectTextTrack(textTracks[0])
2352+
}
2353+
23312354
showOverlayControls()
23322355
}
23332356
break
2357+
}
23342358
case KeyboardShortcuts.VIDEO_PLAYER.GENERAL.VOLUME_UP:
23352359
// Increase volume
23362360
event.preventDefault()
@@ -2939,8 +2963,6 @@ export default defineComponent({
29392963

29402964
if (textTrack) {
29412965
player.selectTextTrack(textTrack)
2942-
2943-
await player.setTextTrackVisibility(true)
29442966
}
29452967
}
29462968

@@ -2998,12 +3020,12 @@ export default defineComponent({
29983020

29993021
const activeCaptionIndex = player.getTextTracks().findIndex(caption => caption.active)
30003022

3001-
if (activeCaptionIndex >= 0 && player.isTextTrackVisible()) {
3023+
if (activeCaptionIndex >= 0) {
30023024
restoreCaptionIndex = activeCaptionIndex
30033025

30043026
// hide captions before switching as shaka/the browser doesn't clean up the displayed captions
30053027
// when switching away from the legacy formats
3006-
await player.setTextTrackVisibility(false)
3028+
player.selectTextTrack(null)
30073029
} else {
30083030
restoreCaptionIndex = null
30093031
}
@@ -3053,7 +3075,14 @@ export default defineComponent({
30533075

30543076
if (useAutoQuality) {
30553077
if (label) {
3056-
player.selectVariantsByLabel(label)
3078+
const audioTracks = deduplicateAudioTracks(player.getAudioTracks()).values()
3079+
3080+
for (const track of audioTracks) {
3081+
if (label === track.label) {
3082+
player.selectAudioTrack(track)
3083+
break
3084+
}
3085+
}
30573086
}
30583087
} else {
30593088
if (dimension) {

src/renderer/components/ft-shaka-video-player/player-components/AudioTrackSelection.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export class AudioTrackSelection extends shaka.ui.SettingsMenu {
1717
this.menu.classList.add('audio-tracks')
1818

1919
/** @type {SVGElement} */
20-
const checkmarkIcon = new shaka.ui.MaterialSVGIcon(null, PlayerIcons.DONE_FILLED).getSvgElement()
20+
const checkmarkIcon = new shaka.ui.Icon(null, PlayerIcons.DONE_FILLED).getSvgElement()
2121
checkmarkIcon.classList.add('shaka-chosen-item')
2222
checkmarkIcon.ariaHidden = 'true'
2323

@@ -44,6 +44,16 @@ export class AudioTrackSelection extends shaka.ui.SettingsMenu {
4444
this.updateAudioTracks_()
4545
})
4646

47+
if (this.isSubMenu) {
48+
this.eventManager.listen(this.controls, 'submenuopen', () => {
49+
this.updateAudioTracks_()
50+
})
51+
52+
this.eventManager.listen(this.controls, 'submenuclose', () => {
53+
this.updateAudioTracks_()
54+
})
55+
}
56+
4757
this.updateLocalisedStrings_()
4858

4959
this.updateAudioTracks_()
@@ -94,7 +104,7 @@ export class AudioTrackSelection extends shaka.ui.SettingsMenu {
94104

95105
this.button.setAttribute('shaka-status', this.currentSelection.innerText)
96106

97-
if (count > 1) {
107+
if (count > 1 && !this.isSubMenuOpened) {
98108
this.button.classList.remove('shaka-hidden')
99109
} else {
100110
this.button.classList.add('shaka-hidden')

src/renderer/components/ft-shaka-video-player/player-components/AutoplayToggle.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export class AutoplayToggle extends shaka.ui.Element {
1818
this.button_.classList.add('autoplay-toggle', 'shaka-tooltip')
1919

2020
/** @private */
21-
this.icon_ = new shaka.ui.MaterialSVGIcon(this.button_, PlayerIcons.PAUSE_CIRCLE_FILLED)
21+
this.icon_ = new shaka.ui.Icon(this.button_, PlayerIcons.PAUSE_CIRCLE_FILLED)
2222

2323
const label = document.createElement('label')
2424
label.classList.add(

src/renderer/components/ft-shaka-video-player/player-components/FullWindowButton.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export class FullWindowButton extends shaka.ui.Element {
1919
this.button_.classList.add('full-window-button', 'shaka-tooltip')
2020

2121
/** @private */
22-
this.icon_ = new shaka.ui.MaterialSVGIcon(this.button_, PlayerIcons.OPEN_IN_FULL_FILLED)
22+
this.icon_ = new shaka.ui.Icon(this.button_, PlayerIcons.OPEN_IN_FULL_FILLED)
2323

2424
const label = document.createElement('label')
2525
label.classList.add(

src/renderer/components/ft-shaka-video-player/player-components/LegacyQualitySelection.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export class LegacyQualitySelection extends shaka.ui.SettingsMenu {
1717
this.menu.classList.add('legacy-qualities')
1818

1919
/** @type {SVGElement} */
20-
const checkmarkIcon = new shaka.ui.MaterialSVGIcon(null, PlayerIcons.DONE_FILLED).getSvgElement()
20+
const checkmarkIcon = new shaka.ui.Icon(null, PlayerIcons.DONE_FILLED).getSvgElement()
2121
checkmarkIcon.classList.add('shaka-chosen-item')
2222
checkmarkIcon.ariaHidden = 'true'
2323

@@ -63,6 +63,16 @@ export class LegacyQualitySelection extends shaka.ui.SettingsMenu {
6363
this.updateResolutionSelection_()
6464
})
6565

66+
if (this.isSubMenu) {
67+
this.eventManager.listen(this.controls, 'submenuopen', () => {
68+
this.button.classList.add('shaka-hidden')
69+
})
70+
71+
this.eventManager.listen(this.controls, 'submenuclose', () => {
72+
this.button.classList.remove('shaka-hidden')
73+
})
74+
}
75+
6676
this.updateResolutionSelection_()
6777
}
6878

@@ -116,12 +126,12 @@ export class LegacyQualitySelection extends shaka.ui.SettingsMenu {
116126
const activeCaptionIndex = this.player.getTextTracks().findIndex(caption => caption.active)
117127
let restoreCaptionIndex = null
118128

119-
if (activeCaptionIndex >= 0 && this.player.isTextTrackVisible()) {
129+
if (activeCaptionIndex >= 0) {
120130
restoreCaptionIndex = activeCaptionIndex
121131

122132
// hide captions before switching as shaka/the browser doesn't clean up the displayed captions
123133
// when switching away from the legacy formats
124-
await this.player.setTextTrackVisibility(false)
134+
this.player.selectTextTrack(null)
125135
}
126136

127137
this.events_.dispatchEvent(new CustomEvent('setLegacyFormat', {

0 commit comments

Comments
 (0)