@@ -11,14 +11,32 @@ import SwiftUI
1111public struct ImageTestView : View {
1212 @Environment ( \. recorder) private var recorder
1313
14- let url = " https://sample-videos.com/img/Sample-jpg-image-5mb.jpg "
14+ @State private var currentImageIndex = 0
15+
16+ let imageUrls = [
17+ " https://sample-videos.com/img/Sample-jpg-image-5mb.jpg " ,
18+ " https://mogged-pullzone.b-cdn.net/people/8336bde2-3d36-41c3-a8ad-9c9d5413eff6.jpg?class=mobile " ,
19+ " https://mogged-pullzone.b-cdn.net/people/0880cf5d-10d1-49b2-b468-e84d19f5bdca.jpg " ,
20+ " https://mogged-pullzone.b-cdn.net/people/08c08ae7-732e-4966-917f-f94174daa024.jpg " ,
21+ " https://mogged-pullzone.b-cdn.net/people/0a4f6fc6-bc77-4b4a-9dfb-c690b5931625.jpg "
22+ ]
1523
1624 public init ( ) { }
1725 public var body : some View {
18- StreamingImage ( url: URL ( string: url) !)
19- . frame ( width: 500 , height: 900 )
26+ VStack {
27+ StreamingImage ( url: URL ( string: imageUrls [ currentImageIndex] ) !, scaleType: . fill)
28+ . frame ( width: 1080 , height: 1920 )
29+ . id ( currentImageIndex)
30+ }
31+ . onAppear ( perform: startTimer)
32+ }
2033
21- // VideoPlayer(player: AVPlayer(url: URL(string: "https://file-examples.com/storage/fed5266c9966708dcaeaea6/2017/04/file_example_MP4_480_1_5MG.mp4")!))
22- // .frame(height: 400)
34+ private func startTimer( ) {
35+ Task {
36+ while true {
37+ try await recorder? . controlledClock. clock. sleep ( for: . milliseconds( 1000 ) )
38+ currentImageIndex = ( currentImageIndex + 1 ) % imageUrls. count
39+ }
40+ }
2341 }
2442}
0 commit comments