Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const DEFAULT_VIDEO_PARAMS = {
chapters: {}
};

const COMMON_VIDEO_EXTENSIONS = [
export const COMMON_VIDEO_EXTENSIONS = [
'3g2',
'3gp',
'avi',
Expand Down
24 changes: 14 additions & 10 deletions src/plugins/cloudinary/models/video-source/video-source.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
ADAPTIVE_SOURCETYPES,
DEFAULT_POSTER_PARAMS,
DEFAULT_VIDEO_PARAMS,
COMMON_VIDEO_EXTENSIONS,
VIDEO_SUFFIX_REMOVAL_PATTERN
} from './video-source.const';
import {
Expand Down Expand Up @@ -167,8 +168,7 @@ class VideoSource extends BaseSource {

generateSources() {
if (this.isRawUrl) {
const type = this.sourceTypes()[0] === 'auto' ? null : this.sourceTypes()[0];
return [this.generateRawSource(this.publicId(), type)];
return [this.generateRawSource(this.publicId(), this.sourceTypes()[0])];
}

const srcs = this.sourceTypes().map(sourceType => {
Expand Down Expand Up @@ -231,17 +231,21 @@ class VideoSource extends BaseSource {
}

generateRawSource(url, type) {
type = type || url.split('.').pop();
// If type is not provided (default is 'auto'), determine it from the URL extension
if (!type || type === 'auto') {
const ext = url.split('.').pop().split(/[?#]/)[0].toLowerCase();
type = COMMON_VIDEO_EXTENSIONS.includes(ext) ? ext : 'auto';
}

const isAdaptive = ADAPTIVE_SOURCETYPES.includes(type);

if (CONTAINER_MIME_TYPES[type]) {
type = CONTAINER_MIME_TYPES[type];
} else {
type = type ? `video/${type}` : null;
}

return { type, src: url, cldSrc: this, isAdaptive, withCredentials: this.withCredentials };
return {
type: CONTAINER_MIME_TYPES[type] || `video/${type}`,
src: url,
cldSrc: this,
isAdaptive,
withCredentials: this.withCredentials
};
}

info(value) {
Expand Down
Loading