Skip to content

Commit

Permalink
Merge pull request #7 from apivideo/add-video-style-attributes
Browse files Browse the repository at this point in the history
Fix style attributes on instantiation
  • Loading branch information
olivier-lando authored Jun 23, 2022
2 parents 482b2f4 + acb14d4 commit 7f5ac93
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Changelog
All changes to this project will be documented in this file.

## [1.0.0] - 2022-06-23
## [1.0.1] - 2022-06-23
- Add `videoStyleObjectFit` and `videoStyleTransform` attributes

## [0.1.3] - 2022-04-27
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@api.video/react-player",
"version": "1.0.0",
"version": "1.0.1",
"description": "api.video React player component",
"keywords": [
"player",
Expand Down
15 changes: 11 additions & 4 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,13 @@ export default class ApiVideoPlayer extends React.Component<ApiVideoPlayerProps,
this.playerSdk.addEventListener("userinactive", () => this.props.onUserInactive && this.props.onUserInactive());
this.playerSdk.addEventListener("volumechange", (v) => this.props.onVolumeChange && this.props.onVolumeChange(v.volume));

if(this.props.videoStyleObjectFit) {
this.playerSdk.setVideoStyleObjectFit(this.props.videoStyleObjectFit);
}

if(this.props.videoStyleTransform) {
this.playerSdk.setVideoStyleTransform(this.props.videoStyleTransform);
}

this.playerSdk.addEventListener("ready", () => {
this.playerSdk.getVolume().then(d => this.props.onVolumeChange && this.props.onVolumeChange(d));
Expand Down Expand Up @@ -206,11 +213,11 @@ export default class ApiVideoPlayer extends React.Component<ApiVideoPlayerProps,
if (nextProps.playbackRate !== undefined && nextProps.playbackRate !== this.props.playbackRate) {
this.playerSdk.setPlaybackRate(nextProps.playbackRate);
}
if (nextProps.videoStyleObjectFit !== undefined && nextProps.videoStyleObjectFit !== this.props.videoStyleObjectFit) {
this.playerSdk.setVideoStyleObjectFit(nextProps.videoStyleObjectFit);
if (nextProps.videoStyleObjectFit !== this.props.videoStyleObjectFit) {
this.playerSdk.setVideoStyleObjectFit(nextProps.videoStyleObjectFit || "none");
}
if (nextProps.videoStyleTransform !== undefined && nextProps.videoStyleTransform !== this.props.videoStyleTransform) {
this.playerSdk.setVideoStyleTransform(nextProps.videoStyleTransform);
if (nextProps.videoStyleTransform !== this.props.videoStyleTransform) {
this.playerSdk.setVideoStyleTransform(nextProps.videoStyleTransform || "");
}

if (nextProps.controls !== undefined) {
Expand Down

0 comments on commit 7f5ac93

Please sign in to comment.