Implement SponsorBlock API

This commit is contained in:
Arkadiusz Fal
2021-06-18 00:43:29 +02:00
parent 9d7abda63f
commit d551dee426
9 changed files with 190 additions and 29 deletions

View File

@@ -117,6 +117,14 @@ struct PlayerViewController: UIViewControllerRepresentable {
#if os(tvOS)
controller.transportBarCustomMenuItems = items
#endif
if let skip = skipSegmentAction {
if controller.contextualActions.isEmpty {
controller.contextualActions = [skip]
}
} else {
controller.contextualActions = []
}
}
fileprivate var streamingQualityMenu: UIMenu {
@@ -149,4 +157,16 @@ struct PlayerViewController: UIViewControllerRepresentable {
}
}
}
private var skipSegmentAction: UIAction? {
if state.currentSegment == nil {
return nil
}
return UIAction(title: "Skip \(state.currentSegment!.title())") { _ in
DispatchQueue.main.async {
state.player.seek(to: state.currentSegment!.skipTo)
}
}
}
}