1

I'm trying to use SwiftUI to create an album in which you can scroll through the video. Faced the problem when returning to the previous video the player control panel shows that the video is still playing but the changes are not displayed. Why?


import SwiftUI
import AVKit

struct ContentView: View {
    @State var players: [AVPlayer] = [
        AVPlayer(url: URL(string: "https://test-videos.co.uk/vids/bigbuckbunny/mp4/h264/1080/Big_Buck_Bunny_1080_10s_1MB.mp4")!),
        AVPlayer(url: URL(string: "https://edisciplinas.usp.br/pluginfile.php/5196097/mod_resource/content/1/Teste.mp4")!),

    ]


    var body: some View {
        TabView {
            ForEach(players, id: \.self) { player in
                VStack {
                    VideoPlayer(player: player)
                        .frame(width: 400, height: 300, alignment: .center)
                        .clipped()
                }.tag(player)

            }
        }
            .tabViewStyle(.page(indexDisplayMode: .never))
            .indexViewStyle(.page(backgroundDisplayMode: .interactive))

    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}

0 Answers0