如何在录制时收听timeupdate事件?

时间:2017-02-22 17:55:37

标签: javascript webrtc video.js video-recording

是否可以在录制时收听timeupdate事件并获取当前时间? 我使用带有videojs-record插件的videojs来录制视频和音频。 我尝试在videojs的播放器对象上听timeupdate,但没有结果 - 它没有触发

1 个答案:

答案 0 :(得分:0)

看看https://github.com/collab-project/videojs-record#timestamps

使用timeSlice选项基本启用事件:

record: {
    audio: false,
    video: true,
    maxLength: 5,
    debug: true,
    // fire the timestamp event every 2 seconds
    timeSlice: 2000
}

并监听时间戳事件。例如:

// monitor stream data during recording
player.on('timestamp', function() {
    // timestamps
    console.log('current timestamp: ', player.currentTimestamp);
    console.log('all timestamps: ', player.allTimestamps);

    // stream data
    console.log('array of blobs: ', player.recordedData);
    // or construct a single blob:
    // var blob = new Blob(blobs, {
    //     type: 'video/webm'
    // });
});