diff --git a/README.md b/README.md index 74d3636..3d3d796 100644 --- a/README.md +++ b/README.md @@ -89,6 +89,7 @@ When submitting an app to the App Store which includes the `YouTubePlayerKit`, p - Audio background playback is not supported as it violates the YouTube Terms of Service. - Simultaneous playback of multiple YouTube players is not supported. +- Controlling playback of [360° videos](https://developers.google.com/youtube/iframe_api_reference#Spherical_Video_Controls) is not supported on iOS and macOS. ## Usage @@ -410,23 +411,6 @@ try await youTubePlayer.getPlaylist() try await youTubePlayer.getPlaylistIndex() ``` -#### Controlling playback of 360° videos - -```swift -// Retrieves properties that describe the viewer's current perspective -try await youTubePlayer.get360DegreePerspective() - -// Sets the video orientation for playback of a 360° video -youTubePlayer.set( - perspective360Degree: .init( - yaw: 50, - pitch: 20, - roll: 60, - fov: 10 - ) -) -``` - #### Setting the playback rate ```swift diff --git a/Sources/API/YouTubePlayer+360DegreePerspectiveAPI.swift b/Sources/API/YouTubePlayer+360DegreePerspectiveAPI.swift deleted file mode 100644 index 402619b..0000000 --- a/Sources/API/YouTubePlayer+360DegreePerspectiveAPI.swift +++ /dev/null @@ -1,53 +0,0 @@ -import Foundation - -/// The YouTubePlayer 360 Degree Perspective API -/// - Read more: https://developers.google.com/youtube/iframe_api_reference#Spherical_Video_Controls -public extension YouTubePlayer { - - /// Retrieves properties that describe the viewer's current perspective - /// - Parameter completion: The completion closure - func get360DegreePerspective( - completion: @escaping (Result) -> Void - ) { - self.webView.evaluate( - javaScript: .player(function: "getSphericalProperties"), - converter: .typeCast( - to: [String: Any].self - ) - .decode(), - completion: completion - ) - } - - #if compiler(>=5.5) && canImport(_Concurrency) - /// Retrieves properties that describe the viewer's current perspective - func get360DegreePerspective() async throws -> Perspective360Degree { - try await withCheckedThrowingContinuation { continuation in - self.get360DegreePerspective(completion: continuation.resume) - } - } - #endif - - /// Sets the video orientation for playback of a 360° video - /// - Parameter perspective360Degree: The Perspective360Degree - func set( - perspective360Degree: Perspective360Degree - ) { - // Verify YouTubePlayer Perspective360Degree can be decoded - guard let jsonData = try? JSONEncoder().encode(perspective360Degree) else { - // Otherwise return out of function - return - } - // Initialize JSON string from data - let jsonString = String(decoding: jsonData, as: UTF8.self) - // Evaluate JavaScript - self.webView.evaluate( - javaScript: .player( - function: "setSphericalProperties", - parameters: jsonString - ) - .embedInAnonymousFunction() - ) - } - -} diff --git a/Sources/Models/YouTubePlayer+Perspective360Degree.swift b/Sources/Models/YouTubePlayer+Perspective360Degree.swift deleted file mode 100644 index 9796aee..0000000 --- a/Sources/Models/YouTubePlayer+Perspective360Degree.swift +++ /dev/null @@ -1,49 +0,0 @@ -import Foundation - -// MARK: - YouTubePlayer+Perspective360Degree - -public extension YouTubePlayer { - - /// The 360° YouTube player video playback perspective configuration - struct Perspective360Degree: Codable, Hashable { - - // MARK: Properties - - /// Represents the horizontal angle of the view in degrees, - /// which reflects the extent to which the user turns the view to face further left or right - public let yaw: Int? - - /// Represents the vertical angle of the view in degrees, - /// which reflects the extent to which the user adjusts the view to look up or down - public let pitch: Int? - - /// Represents the clockwise or counterclockwise rotational angle of the view in degrees - public let roll: Int? - - /// Represents the field-of-view of the view in degrees as measured along the longer edge of the viewport - public let fov: Int? - - /// A boolean value that indicates whether the IFrame embed - /// should respond to events that signal changes in a supported device's orientation - public let enableOrientationSensor: Bool? - - // MARK: Initializer - - /// Creates a new instance of `YouTubePlayer.Perspective360Degree` - public init( - yaw: Int? = nil, - pitch: Int? = nil, - roll: Int? = nil, - fov: Int? = nil, - enableOrientationSensor: Bool? = nil - ) { - self.yaw = yaw.flatMap { max(0, min($0, 360)) } - self.pitch = pitch.flatMap { max(-90, min($0, 90)) } - self.roll = roll.flatMap { max(-180, min($0, 180)) } - self.fov = fov.flatMap { max(30, min($0, 120)) } - self.enableOrientationSensor = enableOrientationSensor - } - - } - -}