Page 1 of 1

MobileVLCkit and scale

Posted: 17 Apr 2024 19:55
by Cramac
Hello.
how to stretch a video image to the entire container?
I did this on Android

Code: Select all

mediaPlayer?.videoScale = MediaPlayer.ScaleType.SURFACE_FILL
how to do it on ios?

Code: Select all

struct VLCPlayerView: UIViewRepresentable { @Binding var mediaUrl: URL? @State var mediaPlayer = VLCMediaPlayer() typealias UIViewType = UIView func makeUIView(context: Context) -> UIView { let uiView = UIView() mediaPlayer.drawable = uiView return uiView } func updateUIView(_ uiView: UIView, context: Context) { if let url = mediaUrl { mediaPlayer.media = VLCMedia(url: url) mediaPlayer.media?.addOption(":rtsp-tcp") mediaPlayer.media?.addOption(":avcodec-hw=any") mediaPlayer.media?.addOption(":no-audio") mediaPlayer.play() } else { mediaPlayer.stop() } } } struct DomofonInfoView: View { @State var mediaURL: URL? = URL(string: "https://streams.videolan.org/streams/mp4/Mr_MrsSmith-h264_aac.mp4") @State private var isRefreshing = false var body: some View { ZStack{ VStack{ Color(hex: "#f5f6ff") } VStack { ZStack{ VStack{ Color.gray } VStack{ VLCPlayerView(mediaUrl: $mediaURL) .frame(maxWidth: .infinity, maxHeight: .infinity) .onAppear { ... } } } .frame(width: .infinity, height: 400) // Укажите размер видео Spacer() } VStack{ Spacer() VStack{ } .frame(height: 600) } VStack{ Spacer() MenuFooterView(mediaUrl: $mediaURL) .padding(.bottom, 0.0) } } .edgesIgnoringSafeArea(.all) .frame(maxWidth: .infinity, maxHeight: .infinity) } }