Reputation: 8029
How can I obtain a current stream time of the stream object in javascript ?
navigator.mediaDevices.getUserMedia(constraints)
.then(function(stream) {
console.log("get stream time here")
})
Is there any possible way to get stream time ??
Upvotes: 1
Views: 2454
Reputation: 42480
You can get the playback time using currentTime (use fiddle to make getUserMedia work):
var wait = ms => new Promise(resolve => setTimeout(resolve, ms));
(async () => {
video.srcObject = await navigator.mediaDevices.getUserMedia({video: true});
while (true) {
console.log(video.currentTime);
await wait(100);
}
})().catch(e => console.log(e));
<video id="video" width="160" height="120" autoplay></video><br>
<div id="div"></div>
There is no inherent stream time without hooking it up to a sink and playing it. E.g. if you join a WebRTC video call late, there's no stream time that tells you when the meeting started.
Upvotes: 4