Skip to content

Conversation

@tsi
Copy link
Collaborator

@tsi tsi commented Oct 26, 2025

Refactor Player Initialization API and Profile Configuration

Jira: https://cloudinary.atlassian.net/browse/VIDEO-20073

Overview

Refactors player initialization to centralize profile and video-specific configuration fetching, laying the groundwork for asset-level config support.

Prepared infrastructure for video-specific configuration fetching

This refactoring centralizes all configuration fetching logic in src/utils/fetch-config.js, making it straightforward to support per-video configurations. The new architecture cleanly handles:

  • Default profiles (built-in)
  • Custom profiles (fetched from cloud)
  • Asset-specific configs (per-video settings) - ready to expand

The unified fetchAndMergeConfig utility provides a single point for all config resolution, properly merging profiles with player options and maintaining analytics metadata.

Key Changes

Code Organization

  • Created src/utils/fetch-config.js - centralized config fetching for profiles and asset-specific settings
  • Deleted src/player.js - logic moved to appropriate locations
  • Moved cloudinaryConfig extraction into extractOptions()
  • Removed function renaming layer in src/index.js

API Clarity

  • Sync methods (videoPlayer, videoPlayers) - Simple use cases
  • Async methods (player, players) - Profile/config support
  • Sync methods warn if profile option used

Testing

  • Extended profiles page E2E tests from 3 to 5 videos
  • All unit and E2E tests passing

Benefits

✅ Infrastructure ready for video-specific config expansion
✅ Cleaner code organization and maintainability
✅ Clear sync vs async API contracts
✅ Full backward compatibility

Breaking Changes

None

@tsi tsi self-assigned this Oct 26, 2025
@netlify
Copy link

netlify bot commented Oct 26, 2025

Deploy Preview for cld-vp-esm-pages ready!

Name Link
🔨 Latest commit 8c71e04
🔍 Latest deploy log https://app.netlify.com/projects/cld-vp-esm-pages/deploys/6903454209115b00088b8c6e
😎 Deploy Preview https://deploy-preview-920--cld-vp-esm-pages.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link

netlify bot commented Oct 26, 2025

Deploy Preview for cld-video-player ready!

Name Link
🔨 Latest commit 8c71e04
🔍 Latest deploy log https://app.netlify.com/projects/cld-video-player/deploys/69034542f3c85400084d48ef
😎 Deploy Preview https://deploy-preview-920--cld-video-player.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@tsi tsi marked this pull request as ready for review October 28, 2025 10:52
@tsi tsi requested a review from a team as a code owner October 28, 2025 10:52
Copy link
Contributor

@kalifyaniv-cloudinary kalifyaniv-cloudinary left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💪

export const videoPlayer = (id, playerOptions = {}, ready) => {
const { videoElement, options } = getConfig(id, playerOptions);
if (options.profile) {
console.warn('Profile option requires async initialization. Use cloudinary.player() instead of cloudinary.videoPlayer()');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💪

Comment on lines +44 to 52
const cloudinaryVideoPlayerLegacyConfig = () => {
console.warn(
'Cloudinary.new() is deprecated and will be removed. Please use cloudinary.videoPlayer() instead.'
);
return {
videoPlayer: getVideoPlayer(config),
videoPlayers: getVideoPlayers(config)
videoPlayer,
videoPlayers
};
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isnt it time to deprecate it for real?

Copy link
Collaborator Author

@tsi tsi Oct 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In theory, yes, absolutely.
On the other hand, this.

tsi added 2 commits October 30, 2025 13:00
* chore: simplify and test build system

* docs: transformations example page

* chore: refactor and cleanup icons (#923)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants