Hello.
how to stretch a video image to the entire container?
I did this on Android
Code:
mediaPlayer?.videoScale = MediaPlayer.ScaleType.SURFACE_FILL
how to do it on ios?
Code:
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) } }
Statistics: Posted by Cramac — 17 Apr 2024 19:55