You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you wish to change the video at runtime simply update the `source` of a `YouTubePlayer`.
121
+
122
+
```swift
123
+
youTubePlayer.source= .video(id: "0TD96VTf0Xs")
124
+
```
125
+
126
+
Additionally, you can update the `configuration` of a `YouTubePlayer` to update the current configuration.
127
+
128
+
```swift
129
+
youTubePlayer.configuration= .init(
130
+
isUserInteractionEnabled: true,
131
+
autPlay: true
132
+
)
133
+
```
134
+
> Note: Updating the `YouTubePlayer.Configuration` will result in a reload of the YouTubePlayer.
135
+
136
+
Since `YouTubePlayer` is conform to the [`ObservableObject`](https://developer.apple.com/documentation/combine/observableobject) protocol you can listen for changes whenever the `source` or `configuration` of a `YouTubePlayer` gets updated.
137
+
138
+
```swift
139
+
youTubePlayer
140
+
.objectWillChange
141
+
.sink { }
142
+
```
143
+
131
144
## YouTubePlayer
132
145
133
146
A `YouTubePlayer` is the central object which needs to be passed to every YouTubePlayerView or YouTubePlayerViewController in order to play a certain YouTube video and interact with the underlying YouTube iFrame API.
0 commit comments