Big spaces above and below video player

Viewed 107

I have added a video player to play stream video. And now there are some spaces at the top and bottom.

import SwiftUI
import AVKit

struct LivePageView: View {
    var body: some View {
        VStack {
            Text("Top")
            VideoPlayer(player: AVPlayer(url:  URL(string: "https://stream.site.com:1500/hls/stream.m3u8")!))
                .frame(idealHeight: 300)
                .edgesIgnoringSafeArea(.all)
            Text("Bottom")
        }
        .background(Color.blue)
        .navigationBarHidden(true)
        .navigationBarBackButtonHidden(true)
    }
}

How to delete this spaces?

1 Answers

I have find the solution of my problem. The problem was in NavigationView.

import SwiftUI

struct ContentView: View {
    var body: some View {
        NavigationView {
            VStack {
                LivePageView()
            }
            .navigationBarHidden(true)
            .navigationBarBackButtonHidden(true)
        }
    }
}

Here is example of correct code:

import SwiftUI

struct ContentView: View {
    var body: some View {
        VStack {
            LivePageView()
        }
    }
}

Player work's fine.

Related