mirror of
https://github.com/yattee/yattee.git
synced 2026-05-13 10:55:03 +00:00
Route YouTube links tapped in descriptions through in-app playback
Description links to YouTube videos, channels, playlists, and external video URLs now open in Yattee instead of Safari. When a video is already playing, tapping a video link surfaces the existing QueueActionSheet (Play Now / Play Next / Add to Queue) — the sheet is hosted both at the app root and inside ExpandedPlayerSheet so it appears above whichever layer is on screen.
This commit is contained in:
@@ -88,7 +88,9 @@ enum DescriptionText {
|
||||
// MARK: - OpenURL Action for Seeking
|
||||
|
||||
extension View {
|
||||
/// Adds a URL handler that intercepts timestamp links and seeks the player.
|
||||
/// Adds a URL handler that intercepts timestamp links (seeks the player) and
|
||||
/// known content URLs — YouTube/PeerTube video/channel/playlist links and external
|
||||
/// video URLs — so they open in-app instead of the browser.
|
||||
func handleTimestampLinks(using playerService: PlayerService?) -> some View {
|
||||
self.environment(\.openURL, OpenURLAction { url in
|
||||
if let seconds = DescriptionText.seekSeconds(from: url) {
|
||||
@@ -97,6 +99,12 @@ extension View {
|
||||
}
|
||||
return .handled
|
||||
}
|
||||
|
||||
if URLRouter().route(url) != nil {
|
||||
NotificationCenter.default.post(name: .openDescriptionLink, object: url)
|
||||
return .handled
|
||||
}
|
||||
|
||||
return .systemAction
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user