Skip to content

Commit 1a5d0cd

Browse files
author
Amir Tocker
committed
Add context to Video.
1 parent ac7b33f commit 1a5d0cd

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

src/components/Video/Video.js

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import React, {Component, PropTypes} from 'react';
2-
import cloudinary from 'cloudinary-core';
2+
import {Cloudinary, Configuration, Transformation, Util} from 'cloudinary-core';
33
import CloudinaryComponent from '../CloudinaryComponent';
4-
const Util = cloudinary.Util;
5-
const Cloudinary = cloudinary.Cloudinary;
4+
65
const DEFAULT_POSTER_OPTIONS = {
76
format: 'jpg',
87
resource_type: 'video'
@@ -14,7 +13,7 @@ export default class Video extends CloudinaryComponent {
1413
this.state = {};
1514
}
1615

17-
componentWillReceiveProps(nextProps) {
16+
componentWillReceiveProps(nextProps, nextContext) {
1817
}
1918

2019
componentWillMount() {
@@ -26,13 +25,13 @@ export default class Video extends CloudinaryComponent {
2625
componentWillUnmount() {
2726
}
2827

29-
componentWillUpdate(nextProps, nextState) {
28+
componentWillUpdate(nextProps, nextState, nextContext) {
3029
}
3130

32-
componentDidUpdate(prevProps, prevState) {
31+
componentDidUpdate(prevProps, prevState, prevContext) {
3332
}
3433

35-
shouldComponentUpdate(nextProps, nextState) {
34+
shouldComponentUpdate(nextProps, nextState, nextContext) {
3635
return true;
3736
}
3837

@@ -43,27 +42,29 @@ export default class Video extends CloudinaryComponent {
4342
options = this.getOptions(options, {});
4443
let cld = Cloudinary.new(options);
4544
let sources = [];
46-
let tagAttributes = cloudinary.Transformation.new(options).toHtmlAttributes();
45+
let tagAttributes = Transformation.new(options).toHtmlAttributes();
4746
if (Util.isPlainObject(poster)) {
48-
let defaults = poster.publicId != null ? Cloudinary.DEFAULT_IMAGE_PARAMS : DEFAULT_POSTER_OPTIONS;
47+
let defaults = poster.publicId !== undefined && poster.publicId !== null ? Cloudinary.DEFAULT_IMAGE_PARAMS : DEFAULT_POSTER_OPTIONS;
4948
poster = cld.url(poster.publicId || publicId, Util.defaults({}, poster, defaults));
5049
}
5150
if(!Util.isEmpty(poster)){
52-
tagAttributes["poster"] = poster;
51+
tagAttributes.poster = poster;
52+
}
53+
if(!Util.isEmpty(this.state.poster)){
54+
tagAttributes.poster = this.state.poster;
5355
}
5456

5557
if(Util.isArray(sourceTypes)){
5658
sources = sourceTypes.map( srcType => {
5759
let transformation = sourceTransformation[srcType] || {};
5860
let src = cld.url(publicId, Util.defaults({}, transformation, {resource_type: 'video', format: srcType}));
59-
let mimeType = 'video/' + (srcType == 'ogv' ? 'ogg' : srcType);
61+
let mimeType = 'video/' + (srcType === 'ogv' ? 'ogg' : srcType);
6062
return <source key={mimeType} src={ src} type={ mimeType}/>;
6163
}
6264
);
6365
} else {
6466
tagAttributes["src"] = cld.url(publicId, {resource_type: 'video', format: sourceTypes});
6567
}
66-
console.log("Ready to return tag", tagAttributes);
6768
return (
6869
<video {...tagAttributes}>
6970
{sources}

0 commit comments

Comments
 (0)