Skip to content

Commit 38127ad

Browse files
committed
use context.wrapNativeCallback to wrap femto video player callbacks - no missing updates
1 parent 29ce393 commit 38127ad

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

platform/pure.femto/video.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ exports.createPlayer = function(ui) {
22
log('video.createPlayer')
33

44
var player = new fd.VideoPlayer()
5+
var context = ui._context
56

67
var resetState = function() {
78
ui.ready = false
@@ -11,7 +12,7 @@ exports.createPlayer = function(ui) {
1112
ui.stalled = false
1213
}
1314

14-
player.on('stateChanged', function(state) {
15+
player.on('stateChanged', context.wrapNativeCallback(function(state) {
1516
log('VideoPlayer: stateChanged ' + state)
1617
switch(state) {
1718
case 1:
@@ -36,35 +37,34 @@ exports.createPlayer = function(ui) {
3637
default:
3738
log("VideoPlayer: unhandled state", typeof state, state)
3839
}
39-
})
40+
}))
4041

41-
player.on('seeked', function() {
42+
player.on('seeked', context.wrapNativeCallback(function() {
4243
ui.waiting = false
4344
ui.seeking = false
44-
})
45+
}))
4546

46-
player.on('error', function(err) {
47+
player.on('error', context.wrapNativeCallback(function(err) {
4748
log('VideoPlayer: error: ', err)
4849
resetState(ui);
4950
ui.error({ message: err })
50-
})
51+
}))
5152

52-
player.on('pause', function(isPaused) {
53+
player.on('pause', context.wrapNativeCallback(function(isPaused) {
5354
ui.paused = isPaused
5455
log('VideoPlayer: paused: ', isPaused)
55-
})
56+
}))
5657

57-
player.on('timeupdate', function(position) {
58+
player.on('timeupdate', context.wrapNativeCallback(function(position) {
5859
ui.waiting = false
5960
ui.stalled = false
6061
if (!ui.seeking)
6162
ui.progress = position;
62-
}.bind(ui))
63+
}))
6364

64-
player.on('durationchange', function(duration) {
65+
player.on('durationchange', context.wrapNativeCallback(function(duration) {
6566
ui.duration = duration
66-
}.bind(ui))
67-
67+
}))
6868

6969
return player
7070
}

0 commit comments

Comments
 (0)