atw
atw

Reputation: 5840

How to I retrieve call duration when someone leaves a call?

How to I retrieve call duration when someone leaves a call?

I am trying to use getStats() but I am only being returned a state value.

console.log("this.room.getStats() ", this.room.getStats());

returns:

this.room.getStats()  
Promise { <state>: "pending" }

Upvotes: 0

Views: 77

Answers (1)

lizziepika
lizziepika

Reputation: 3300

Twilio developer evangelist here.

Maybe something like

const stats = await this.room.getStats();
const remoteTrackStats = kind === 'audio'
    ? stats[0].remoteAudioTrackStats[0]
    : stats[0].remoteVideoTrackStats[0]
const bytesReceived = remoteTrackStats.bytesReceived;
const timestamp = remoteTrackStats.timestamp;

Let me know if this helps at all!

Upvotes: 1

Related Questions