-
Notifications
You must be signed in to change notification settings - Fork 7
/
GVRVideo.js
58 lines (53 loc) · 1.56 KB
/
GVRVideo.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
51
52
53
54
55
56
57
58
/*
* @Author: tiero
* @Date: 2017-01-05 17:39:15
* @Last Modified by: tiero
* @Last Modified time: 2017-01-05 17:40:04
*/
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import { requireNativeComponent, ViewPropTypes } from 'react-native'
import resolveAssetSource from 'react-native/Libraries/Image/resolveAssetSource'
class VideoView extends Component {
render () {
const source = resolveAssetSource(this.props.source) || {}
let uri = source.uri || ''
if (uri && uri.match(/^\//)) {
uri = `file://${uri}`
}
const isNetwork = !!(uri && uri.match(/^https?:/))
const isAsset = !!(uri && uri.match(/^(assets-library|content|ms-appx|ms-appdata):/))
return <RCTViedoView
{...this.props}
src={{
uri,
isNetwork,
isAsset,
type: source.type || ''
}}
/>
}
}
VideoView.propTypes = {
...ViewPropTypes,
src: PropTypes.object,
source: PropTypes.oneOfType([
PropTypes.shape({
uri: PropTypes.string,
type: PropTypes.string
}),
// Opaque type returned by require('./video.mp4')
PropTypes.number
]),
videoType: PropTypes.string,
volume: PropTypes.number,
displayMode: PropTypes.string,
enableFullscreenButton: PropTypes.bool,
enableCardboardButton: PropTypes.bool,
enableInfoButton: PropTypes.bool,
enableTouchTracking: PropTypes.bool,
hidesTransitionView: PropTypes.bool
}
// requireNativeComponent automatically resolves this to "VideoManager"
var RCTViedoView = requireNativeComponent('VrVideo', VideoView)
export default VideoView