Skip to content

Commit ae5d41f

Browse files
feat: SNI-6952 add cldPoster to vue sdk video component
1 parent 5121df0 commit ae5d41f

2 files changed

Lines changed: 36 additions & 3 deletions

File tree

packages/vue/src/components/AdvancedVideo.vue

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
1414
import { ref, onMounted, onUpdated, onUnmounted } from "vue";
1515
import { CloudinaryVideo } from "@cloudinary/url-gen/assets/CloudinaryVideo";
16+
import { CloudinaryImage } from "@cloudinary/url-gen/assets/CloudinaryImage";
1617
import {
1718
HtmlVideoLayer,
1819
Plugins,
@@ -24,6 +25,7 @@ interface VideoProps {
2425
cldVid: CloudinaryVideo;
2526
plugins?: Plugins;
2627
sources?: VideoSources;
28+
cldPoster?: CloudinaryImage | 'auto';
2729
2830
[x: string]: any;
2931
}
@@ -44,7 +46,9 @@ onMounted(() => {
4446
videoRef.value,
4547
props.cldVid,
4648
props.sources,
47-
props.plugins
49+
props.plugins,
50+
undefined,
51+
props.cldPoster
4852
);
4953
});
5054
@@ -58,7 +62,9 @@ onUpdated(() => {
5862
htmlLayerInstance.update(
5963
props.cldVid,
6064
props.sources,
61-
props.plugins
65+
props.plugins,
66+
undefined,
67+
props.cldPoster
6268
);
6369
});
6470

packages/vue/tests/unit/AdvancedVideo.spec.ts

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
import { mount } from "@vue/test-utils";
2-
import { CloudinaryVideo } from "@cloudinary/url-gen";
2+
import { CloudinaryImage, CloudinaryVideo } from "@cloudinary/url-gen";
33
import { auto, vp9 } from "@cloudinary/url-gen/qualifiers/videoCodec";
44
import { videoCodec } from "@cloudinary/url-gen/actions/transcode";
55
import { AdvancedVideo } from "../../src";
66
import { waitTicks } from "../unit/utils";
77

8+
const cloudinaryImage = new CloudinaryImage(
9+
"sample",
10+
{ cloudName: "demo" },
11+
{ analytics: false }
12+
);
813
const cloudinaryVideo = new CloudinaryVideo(
914
"sample",
1015
{ cloudName: "demo" },
@@ -110,6 +115,28 @@ describe("AdvancedVideo", () => {
110115
expect(component.html()).toContain('poster="www.example.com"');
111116
});
112117

118+
it('should contain poster when "auto" is passed as cldPoster', async function () {
119+
const component = mount(AdvancedVideo, {
120+
props: { cldVid: cloudinaryVideo, cldPoster: "auto" },
121+
});
122+
await waitTicks(1);
123+
124+
expect(component.html()).toContain(
125+
'poster="https://res.cloudinary.com/demo/video/upload/q_auto/f_jpg/so_auto/sample"'
126+
);
127+
});
128+
129+
it("should contain poster when cloudinary image is passed as cldPoster", async function () {
130+
const component = mount(AdvancedVideo, {
131+
props: { cldVid: cloudinaryVideo, cldPoster: cloudinaryImage },
132+
});
133+
await waitTicks(1);
134+
135+
expect(component.html()).toContain(
136+
'poster="https://res.cloudinary.com/demo/image/upload/sample"'
137+
);
138+
});
139+
113140
it("should emit play event", async function () {
114141
const mockCallback = jest.fn();
115142

0 commit comments

Comments
 (0)