Skip to content

Commit a432a5b

Browse files
author
Yaniv Aran-Shamir
committed
change fallback behavior
1 parent e6dadcf commit a432a5b

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

src/plugins/cloudinary/common.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,15 @@ const h264avcToString = (s) => {
158158
throw new Error('Codec string is not formatted according to H.264/AVC standards for example avc1.42001e (maybe an iOS friendly version...)');
159159
}
160160
let matches = s.match(REGEX);
161-
matches.shift(); // first one is the entire-string.
161+
if (matches !== null) {
162+
matches.shift(); // first one is the entire-string.
162163

163-
let vc_codec = ISOAVC_MAP[matches[0]];
164-
let avc_codec = typeof avc_codec === 'string' ? avc_codec : 'Unknown'; // explicit fix
164+
let vc_codec = ISOAVC_MAP[matches[0]];
165+
let avc_codec = typeof avc_codec === 'string' ? avc_codec : 'Unknown'; // explicit fix
165166

166-
return vc_codec + ':' + avcotiToStr(matches[1]);
167+
return vc_codec + ':' + avcotiToStr(matches[1]);
168+
}
169+
return s;
167170
};
168171

169172
const codecToSrcTransformation = (codec) => {

src/plugins/cloudinary/models/video-source.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import assign from 'utils/assign';
66
import { objectToQuerystring } from 'utils/querystring';
77

88
const DEFAULT_POSTER_PARAMS = { format: 'jpg', resource_type: 'video' };
9-
const DEFAULT_VIDEO_SOURCE_TYPES = ['webm', 'mp4', 'fallback'];
9+
const DEFAULT_VIDEO_SOURCE_TYPES = ['webm', 'mp4/h265', 'mp4', 'fallback'];
1010
const DEFAULT_CODEC_FOR_CONTAINER = {
1111
mp4: 'h264',
1212
webm: 'vp9'
@@ -192,7 +192,7 @@ function normalizeFormat(format) {
192192

193193
let res = FORMAT_MAPPINGS[format];
194194
if (!res) {
195-
res = format;
195+
res = format.split('\/').shift();
196196
}
197197

198198
return res;

src/video-player.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,6 @@ class VideoPlayer extends Utils.mixin(Eventable) {
390390
this.fallbackTrys = 0;
391391
this.videojs.on('error', () => {
392392
if ((this.videojs.error().code === 10 || this.videojs.error().code === 4) && !options.playerOptions.skipFallback) {
393-
this.videojs.error(null);
394393
this.fallbackToOrigFile();
395394
}
396395
});
@@ -522,13 +521,13 @@ class VideoPlayer extends Utils.mixin(Eventable) {
522521
}
523522

524523
fallbackToOrigFile() {
525-
if (this.fallbackTrys === 0) {
526-
527-
let src = this.videojs.currentSources().filter(src => src.isFallback);
524+
if (this.videojs.currentSources().length > 0) {
525+
this.videojs.error(null);
526+
let src = this.videojs.currentSources();
528527
if (src.length > 0) {
529-
this.videojs.src(src.pop());
528+
src.pop();
529+
this.videojs.src(src);
530530
}
531-
this.fallbackTrys++;
532531
}
533532
}
534533

0 commit comments

Comments
 (0)