Skip to content
Open
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
12 changes: 12 additions & 0 deletions docs/es-modules/poster.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ <h4>Raw URL - default with no poster image</h4>
<video id="player-raw" playsinline controls class="cld-video-player cld-fluid"></video>
</div>

<div class="video-container mb-4">
<h4>Applet poster (poster: true)</h4>
<h6>Uses applet service URL for poster</h6>
<video id="player-applet-poster" playsinline controls class="cld-video-player cld-fluid"></video>
</div>

<p class="mt-4">
<a href="https://cloudinary.com/documentation/cloudinary_video_player"
>Full documentation</a
Expand Down Expand Up @@ -89,6 +95,12 @@ <h4>Raw URL - default with no poster image</h4>
cloudName: 'demo',
publicId: 'https://res.cloudinary.com/demo/video/upload/sp_auto/sea_turtle.m3u8'
});

const playerAppletPoster = videoPlayer('player-applet-poster', {
cloudName: 'demo',
publicId: 'snow_horses',
poster: true
});
</script>

<!-- Bootstrap -->
Expand Down
31 changes: 31 additions & 0 deletions docs/poster.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@
publicId: 'https://res.cloudinary.com/demo/video/upload/sp_auto/sea_turtle.m3u8'
});

player5 = cloudinary.videoPlayer('player-applet-poster', {
cloud_name: 'demo',
publicId: 'snow_horses',
poster: true
// poster: 'https://images.unsplash.com/photo-1559551538-96c62c56b256?ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&q=80&w=3540'
});

}, false);
</script>

Expand Down Expand Up @@ -113,6 +120,17 @@ <h4>Raw URL - default with no poster image</h4>
></video>
</div>

<div class="video-container mb-4">
<h4>Applet poster (poster: true)</h4>
<h6>Uses applet service URL for poster</h6>
<video
id="player-applet-poster"
playsinline
controls
class="cld-video-player cld-fluid"
></video>
</div>

<p class="mt-4">
<a href="https://cloudinary.com/documentation/video_player_api_reference#posteroptions">Full documentation</a>
</p>
Expand Down Expand Up @@ -151,6 +169,13 @@ <h3 class="mt-4">Example Code:</h3>
class="cld-video-player cld-fluid"
&lt;/video&gt;

&lt;video
id="player-applet-poster"
playsinline
controls
class="cld-video-player cld-fluid"
&lt;/video&gt;

</code>
<code class="language-javascript">

Expand Down Expand Up @@ -179,6 +204,12 @@ <h3 class="mt-4">Example Code:</h3>
publicId: 'https://res.cloudinary.com/demo/video/upload/sp_auto/sea_turtle.m3u8'
});

player5 = cloudinary.videoPlayer('player-applet-poster', {
cloud_name: 'demo',
publicId: 'snow_horses',
poster: true
});

</code>
</pre>
</div>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"files": [
{
"path": "./dist/cld-video-player.min.js",
"maxSize": "135kb"
"maxSize": "136kb"
},
{
"path": "./lib/cld-video-player.js",
Expand Down
10 changes: 8 additions & 2 deletions src/plugins/cloudinary/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,14 @@ class CloudinaryContext {
options.cloudinaryConfig = extendCloudinaryConfig(this.cloudinaryConfig(), options.cloudinaryConfig || {});
options.transformation = mergeTransformations(this.transformation(), options.transformation || {});
options.sourceTransformation = options.sourceTransformation || this.sourceTransformation();
options.sourceTypes = options.sourceTypes || this.sourceTypes();
options.poster = options.poster || posterOptionsForCurrent();
options.sourceTypes = options.sourceTypes || this.sourceTypes();


const defaultPosterOptions = posterOptionsForCurrent();
const userPosterOptions = options.posterOptions || {};
options.poster = options.poster || defaultPosterOptions;
options.posterOptions = Object.assign({}, defaultPosterOptions, userPosterOptions);

options.queryParams = Object.assign(options.queryParams || {}, options.allowUsageReport ? { _s: `vp-${VERSION}` } : {});

if (options.sourceTypes.indexOf('audio') > -1) {
Expand Down
27 changes: 24 additions & 3 deletions src/plugins/cloudinary/models/video-source/video-source.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ import {
hasCodec,
normalizeFormat
} from './video-source.utils';
import { normalizeOptions, isSrcEqual, isRawUrl, mergeTransformations } from '../../common';
import { normalizeOptions, isSrcEqual, isRawUrl, mergeTransformations, getCloudinaryUrlPrefix } from '../../common';
import { utf8ToBase64 } from 'utils/utf8Base64';
import Transformation from '@cloudinary/url-gen/backwards/transformation';
import BaseSource from '../base-source';
import ImageSource from '../image-source';

Expand Down Expand Up @@ -127,9 +129,28 @@ class VideoSource extends BaseSource {
}

options.cloudinaryConfig = options.cloudinaryConfig || this.cloudinaryConfig();

options.resource_type = this.resourceType() || options.resource_type;


if (publicId === true) {
const urlPrefix = getCloudinaryUrlPrefix(options.cloudinaryConfig);
const deliveryType = this.getInitOptions().type || 'upload';
const base64PublicId = utf8ToBase64(this.publicId());
let appletUrl = `${urlPrefix}/_applet_/video_service/elements/${deliveryType}/${base64PublicId}/poster`;

const transformation = this.getInitOptions().posterOptions?.transformation;
if (transformation) {
const transformationString = new Transformation(transformation).toString();
appletUrl += `?tx=${transformationString}`;
}

this._poster = new ImageSource(appletUrl, {
cloudinaryConfig: options.cloudinaryConfig
});

return this;
}

this._poster = new ImageSource(publicId, options);

return this;
Expand Down