@shoutem/ui 9.0.0 → 9.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/Video/Video.js +20 -14
- package/package.json +1 -1
|
@@ -6,24 +6,27 @@ import { connectAnimation } from '@shoutem/animation';
|
|
|
6
6
|
import { connectStyle } from '@shoutem/theme';
|
|
7
7
|
import VideoSourceReader from './VideoSourceReader';
|
|
8
8
|
|
|
9
|
-
function getSource(sourceReader, poster) {
|
|
9
|
+
function getSource(sourceReader, poster, headers) {
|
|
10
10
|
const url = sourceReader.getUrl();
|
|
11
|
+
let source;
|
|
11
12
|
|
|
12
13
|
if (sourceReader.isEmbeddableVideo()) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
source = { uri: url };
|
|
15
|
+
} else {
|
|
16
|
+
const HTML = `
|
|
17
|
+
<video width="100%" height="auto" poster="${poster}" controls >
|
|
18
|
+
<source src="${url}" >
|
|
19
|
+
</video>
|
|
20
|
+
`;
|
|
21
|
+
|
|
22
|
+
source = { html: HTML };
|
|
16
23
|
}
|
|
17
24
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
</video>
|
|
22
|
-
`;
|
|
25
|
+
if (headers) {
|
|
26
|
+
source.headers = headers;
|
|
27
|
+
}
|
|
23
28
|
|
|
24
|
-
return
|
|
25
|
-
html: HTML,
|
|
26
|
-
};
|
|
29
|
+
return source;
|
|
27
30
|
}
|
|
28
31
|
|
|
29
32
|
/**
|
|
@@ -44,7 +47,8 @@ class Video extends PureComponent {
|
|
|
44
47
|
}
|
|
45
48
|
|
|
46
49
|
render() {
|
|
47
|
-
const { width, height = '100%', style, poster } = this.props;
|
|
50
|
+
const { width, height = '100%', style, poster, headers } = this.props;
|
|
51
|
+
const webViewSource = getSource(this.sourceReader, poster, headers);
|
|
48
52
|
|
|
49
53
|
return (
|
|
50
54
|
<View style={style.container}>
|
|
@@ -52,7 +56,7 @@ class Video extends PureComponent {
|
|
|
52
56
|
allowsFullscreenVideo
|
|
53
57
|
mediaPlaybackRequiresUserAction={false}
|
|
54
58
|
style={{ width, height }}
|
|
55
|
-
source={
|
|
59
|
+
source={webViewSource}
|
|
56
60
|
scrollEnabled={false}
|
|
57
61
|
originWhitelist={['*']}
|
|
58
62
|
/>
|
|
@@ -63,6 +67,7 @@ class Video extends PureComponent {
|
|
|
63
67
|
|
|
64
68
|
Video.propTypes = {
|
|
65
69
|
style: PropTypes.object.isRequired,
|
|
70
|
+
headers: PropTypes.object,
|
|
66
71
|
height: PropTypes.number,
|
|
67
72
|
// `playerParams` currently only works for Youtube
|
|
68
73
|
playerParams: PropTypes.object,
|
|
@@ -75,6 +80,7 @@ Video.propTypes = {
|
|
|
75
80
|
|
|
76
81
|
Video.defaultProps = {
|
|
77
82
|
width: undefined,
|
|
83
|
+
headers: undefined,
|
|
78
84
|
height: undefined,
|
|
79
85
|
playerParams: { showinfo: 0 },
|
|
80
86
|
source: undefined,
|