-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: video profiles * feat: video profiles * feat: video profiles - default profile json * feat: video profiles * feat: rollback webpack changes * fix: review, es export, name * fix: webpack json * fix: webpack config
- Loading branch information
1 parent
888dc61
commit 0e99c27
Showing
11 changed files
with
210 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Cloudinary Video Player</title> | ||
<link href="https://res.cloudinary.com/cloudinary-marketing/image/upload/f_auto,q_auto/c_scale,w_32/v1597183771/creative_staging/cloudinary_internal/Website/Brand%20Updates/Favicon/cloudinary_web_favicon_192x192.png" rel="icon" type="image/png"> | ||
|
||
<!-- Bootstrap --> | ||
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"> | ||
|
||
<!-- highlight.js --> | ||
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/solarized-light.min.css"> | ||
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script> | ||
<script>hljs.initHighlightingOnLoad();</script> | ||
|
||
<!-- | ||
We're loading scripts & style dynamically for development/testing. | ||
Real-world usage would look like this: | ||
<link rel="stylesheet" href="https://unpkg.com/cloudinary-video-player/dist/cld-video-player.min.css"> | ||
<script src="https://unpkg.com/cloudinary-video-player/dist/cld-video-player.min.js"></script> | ||
--> | ||
|
||
<script type="text/javascript" src="./scripts.js"></script> | ||
|
||
<script type="text/javascript"> | ||
window.addEventListener('load', async function() { | ||
const playerWithDefaultProfile = await cloudinary.videoPlayerWithProfile('player-default-profile', { | ||
cloud_name: 'demo', | ||
profile: 'cldDefault', | ||
}); | ||
|
||
playerWithDefaultProfile.source('sea_turtle'); | ||
|
||
const playerWithCustomProfile = await cloudinary.videoPlayerWithProfile('player-custom-profile', { | ||
cloud_name: 'dwaq5xqm4', | ||
profile: 'https://res.cloudinary.com/dwaq5xqm4/raw/upload/v1/profiles/default_profile.json', | ||
}); | ||
|
||
playerWithCustomProfile.source('samples/cld-sample-video'); | ||
}, false); | ||
</script> | ||
</head> | ||
<body> | ||
<div class="container p-4 col-12 col-md-9 col-xl-6"> | ||
<nav class="nav mb-2"> | ||
<a href="./index.html"><< Back to examples index</a> | ||
</nav> | ||
<h1>Cloudinary Video Player</h1> | ||
<h3 class="mb-4">Profiles</h3> | ||
|
||
<h5>Player with default profile</h5> | ||
<video | ||
id="player-default-profile" | ||
playsinline | ||
controls | ||
autoplay | ||
muted | ||
class="cld-video-player" | ||
width="500"> | ||
</video> | ||
|
||
<br/><br/> | ||
<h5>Player with custom profile</h5> | ||
<video | ||
id="player-custom-profile" | ||
playsinline | ||
controls | ||
autoplay | ||
muted | ||
class="cld-video-player" | ||
width="500"> | ||
</video> | ||
|
||
<h3 class="mt-4">Example Code:</h3> | ||
|
||
<pre><code class="language-html"> | ||
|
||
<video | ||
id="player-default-profile" | ||
controls | ||
autoplay | ||
muted | ||
class="cld-video-player" | ||
width="500"> | ||
</video> | ||
|
||
<video | ||
id="player-custom-profile" | ||
controls | ||
autoplay | ||
muted | ||
class="cld-video-player" | ||
width="500"> | ||
</video> | ||
|
||
</code> | ||
<code class="language-javascript"> | ||
window.addEventListener('load', async function() { | ||
const playerWithDefaultProfile = await cloudinary.videoPlayerWithProfile('player-default-profile', { | ||
cloud_name: 'demo', | ||
profile: 'loopingVideo', | ||
}); | ||
|
||
playerWithDefaultProfile.source('sea_turtle'); | ||
|
||
const playerWithCustomProfile = await cloudinary.videoPlayerWithProfile('player-custom-profile', { | ||
cloud_name: 'dwaq5xqm4', | ||
profile: 'https://res.cloudinary.com/dwaq5xqm4/raw/upload/v1/profiles/default_profile.json', | ||
}); | ||
|
||
playerWithCustomProfile.source('samples/cld-sample-video'); | ||
}, false); | ||
</code> | ||
</pre> | ||
</div> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"playerOptions": { | ||
"fluid": true, | ||
"controls": true, | ||
"controlBar": { | ||
"fullscreenToggle": false | ||
}, | ||
"showJumpControls": true, | ||
"hideContextMenu": false, | ||
"floatingWhenNotVisible": "none" | ||
}, | ||
"sourceOptions": { | ||
"chapters": true, | ||
"sourceTypes": ["hls"], | ||
"transformation": [ | ||
{ | ||
"effect": ["volume:auto"] | ||
} | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"playerOptions": {}, | ||
"sourceOptions": {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"playerOptions": { | ||
"fluid": true, | ||
"controls": false, | ||
"muted": true, | ||
"floatingWhenNotVisible": "none", | ||
"hideContextMenu": false, | ||
"autoplay": true, | ||
"loop": true | ||
}, | ||
"sourceOptions": {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import cldDefault from './cldDefault.json'; | ||
import cldLooping from './cldLooping.json'; | ||
import cldAdaptiveStream from './cldAdaptiveStream.json'; | ||
|
||
export const defaultProfiles = { | ||
cldDefault, | ||
cldLooping, | ||
cldAdaptiveStream | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import VideoPlayer from './video-player'; | ||
|
||
export const getProfile = async (cloudName, profile) => { | ||
const defaultProfiles = await import(/* webpackChunkName: "defaultProfiles" */ './config/profiles'); | ||
|
||
if (Object.keys(defaultProfiles).includes(profile)) { | ||
return defaultProfiles[profile]; | ||
} | ||
|
||
return await fetch(profile, { method: 'GET' }).then(res => res.json()); | ||
}; | ||
|
||
const videoPlayerProfile = async (elem, initOptions, ready) => { | ||
if (!initOptions.profile) { | ||
throw new Error('VideoPlayerProfile method requires "profile" property'); | ||
} | ||
|
||
try { | ||
const profileOptions = await getProfile(initOptions.cloud_name, initOptions.profile); | ||
const options = Object.assign({}, profileOptions.playerOptions, initOptions); | ||
const videoPlayer = new VideoPlayer(elem, options, ready); | ||
|
||
const nativeVideoPlayerSourceMethod = videoPlayer.source; | ||
videoPlayer.source = (id, options) => { | ||
const extendedOptions = Object.assign({}, profileOptions.sourceOptions, options); | ||
return nativeVideoPlayerSourceMethod.call(videoPlayer, id, extendedOptions); | ||
}; | ||
|
||
return videoPlayer; | ||
} catch (e) { | ||
const videoPlayer = new VideoPlayer(elem, initOptions); | ||
videoPlayer.videojs.error('Invalid profile'); | ||
return videoPlayer; | ||
} | ||
}; | ||
|
||
export default videoPlayerProfile; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { videoPlayerWithProfile as default } from './index.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters