Skip to content

Commit 417d4a7

Browse files
feat: SNI-6952 add VideoPoster type for cldVideo
1 parent a9065df commit 417d4a7

6 files changed

Lines changed: 17 additions & 12 deletions

File tree

packages/angular/projects/cloudinary-library/src/lib/cloudinary-video.component.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import {Component, OnInit, Input, ElementRef, EventEmitter, Output, OnChanges, OnDestroy} from '@angular/core';
2-
import {CloudinaryImage, CloudinaryVideo} from '@cloudinary/url-gen';
2+
import {CloudinaryVideo} from '@cloudinary/url-gen';
33

44
import {
55
cancelCurrentlyRunningPlugins,
66
HtmlVideoLayer,
77
Plugins,
8+
VideoPoster,
89
VideoSources
910
} from '@cloudinary/html';
1011

@@ -14,7 +15,7 @@ import {
1415
* @type {Component}
1516
* @description The Cloudinary video component.
1617
* @prop {CloudinaryVideo} transformation Generated by @cloudinary/url-gen
17-
* @prop {CloudinaryImage | "auto"} transformation Generated by @cloudinary/url-gen
18+
* @prop {VideoPoster} transformation Generated by @cloudinary/url-gen
1819
* @prop {Plugins} plugins Advanced image component plugins lazyload()
1920
* @prop videoAttributes Optional attributes include controls, loop, muted, poster, preload, autoplay
2021
* @prop videoEvents Optional video events include play, loadstart, playing, error, ended
@@ -52,7 +53,7 @@ export class CloudinaryVideoComponent implements OnInit, OnChanges, OnDestroy {
5253
constructor(private el: ElementRef) { }
5354

5455
@Input('cldVid') cldVid: CloudinaryVideo;
55-
@Input('cldPoster') cldPoster: CloudinaryImage | 'auto';
56+
@Input('cldPoster') cldPoster: VideoPoster;
5657
@Input('sources') sources: VideoSources;
5758
@Input('plugins') plugins: Plugins;
5859
@Input('poster') poster: string;

packages/html/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ export {accessibility} from './plugins/accessibility.js';
99
export {placeholder} from './plugins/placeholder.js';
1010
export {isBrowser} from './utils/isBrowser.js';
1111
export {serverSideSrc} from './utils/serverSideSrc.js';
12-
export {Plugins, VideoSources, PictureSources} from './types.js';
12+
export {Plugins, VideoSources, VideoPoster, PictureSources} from './types.js';
1313
export {cancelCurrentlyRunningPlugins} from './utils/cancelCurrentlyRunningPlugins.js';

packages/html/src/layers/htmlVideoLayer.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Plugins, HtmlPluginState, VideoSources, VideoType} from '../types.js'
1+
import {Plugins, HtmlPluginState, VideoSources, VideoType, VideoPoster} from '../types.js'
22
import cloneDeep from 'lodash.clonedeep'
33
import {CloudinaryImage, CloudinaryVideo} from "@cloudinary/url-gen";
44
import {render} from '../utils/render.js';
@@ -13,7 +13,7 @@ export class HtmlVideoLayer{
1313
mimeType = 'video';
1414
mimeSubTypes = VIDEO_MIME_TYPES;
1515

16-
constructor(element: HTMLVideoElement | null, userCloudinaryVideo: CloudinaryVideo, sources: VideoSources, plugins?: Plugins, videoAttributes?: object, userCloudinaryPoster?: CloudinaryImage | 'auto'){
16+
constructor(element: HTMLVideoElement | null, userCloudinaryVideo: CloudinaryVideo, sources: VideoSources, plugins?: Plugins, videoAttributes?: object, userCloudinaryPoster?: VideoPoster){
1717
this.videoElement = element;
1818
this.originalVideo = userCloudinaryVideo;
1919
this.htmlPluginState = {cleanupCallbacks:[], pluginEventSubscription: []};
@@ -104,7 +104,7 @@ export class HtmlVideoLayer{
104104
* In case of poster, sets the poster.
105105
* @param videoAttributes {object} Supported attributes: controls, loop, muted, poster, preload, autoplay, playsinline
106106
*/
107-
setVideoAttributes(videoAttributes: object = {}, userCloudinaryPoster?: CloudinaryImage | 'auto') {
107+
setVideoAttributes(videoAttributes: object = {}, userCloudinaryPoster?: VideoPoster) {
108108
if (userCloudinaryPoster === 'auto') {
109109
videoAttributes['poster'] = this.originalVideo
110110
.quality('auto')
@@ -129,7 +129,7 @@ export class HtmlVideoLayer{
129129
* @param plugins
130130
* @param videoAttributes
131131
*/
132-
update(updatedCloudinaryVideo: CloudinaryVideo, sources: VideoSources, plugins?: Plugins, videoAttributes?: object, userCloudinaryPoster?: CloudinaryImage | 'auto'){
132+
update(updatedCloudinaryVideo: CloudinaryVideo, sources: VideoSources, plugins?: Plugins, videoAttributes?: object, userCloudinaryPoster?: VideoPoster){
133133
if(updatedCloudinaryVideo !== this.originalVideo){
134134
const sourcesToDelete = this.videoElement.getElementsByTagName("SOURCE");
135135
while (sourcesToDelete[0]) sourcesToDelete[0].parentNode.removeChild(sourcesToDelete[0]);

packages/html/src/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,5 @@ export type PictureSources = {minWidth?: number, maxWidth?: number, image: Cloud
2020
export type PictureSource = {minWidth?: number, maxWidth?: number, image: CloudinaryImage, sizes?: string};
2121

2222
export type AnalyticsOptions = {sdkSemver: string, techVersion: string, sdkCode: string};
23+
24+
export type VideoPoster = CloudinaryImage | 'auto';

packages/react/src/AdvancedVideo.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { CloudinaryImage, CloudinaryVideo } from '@cloudinary/url-gen';
44
import {
55
HtmlVideoLayer,
66
Plugins,
7+
VideoPoster,
78
VideoSources,
89
cancelCurrentlyRunningPlugins
910
} from '@cloudinary/html';
@@ -12,7 +13,7 @@ type ReactEventHandler<T = Element> = EventHandler<SyntheticEvent<T>>;
1213

1314
interface VideoProps extends HTMLAttributes<HTMLVideoElement>{
1415
cldVid: CloudinaryVideo,
15-
cldPoster?: CloudinaryImage | "auto",
16+
cldPoster?: VideoPoster,
1617
plugins?: Plugins,
1718
sources?: VideoSources,
1819
innerRef?: ((instance: any) => void) | MutableRefObject<unknown> | null

packages/vue/src/components/AdvancedVideo.vue

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,16 @@
88
* @type {Component}
99
* @description The Cloudinary video component.
1010
* @prop {CloudinaryVideo} cldVid Generated by @cloudinary/url-gen
11+
* @prop {VideoPoster} cldPoster Generated by @cloudinary/url-gen
1112
* @prop {Plugins} plugins Advanced video component plugins accessibility(), responsive(), lazyload(), placeholder()
1213
*/
1314
1415
import { ref, onMounted, onUpdated, onUnmounted } from "vue";
15-
import { CloudinaryVideo } from "@cloudinary/url-gen/assets/CloudinaryVideo";
16-
import { CloudinaryImage } from "@cloudinary/url-gen/assets/CloudinaryImage";
16+
import { CloudinaryImage, CloudinaryVideo } from "@cloudinary/url-gen";
1717
import {
1818
HtmlVideoLayer,
1919
Plugins,
20+
VideoPoster,
2021
VideoSources,
2122
cancelCurrentlyRunningPlugins,
2223
} from "@cloudinary/html";
@@ -25,7 +26,7 @@ interface VideoProps {
2526
cldVid: CloudinaryVideo;
2627
plugins?: Plugins;
2728
sources?: VideoSources;
28-
cldPoster?: CloudinaryImage | 'auto';
29+
cldPoster?: VideoPoster;
2930
3031
[x: string]: any;
3132
}

0 commit comments

Comments
 (0)