Hi there !! How are you!!! I have one for you
a) ¿When put variables in body, and when outside ?
- In this case let url is recommended put together the others variables?
b) if I write var video: Video. and call the Struct PlayerView from ContentView why this variable is a parameter of my struct PlayerView, but not videoRatio, for example.?
c) ¿My struct PlayerView can be much better a class? If this class or struct consume more memory? Depend of size of videos.
Thanks a lot.!
import SwiftUI
import AVKit
struct PlayerView: View {
var video:Video
let videoRatio: CGFloat = 1080 / 1920
var body: some View {
let url = URL(string: video.url)
GeometryReader { geo in
VStack {
Text(video.title)
.font(.title)
.bold()
if url != nil {
VideoPlayer(player: AVPlayer(url: url!))
.frame(height: geo.size.width * videoRatio)
}
Spacer()
}
}
}
}