SvenTiigi / YouTubePlayerKit

A Swift Package to easily play YouTube videos 📺
https://sventiigi.github.io/YouTubePlayerKit/
MIT License
683 stars 61 forks source link

Feature/Add ability to pass a String Variable to represent a URL when creating the YouTubePlayer constant #55

Closed gturney closed 1 year ago

gturney commented 1 year ago

From all the examples I have seen related to the library the only way to set a source ID or URL is by hard coding it into the swift program. It would be nice to be able to have the ability to enter a URL via a text field or something and then use that when creating a YouTubePlayerView. Here is a basic example of how I would like to create a YouTubePlayerView by passing it a variable instead of hard coding the URL into the app:

// // ContentView.swift // YouTubePlayer-Example

import SwiftUI import YouTubePlayerKit

// Would ultimately like to get the string from a TextField input. var MyURL: String = "https://youtube.com/watch?v=psL_5RIBqnY"

struct ContentView: View { var body: some View { VStack { //YouTubePlayerView("https://youtube.com/watch?v=psL_5RIBqnY") YouTubePlayerView(MyURL) } .padding() } }

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