Skip to content

Commit a8d0347

Browse files
authored
fix: filename generated for download button (#900)
* fix: filename generated for download button * chore: add download to schema
1 parent cc660e7 commit a8d0347

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/config/configSchema.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,10 @@
139139
"type": "boolean",
140140
"default": false
141141
},
142+
"download": {
143+
"type": "boolean",
144+
"default": false
145+
},
142146
"seekThumbnails": {
143147
"type": "boolean",
144148
"default": true

src/plugins/share/share.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,15 @@ const SharePlugin = function (options = {}, playerInstance) {
5454

5555
const transformations = stripKeysDeep(player.cloudinary.transformation() || {});
5656

57+
const filename = player.cloudinary.currentPublicId()?.split('/')?.pop();
58+
5759
const baseOptions = {
5860
...player.cloudinary.cloudinaryConfig(),
5961
...transformations,
6062
resource_type: 'video',
6163
format: 'mp4',
6264
video_codec: 'h264',
63-
flags: `streaming_attachment:${player.cloudinary.currentPublicId()}`,
65+
flags: `streaming_attachment:${filename}`,
6466
};
6567

6668
// For ABR - download a limited-size video
@@ -114,9 +116,6 @@ const SharePlugin = function (options = {}, playerInstance) {
114116
const response = await fetch(url, { method: 'HEAD' });
115117

116118
if (RETRY_STATUS_CODES.includes(response.status) && attempt < MAX_ATTEMPTS) {
117-
if (attempt === 0) {
118-
setPreparingState(true);
119-
}
120119
await wait(INTERVAL_MS);
121120
return fetchDownload(attempt + 1);
122121
}
@@ -125,6 +124,7 @@ const SharePlugin = function (options = {}, playerInstance) {
125124
triggerDownload();
126125
};
127126

127+
setPreparingState(true);
128128
fetchDownload();
129129
};
130130

0 commit comments

Comments
 (0)