Skip to content

Commit

Permalink
fix: Duplicate requests for video summarization and thumbnails info
Browse files Browse the repository at this point in the history
  • Loading branch information
tsi committed Sep 11, 2023
1 parent a2a2e3c commit 3ddea5d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 39 deletions.
14 changes: 11 additions & 3 deletions src/plugins/cloudinary/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@ import { applyWithProps } from 'utils/apply-with-props';
import { sliceAndUnsetProperties } from 'utils/slicing';
import { isKeyInTransformation } from 'utils/cloudinary';
import { assign } from 'utils/assign';
import { isFunction } from 'utils/type-inference';
import Playlistable from 'mixins/playlistable';
import plugins from 'plugins';
import {
normalizeOptions,
mergeTransformations,
codecShorthandTrans,
extendCloudinaryConfig
} from './common';
import Playlistable from 'mixins/playlistable';
import VideoSource from './models/video-source/video-source';
import EventHandlerRegistry from './event-handler-registry';
import AudioSource from './models/audio-source/audio-source';
import { isFunction } from '../../utils/type-inference';

const DEFAULT_PARAMS = {
transformation: {},
Expand Down Expand Up @@ -79,9 +80,16 @@ class CloudinaryContext extends mixin(Playlistable) {
}

_source = src;
if (!options.skipRefresh) {

const isDashRequired = options.sourceTypes && options.sourceTypes.some(s => s.includes('dash'));
if (plugins.dashPlugin && isDashRequired) {
plugins.dashPlugin().then(() => {
refresh();
});
} else if (!options.skipRefresh) {
refresh();
}

this.player.trigger('cldsourcechanged', { source: src });

return _chainTarget;
Expand Down
12 changes: 6 additions & 6 deletions src/plugins/cloudinary/models/video-source/video-source.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import BaseSource from '../base-source';
import ImageSource from '../image-source';
import { normalizeOptions, isSrcEqual, isRawUrl, mergeTransformations } from '../../common';
import { default as vjs } from 'video.js';
import { sliceAndUnsetProperties } from 'utils/slicing';
import { assign } from 'utils/assign';
import { objectToQuerystring } from 'utils/querystring';
import { default as vjs } from 'video.js';
import { castArray } from 'utils/array';
import { SOURCE_TYPE } from 'utils/consts';
import {
CONTAINER_MIME_TYPES,
DEFAULT_POSTER_PARAMS,
DEFAULT_VIDEO_PARAMS,
VIDEO_SUFFIX_REMOVAL_PATTERN
} from './video-source.const';
import { formatToMimeTypeAndTransformation, isCodecAlreadyExist, normalizeFormat } from './video-source.utils';
import { castArray } from '../../../../utils/array';
import { SOURCE_TYPE } from '../../../../utils/consts';
import { normalizeOptions, isSrcEqual, isRawUrl, mergeTransformations } from '../../common';
import BaseSource from '../base-source';
import ImageSource from '../image-source';

let objectId = 0;

Expand Down
30 changes: 0 additions & 30 deletions src/video-player.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,16 +135,6 @@ class VideoPlayer extends Utils.mixin(Eventable) {
};

_setVideoJsListeners(ready) {

// Prevent flash of error message while lazy-loading plugins.
videojs.hook('beforeerror', (player, err) => {
if (err && err.code === 3 && this.loadingLazyPlugins) {
err = null;
}
return err;
});


this.videojs.on(PLAYER_EVENT.ERROR, () => {
const error = this.videojs.error();
if (error) {
Expand Down Expand Up @@ -208,21 +198,6 @@ class VideoPlayer extends Utils.mixin(Eventable) {
this._initSeekThumbs();
}

async _initLazyPlugins(options) {
this.loadingLazyPlugins = true;

await this._initDash(options);

this.loadingLazyPlugins = false;
}

async _initDash(options) {
const isDashRequired = options.sourceTypes && options.sourceTypes.some(s => s.includes('dash'));
if (plugins.dashPlugin && isDashRequired) {
await plugins.dashPlugin();
}
}

_isFullScreen() {
return this.videojs.player().isFullscreen();
}
Expand Down Expand Up @@ -584,11 +559,6 @@ class VideoPlayer extends Utils.mixin(Eventable) {
const videoReadyTimeout = this.videojs.options_.videoTimeout || 55000;
this.reTryVideo(maxTries, videoReadyTimeout);

// Lazy loaded plugins
this._initLazyPlugins(options).then(() => {
return this.videojs.cloudinary.source(publicId, options);
});

return this.videojs.cloudinary.source(publicId, options);
}

Expand Down

0 comments on commit 3ddea5d

Please sign in to comment.