Twilio-video.js: How to get the dimensions of a videoTrack?

Created on 31 Dec 2018  路  2Comments  路  Source: twilio/twilio-video.js

  • [ ] I have verified that the issue occurs with the latest twilio-video.js release and is not marked as a known issue in the CHANGELOG.md.
  • [x] I reviewed the Common Issues and open GitHub issues and verified that this report represents a potentially new issue.
  • [ ] I verified that the Quickstart application works in my environment.
  • [ ] I am not sharing any Personally Identifiable Information (PII)
    or sensitive account information (API keys, credentials, etc.) when reporting this issue.

Code to reproduce the issue:

publication.on('subscribed', track => {
if (track.kind === 'video') {
const width = track.dimensions.width;
console.log(track.dimensions);
}
container.appendChild(track.attach());
console.log(LocalParticipant subscribed to a RemoteTrack: ${track});
});

Expected behavior:
track.dimensions should return the width and height of th eincoming videoTrack
{
width:240,
height: 320,
}

Actual behavior:
{
width:null,
height: null
}

TODO

Software versions:

  • [x] Browser(s): Chrome: 69
  • [x] Operating System: ubuntu 16.04
  • [x] twilio-video.js: 2.0.0-beta4
  • [x] Third-party libraries React,
question

Most helpful comment

Hi @lightbringer2994 ,

Thanks for writing in with your question. The dimensions of a VideoTrack are only available once it starts receiving video frames. So, you can wait for the "started" event to fire before accessing the dimensions like so:

publication.on('subscribed', track => {
  if (track.kind === 'video') {
    track.once('started', () => console.log(track.dimensions));
  }
});

Please let me know if this works for you.

Thanks,

Manjesh Malavalli
JSDK Team

All 2 comments

Hi @lightbringer2994 ,

Thanks for writing in with your question. The dimensions of a VideoTrack are only available once it starts receiving video frames. So, you can wait for the "started" event to fire before accessing the dimensions like so:

publication.on('subscribed', track => {
  if (track.kind === 'video') {
    track.once('started', () => console.log(track.dimensions));
  }
});

Please let me know if this works for you.

Thanks,

Manjesh Malavalli
JSDK Team

Hi @lightbringer2994 ,

I'm going to close this issue. Please feel free to open another one if you have any other questions or issues.

Thanks,

Manjesh Malavalli
JSDK Team

Was this page helpful?
0 / 5 - 0 ratings

Related issues

HandsomeMedia picture HandsomeMedia  路  3Comments

tapannathvani picture tapannathvani  路  5Comments

julien-l picture julien-l  路  4Comments

vsrboth picture vsrboth  路  3Comments

himichaelroberts picture himichaelroberts  路  3Comments