Reputation: 1472
I use Twilio API to create video chat between two users. First user video pic must be a smaller circle on top of the second user pic.
Second user uses USB camera and I get "horizontal rectangle" video, so I need move circle with my video on this rectangle:
I try to get CMVideoDimensions:
extension VideoChatViewController: TVIParticipantDelegate {
func participant(_ participant: TVIParticipant, addedVideoTrack videoTrack: TVIVideoTrack) {
logMessage(messageText: "Participant \(participant.identity) added video track")
if (self.participant == participant) {
videoTrack.attach(self.remoteView)
let dimensions = videoTrack.videoDimensions
let height = dimensions.height
let width = dimensions.width
print ("\(height) ; \(width)")
}
}
}
But I got height = 0 and width = 0. How can I get size of the video track ?
Upvotes: 0
Views: 659
Reputation: 73065
Twilio developer evangelist here.
I've spoken with the Video team and I'm told that videoDimensions
is going to be deprecated from the TVIVideoTrack
class in upcoming betas as it wasn't working particularly well, as you've discovered.
The better way to get videoDimensions
is from a TVIVideoViewRenderer
. Here's a snippet for adding a video view renderer to a video track:
let renderer = TVIVideoViewRenderer.init(delegate: self)
videoTrack.addRenderer(renderer)
renderer.view.frame = view.bounds
renderer.view.contentMode = .scaleAspectFill
view.addSubview(renderer.view)
Let me know if this helps.
Upvotes: 1