|
7 | 7 | ADAPTIVE_SOURCETYPES, |
8 | 8 | DEFAULT_POSTER_PARAMS, |
9 | 9 | DEFAULT_VIDEO_PARAMS, |
| 10 | + COMMON_VIDEO_EXTENSIONS, |
10 | 11 | VIDEO_SUFFIX_REMOVAL_PATTERN |
11 | 12 | } from './video-source.const'; |
12 | 13 | import { |
@@ -167,8 +168,7 @@ class VideoSource extends BaseSource { |
167 | 168 |
|
168 | 169 | generateSources() { |
169 | 170 | if (this.isRawUrl) { |
170 | | - const type = this.sourceTypes()[0] === 'auto' ? null : this.sourceTypes()[0]; |
171 | | - return [this.generateRawSource(this.publicId(), type)]; |
| 171 | + return [this.generateRawSource(this.publicId(), this.sourceTypes()[0])]; |
172 | 172 | } |
173 | 173 |
|
174 | 174 | const srcs = this.sourceTypes().map(sourceType => { |
@@ -231,17 +231,21 @@ class VideoSource extends BaseSource { |
231 | 231 | } |
232 | 232 |
|
233 | 233 | generateRawSource(url, type) { |
234 | | - type = type || url.split('.').pop(); |
| 234 | + // If type is not provided (default is 'auto'), determine it from the URL extension |
| 235 | + if (!type || type === 'auto') { |
| 236 | + const ext = url.split('.').pop().split(/[?#]/)[0].toLowerCase(); |
| 237 | + type = COMMON_VIDEO_EXTENSIONS.includes(ext) ? ext : 'auto'; |
| 238 | + } |
235 | 239 |
|
236 | 240 | const isAdaptive = ADAPTIVE_SOURCETYPES.includes(type); |
237 | 241 |
|
238 | | - if (CONTAINER_MIME_TYPES[type]) { |
239 | | - type = CONTAINER_MIME_TYPES[type]; |
240 | | - } else { |
241 | | - type = type ? `video/${type}` : null; |
242 | | - } |
243 | | - |
244 | | - return { type, src: url, cldSrc: this, isAdaptive, withCredentials: this.withCredentials }; |
| 242 | + return { |
| 243 | + type: CONTAINER_MIME_TYPES[type] || `video/${type}`, |
| 244 | + src: url, |
| 245 | + cldSrc: this, |
| 246 | + isAdaptive, |
| 247 | + withCredentials: this.withCredentials |
| 248 | + }; |
245 | 249 | } |
246 | 250 |
|
247 | 251 | info(value) { |
|
0 commit comments