Skip to content

Commit 2c9f46a

Browse files
committed
feat(VIDEO-19871): control-bar download button timeout
1 parent cc1a24f commit 2c9f46a

File tree

3 files changed

+20
-12
lines changed

3 files changed

+20
-12
lines changed

src/plugins/share/components/download-button.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,21 @@ class ShareDownloadButton extends ClickableComponent {
3434

3535
return button;
3636
}
37+
38+
/**
39+
* Toggles the "preparing download" visual state (spinner + title).
40+
* @param {boolean} isPreparing
41+
*/
42+
setPreparing(isPreparing) {
43+
const el = this.el();
44+
if (isPreparing) {
45+
el.classList.add('vjs-waiting');
46+
el.setAttribute('title', 'Download is being prepared');
47+
} else {
48+
el.classList.remove('vjs-waiting');
49+
el.setAttribute('title', 'Download video');
50+
}
51+
}
3752
}
3853

3954
videojs.registerComponent('ShareDownloadButton', ShareDownloadButton);

src/plugins/share/share.js

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ const SharePlugin = function (options = {}, playerInstance) {
8484
return;
8585
}
8686

87-
const MAX_ATTEMPTS = 30; // 30 tries / 3s interval
88-
const INTERVAL_MS = 3000;
87+
const MAX_ATTEMPTS = 60; // 60 tries / 10s interval
88+
const INTERVAL_MS = 10000;
8989

9090
const triggerDownload = () => {
9191
const a = document.createElement('a');
@@ -102,14 +102,7 @@ const SharePlugin = function (options = {}, playerInstance) {
102102
return;
103103
}
104104
const el = btn.el();
105-
const btnTitle = el.getAttribute('title');
106-
if (isPreparing) {
107-
el.classList.add('vjs-waiting');
108-
el.setAttribute('title', 'Download is being prepared');
109-
} else {
110-
el.classList.remove('vjs-waiting');
111-
el.setAttribute('title', btnTitle);
112-
}
105+
btn?.setPreparing?.(isPreparing);
113106
};
114107

115108
const pollForAvailability = (attempt = 0) => {

src/plugins/share/share.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
// Spinner styling (mirrors visual-search button)
1010
> .vjs-loading-spinner {
1111
display: none;
12-
width: 1.55em;
13-
height: 1.55em;
12+
width: 1.4em;
13+
height: 1.4em;
1414
border-width: 0.2em;
1515
position: absolute;
1616
left: 50%;

0 commit comments

Comments
 (0)