-
Notifications
You must be signed in to change notification settings - Fork 13
/
VideoDetails.js
50 lines (44 loc) · 1.29 KB
/
VideoDetails.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import React from 'react'
import { connect } from 'react-redux'
import Collapsible from '../components/Collapsible'
import KeyValue from '../components/KeyValue'
const stringifiers = {
TimeRanges: obj =>
'TimeRanges[' +
(obj.data.length > 0
? ' ' +
obj.data
.map(({ start, end }) => '(' + start + ', ' + end + ')')
.join(', ') +
' '
: '0') +
']',
TextTrackList: obj => `TextTrackList[${obj.data.length}]`
}
const stringifyProperties = properties => {
const out = {}
for (const name of Object.keys(properties)) {
const obj = properties[name]
out[name] =
obj != null && obj.$type != null && stringifiers[obj.$type] != null
? stringifiers[obj.$type](obj)
: '' + obj
}
return out
}
const VideoDetails = React.memo(({ eventCounts, properties }) => (
<div className="video-details">
<Collapsible trigger="Video Events">
<div className="events">
<KeyValue data={eventCounts} />
</div>
</Collapsible>
<Collapsible trigger="Video Element Properties">
<div className="properties">
<KeyValue data={stringifyProperties(properties)} />
</div>
</Collapsible>
</div>
))
const mapStateToProps = ({ video }) => video
export default connect(mapStateToProps)(VideoDetails)