Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 53 additions & 30 deletions src/CCapture.js
Original file line number Diff line number Diff line change
Expand Up @@ -707,22 +707,28 @@ function CCapture( settings ) {
return _performanceTime;
};

function hookCurrentTime() { 
if( !this._hooked ) {
this._hooked = true;
this._hookedTime = this.currentTime || 0;
this.pause();
media.push( this );
}
return this._hookedTime + _settings.startTime;
};

try {
Object.defineProperty( HTMLVideoElement.prototype, 'currentTime', { get: hookCurrentTime } )
Object.defineProperty( HTMLAudioElement.prototype, 'currentTime', { get: hookCurrentTime } )
} catch (err) {
_log(err);
}
if (_settings.syncVideo) {
_settings.syncVideo.pause();
_settings.syncVideo.addEventListener('seeked', _callCallbacks);
}
else {
function hookCurrentTime() { 
if( !this._hooked ) {
this._hooked = true;
this._hookedTime = this.currentTime || 0;
this.pause();
media.push( this );
}
return this._hookedTime + _settings.startTime;
};

try {
Object.defineProperty( HTMLVideoElement.prototype, 'currentTime', { get: hookCurrentTime } )
Object.defineProperty( HTMLAudioElement.prototype, 'currentTime', { get: hookCurrentTime } )
} catch (err) {
_log(err);
}
}

}

Expand Down Expand Up @@ -757,6 +763,12 @@ function CCapture( settings ) {
window.Date.prototype.getTime = _oldGetTime;
window.Date.now = _oldNow;
window.performance.now = _oldPerformanceNow;

if (_settings.syncVideo) {
_settings.syncVideo.removeEventListener('seeked', _callCallbacks);
_settings.syncVideo.play();
_callCallbacks();
}
}

function _updateTime() {
Expand Down Expand Up @@ -847,21 +859,8 @@ function CCapture( settings ) {
}

}

function _process() {

var step = 1000 / _settings.framerate;
var dt = ( _frameCount + _intermediateFrameCount / _settings.motionBlurFrames ) * step;

_time = _startTime + dt;
_performanceTime = _performanceStartTime + dt;

media.forEach( function( v ) {
v._hookedTime = dt / 1000;
} );

_updateTime();
_log( 'Frame: ' + _frameCount + ' ' + _intermediateFrameCount );
function _callCallbacks() {

for( var j = 0; j < _timeouts.length; j++ ) {
if( _time >= _timeouts[ j ].triggerTime ) {
Expand All @@ -886,6 +885,30 @@ function CCapture( settings ) {
} );
_requestAnimationFrameCallbacks = [];

}

function _process() {

var step = 1000 / _settings.framerate;
var dt = ( _frameCount + _intermediateFrameCount / _settings.motionBlurFrames ) * step;

_time = _startTime + dt;
_performanceTime = _performanceStartTime + dt;

media.forEach( function( v ) {
v._hookedTime = dt / 1000;
} );

_updateTime();
_log( 'Frame: ' + _frameCount + ' ' + _intermediateFrameCount );

if (_settings.syncVideo) {
_settings.syncVideo.currentTime += step / 1000;
}
else {
_callCallbacks();
}

}

function _save( callback ) {
Expand Down