youtube / youtube-ios-player-helper

Lightweight helper library that allows iOS developers to add inline playback of YouTube videos through a WebView
Other
1.64k stars 680 forks source link

Is there a way to override becomeFirstResponder() for YTPlayerView? #412

Open ledzeppelin opened 3 years ago

ledzeppelin commented 3 years ago

Thanks for all the work on this library 🎉

When people use my app to interact with inline youtube embeds (ex. pausing, getting the share link, etc...) my inputAccessoryView https://developer.apple.com/documentation/uikit/uiresponder/1621119-inputaccessoryview disappears. I've been able to solve this issue for WKWebView video embeds from websites other than youtube, like twitch, by using

class TwitchWKWebView: WKWebView {
    override func becomeFirstResponder() -> Bool { return false }
}

I'm not sure if subclassing YTPlayerView is the best option here but when I tried, I got the error

Received error rendering template: Error Domain=NSCocoaErrorDomain Code=258 "The file name is invalid."

Is there a practical way I can prevent my inputAccessoryView from disappearing when people interact with inline youtube embeds?