MobileVLCKit: video aspect ratio not applied correctly the first time (videoAspectRatio, scaleFactor) #8048
Unanswered
Badar-2002
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm working on a Capacitor plugin for iOS that uses MobileVLCKit to play an RTSP stream inside a UIView. The stream loads fine, and I manually adjust the aspect ratio using
videoAspectRatio
andscaleFactor = 0.0
after playback starts.The problem is that the first time I open the stream (after launching the app), the aspect ratio is not applied. The video stretches incorrectly (typically fills the container, ignoring its native aspect). From the second time on, the video usually adjusts correctly.
I'm detecting the
.playing
state using themediaPlayerStateChanged(_:)
delegate method and apply the aspect ratio 0.5 seconds after it enters.playing
. But this doesn't always fire in time on the first run, or the adjustment is ignored.Things I already tried:
player.scaleFactor = 0.0
andplayer.videoAspectRatio = nil
before calling.play()
videoAspectRatio
manually inmediaPlayerStateChanged
DispatchQueue.main.asyncAfter(...)
drawable
view is fully laid outautoresizingMask
andclipsToBounds
correctlyMy question:
How can I reliably apply videoAspectRatio so the video never stretches — not only on the first stream playback, but every single time the stream is started?
Is there a better hook or event than .playing to ensure this adjustment always works? Could this be a race condition or timing issue inside VLCMediaPlayer?
Any ideas or best practices?
Environment:
Photos:
Code:
Beta Was this translation helpful? Give feedback.
All reactions