Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Unable to scale up a video from edge to edge

Little noob question and embarrassed to ask, but I am not sure what am I missing out but I am unable to resize a video in the UI to fill up horizontally edge to edge. There is some white space I want to be filled up with the video. I tried a lot of different things I found online but I can only resize it in height.

import SwiftUI
import AVKit

struct VideoMediaView: View {
    let videoURL: URL

    var body: some View {
        VideoPlayer(player: AVPlayer(url: videoURL))
            .aspectRatio(9 / 16, contentMode: .fill) // Ensures the video aspect ratio
            .frame(maxWidth: .infinity) // Makes the video fill the width of the screen
            .frame(height: 560) // Adjust the height if necessary
            .clipped() // Ensures the video content is clipped to its frame
    }
}

Not sure if anything in content view would cause the issue

struct ContentView: View { 
    var body: some View {
        TabView(selection: $selectedTab) {
            
            // Main media view
            NavigationView {
                ScrollView {
                    VStack {
                        // Display media when loaded
                        ForEach(viewModel.mediaData) { media in
                            MediaCardView(media: media)
                                .padding(.vertical, 8)
                                .padding(.horizontal, 16)
                        }
                    }
                }
                .onAppear {
                    viewModel.loadStoredData() // Load stored media when app starts
                }
            }
            .tabItem {
                Image(systemName: "photo.on.rectangle")
                Text("Media")
            }
            .tag(0)
            
            // Stats view for metrics
            StatsView() // The new view for metrics
                .tabItem {
                    Image(systemName: "chart.bar.fill")
                    Text("Stats")
                }
                .tag(1)
        }
    }
}

enter image description here

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

"fill the width of the screen" isn’t quite correct. It fills the rest of the "allocated" space.

The parent is taking up space, just remove the horizontal padding from the ContentView

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading