Skip to content

Commit d8d1bf7

Browse files
Merge pull request #45 from apivideo/add-video-style-methods
Add video style methods
2 parents aaf54a3 + ba51166 commit d8d1bf7

File tree

7 files changed

+36
-4
lines changed

7 files changed

+36
-4
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Changelog
22
All changes to this project will be documented in this file.
33

4+
## [1.2.20] - 2022-05-23
5+
- Add `setVideoStyleObjectFit()` and `setVideoStyleTransform()` methods.
6+
47
## [1.2.19] - 2022-05-19
58
- When loadConfig() is called, apply the last config settings
69

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
- [`setPlaybackRate(rate: number)`](#setplaybackraterate-number)
3636
- [`setCurrentTime(time: number)`](#setcurrenttimetime-number)
3737
- [`setVolume(volume: number)`](#setvolumevolume-number)
38+
- [`setVideoStyleObjectFit(value: "contain" | "cover" | "fill" | "none" | "scale-down")`](#setvideostyleobjectfitvalue-contain--cover--fill--none--scale-down)
39+
- [`setVideoStyleTransform(value: string)`](#setvideostyletransformvalue-string)
3840
- [`setTheme(theme: PlayerTheme)`](#setthemetheme-playertheme)
3941
- [`requestFullscreen()`](#requestfullscreen)
4042
- [`exitFullscreen()`](#exitfullscreen)
@@ -264,6 +266,22 @@ The sdk instance has the following methods:
264266
> ```javascript
265267
> player.setVolume(0.75); // Set the volume to 75%
266268
> ```
269+
#### `setVideoStyleObjectFit(value: "contain" | "cover" | "fill" | "none" | "scale-down")`
270+
> Change the [object-fit](https://developer.mozilla.org/fr/docs/Web/CSS/object-fit) CSS value of the video tag.
271+
272+
> Example:
273+
> ```javascript
274+
> player.setVideoStyleObjectFit("cover"); // Set the object-fit to cover
275+
> ```
276+
277+
#### `setVideoStyleTransform(value: string)`
278+
> Change the [transform](https://developer.mozilla.org/fr/docs/Web/CSS/transform) CSS value of the video tag.
279+
280+
> Example:
281+
> ```javascript
282+
> player.setVideoStyleTransform("rotateY(180deg)"); // Apply a 180deg rotation around the Y axis (mirroring)
283+
> ```
284+
267285
#### `setTheme(theme: PlayerTheme)`
268286
> Change the appearance of the player.
269287
>

dist/index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ export declare class PlayerSdk {
7878
constructor(targetSelector: string | Element, userOptions?: SdkOptions);
7979
loadConfig(options: SdkOptions): void;
8080
play(): void;
81+
setVideoStyleTransform(value: string): void;
82+
setVideoStyleObjectFit(value: "contain" | "cover" | "fill" | "none" | "scale-down"): void;
8183
hideControls(controls?: ControlName[]): void;
8284
showControls(controls?: ControlName[]): void;
8385
hideSubtitles(): void;

dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,15 @@ export class PlayerSdk {
149149
play() {
150150
this.postMessage({ message: 'play' });
151151
}
152+
153+
setVideoStyleTransform(value: string) {
154+
this.postMessage({ message: 'setStyleProperty', query: "video", property: "transform", value }, undefined, true);
155+
}
156+
157+
setVideoStyleObjectFit(value: "contain" | "cover" | "fill" | "none" | "scale-down") {
158+
this.postMessage({ message: 'setStyleProperty', query: "video", property: "object-fit", value }, undefined, true);
159+
}
160+
152161
hideControls(controls?: ControlName[]) {
153162
if(!controls) {
154163
this.options.hideControls = true;

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@api.video/player-sdk",
3-
"version": "1.2.19",
3+
"version": "1.2.20",
44
"description": "api.video player SDK",
55
"repository": {
66
"type": "git",

0 commit comments

Comments
 (0)