ios – SwiftUI Video Participant not scaling

0
23
ios – SwiftUI Video Participant not scaling


I have been banging my head on the wall with this one for some time.

I’ve a videoPlayer, embedded in a zStack, embedded in a scrollview.

The videoPlayer stays at a static 9:16 facet ratio, at all times. After I import a video that’s extra panorama, say with a facet ratio of 16:9, utilizing “.scaleToFill” on the participant will scale the participant as much as a sq., however will not scale all the best way to fill the videoPlayer. The videoPlayer at all times stays a sq., and won’t scale previous the peak of the body. I would love for the video to scale all the best way up, in order that there aren’t any black bars on the highest and backside. See connected picture.

I’ve tried messing with the participant and the playerLayer video gravity, with no luck.

Thanks for the assistance.

My videoplayer:

var physique: some View {
    
    GeometryReader { geometry in
        
        let frameWidth: CGFloat = geometry.measurement.width
        let frameHeight: CGFloat = geometry.measurement.width * 16 / 9
        
        VideoPlayer(participant: VideoPlayerManagerVM.participant)
            .aspectRatio(16/9, contentMode: .fill)
            .scaledToFill()
            .ignoresSafeArea()
            .disabled(true)
            .body(width: frameWidth, top: frameHeight)
    }
}

My container

var physique: some View {
    ZStack {
        ZStack {
            videoPlayerEditor()
            ForEach(Array($clipArray.textOverlayArray.enumerated()), id: .aspect.id) { index, merchandise in
                VideoText(
                    id: merchandise.id,
                    index: .fixed(index),
                    textPosition: merchandise.textPosition.wrappedValue,
                    textRotation: merchandise.textRotation.wrappedValue,
                    textColor: merchandise.textColor.wrappedValue,
                    overlayText: merchandise.textual content.wrappedValue,
                    textFieldWidth: merchandise.textFieldWidth.wrappedValue,
                    tapAction: tapAction,
                    submitAction: submitAction,
                    deleteAction: deleteAction
                )
            }
        }
        
        ZStack {
            Rectangle()
                .fill(Colour("grey-2"))
            ProgressView()
        }
        .opacity(PostBasicsVM.isTimelineLoading ? 1 : 0)
    }
    .clipped()
    .cornerRadius(12)
    .overlay(RoundedRectangle(cornerRadius: 12)
        .inset(by: globalRef.strokeWidth)
        .stroke(Colour("grey-5"), lineWidth: globalRef.strokeWidth))
    
}

After which all of that is embedded in a scrollview.

current video scaling behavior

LEAVE A REPLY

Please enter your comment!
Please enter your name here