forked from ghondar/react-native-giraffe-player
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
35 lines (31 loc) · 1.03 KB
/
index.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
var { DeviceEventEmitter, NativeModules } = require('react-native')
var { GPlayerAndroid } = NativeModules
var GIRAFFE_PLAYER_EVENTS = {
onBufferingStart : 'onBufferingStart',
onBufferingEnd : 'onBufferingEnd',
onNetworkBandwidth : 'onNetworkBandwidth',
onRenderingStart : 'onRenderingStart',
onControlPanelVisibilityChange: 'onRenderingStart',
onComplete : 'onComplete',
onError : 'onError'
}
var _GiraffePlayerHandlers = {}
var GPlayer = {
addEventListener : function(type, handler) {
_GiraffePlayerHandlers[ handler ] = DeviceEventEmitter.addListener(
GIRAFFE_PLAYER_EVENTS[ type ],
(giraffePlayerData) => {
handler(giraffePlayerData)
}
)
},
removeEventListener: function(type, handler) {
if (!_GiraffePlayerHandlers[ handler ]) {
return
}
_GiraffePlayerHandlers[ handler ].remove()
_GiraffePlayerHandlers[ handler ] = null
},
...GPlayerAndroid
}
module.exports = GPlayer