diff --git a/NineAnimator.xcodeproj/project.pbxproj b/NineAnimator.xcodeproj/project.pbxproj index a4652eb9..ef5456f1 100644 --- a/NineAnimator.xcodeproj/project.pbxproj +++ b/NineAnimator.xcodeproj/project.pbxproj @@ -216,6 +216,7 @@ 2CE2FDF4265070AB00319466 /* NineAnimatorNativeListServices in Embed Frameworks */ = {isa = PBXBuildFile; productRef = 2CA0D98426502C03009EFF76 /* NineAnimatorNativeListServices */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; 2CE2FDF5265070AD00319466 /* NineAnimatorNativeParsers in Embed Frameworks */ = {isa = PBXBuildFile; productRef = 2CA0D980264CC192009EFF76 /* NineAnimatorNativeParsers */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; 2CE2FDF6265070AE00319466 /* NineAnimatorNativeSources in Embed Frameworks */ = {isa = PBXBuildFile; productRef = 2CA0D982264CC192009EFF76 /* NineAnimatorNativeSources */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; + 2CE3CB3E2B2916AC00DC40F6 /* NativePlayerController+Controller.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CE3CB3D2B2916AC00DC40F6 /* NativePlayerController+Controller.swift */; }; 2CE5B8E0225ECAC200A2CF89 /* SetupFinishingViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CE5B8DF225ECAC200A2CF89 /* SetupFinishingViewController.swift */; }; 2CEA0BE821F66D49007EECC4 /* Continuity.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CEA0BE721F66D49007EECC4 /* Continuity.swift */; }; 2CEBE8FE22074401006A64CC /* UISearchBar+Themable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CEBE8FD22074401006A64CC /* UISearchBar+Themable.swift */; }; @@ -507,6 +508,7 @@ 2CE18B0D2374996800771A16 /* LibraryRecentlyWatchedCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LibraryRecentlyWatchedCell.swift; sourceTree = ""; }; 2CE18B0F2374C7ED00771A16 /* LibraryTipGenericCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LibraryTipGenericCell.swift; sourceTree = ""; }; 2CE18B112374D69200771A16 /* LibrarySceneController+Tips.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "LibrarySceneController+Tips.swift"; sourceTree = ""; }; + 2CE3CB3D2B2916AC00DC40F6 /* NativePlayerController+Controller.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NativePlayerController+Controller.swift"; sourceTree = ""; }; 2CE5B8DF225ECAC200A2CF89 /* SetupFinishingViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SetupFinishingViewController.swift; sourceTree = ""; }; 2CE9FF8525699EB900D364E0 /* backups.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = backups.md; sourceTree = ""; }; 2CE9FF862569A60400D364E0 /* information_ipad.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = information_ipad.png; sourceTree = ""; }; @@ -1124,6 +1126,7 @@ 2CAA70D221CFF42A00F0D082 /* NativePlayerController.swift */, 2C12EDE421BDE9DB0064D2BD /* GoogleCastMediaPlaybackViewController.swift */, 2C12EDE621BDFFFF0064D2BD /* CastController.swift */, + 2CE3CB3D2B2916AC00DC40F6 /* NativePlayerController+Controller.swift */, ); path = "Player Scene"; sourceTree = ""; @@ -1718,6 +1721,7 @@ 2C12EDE521BDE9DB0064D2BD /* GoogleCastMediaPlaybackViewController.swift in Sources */, 2CD1A64E222EE32000121320 /* CollectionsTableViewCell.swift in Sources */, 2C0DA2E0238B10E4002C6447 /* PortionBarView.swift in Sources */, + 2CE3CB3E2B2916AC00DC40F6 /* NativePlayerController+Controller.swift in Sources */, 2C4ABC5421B5881E009B4D47 /* AppDelegate.swift in Sources */, 2C8F6E8222061CE30047798B /* OfflineAnimeTableViewCell.swift in Sources */, 2C64FAB8236889F500AD0F45 /* UIView+StyleAttributes.swift in Sources */, diff --git a/NineAnimator/Base.lproj/Settings.storyboard b/NineAnimator/Base.lproj/Settings.storyboard index 327d814c..df07efbc 100644 --- a/NineAnimator/Base.lproj/Settings.storyboard +++ b/NineAnimator/Base.lproj/Settings.storyboard @@ -1,9 +1,9 @@ - + - + @@ -20,14 +20,14 @@ - + - + - + - + diff --git a/NineAnimator/Controllers/Player Scene/NativePlayerController+Controller.swift b/NineAnimator/Controllers/Player Scene/NativePlayerController+Controller.swift new file mode 100644 index 00000000..d2ffa43b --- /dev/null +++ b/NineAnimator/Controllers/Player Scene/NativePlayerController+Controller.swift @@ -0,0 +1,34 @@ +// +// This file is part of the NineAnimator project. +// +// Copyright © 2018-2023 Marcus Zhou. All rights reserved. +// +// NineAnimator is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// NineAnimator is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with NineAnimator. If not, see . +// + +import AVKit +import NineAnimatorCommon + +extension NativePlayerController { + internal class NativePlayerViewController: AVPlayerViewController { + /// Return custom interface orientations based on the `forceLandscapePlayer` preference + override var supportedInterfaceOrientations: UIInterfaceOrientationMask { + if NineAnimator.default.user.forceLandscapePlayer { + return .landscape + } else { + return super.supportedInterfaceOrientations + } + } + } +} diff --git a/NineAnimator/Controllers/Player Scene/NativePlayerController.swift b/NineAnimator/Controllers/Player Scene/NativePlayerController.swift index dab8670f..a1bf1f38 100644 --- a/NineAnimator/Controllers/Player Scene/NativePlayerController.swift +++ b/NineAnimator/Controllers/Player Scene/NativePlayerController.swift @@ -44,7 +44,7 @@ class NativePlayerController: NSObject, AVPlayerViewControllerDelegate, NSUserAc private let player = AVQueuePlayer() // AVPlayerViewController - private var playerViewController = AVPlayerViewController() + private var playerViewController = NativePlayerViewController() private var playerRateObservation: NSKeyValueObservation? @@ -170,7 +170,7 @@ extension NativePlayerController { playerViewController.dismiss(animated: true, completion: nil) // Create and configure the new player view controller - playerViewController = AVPlayerViewController() + playerViewController = NativePlayerViewController() configurePlayerViewController() } diff --git a/NineAnimator/Controllers/Settings Scene/SettingsSceneController.swift b/NineAnimator/Controllers/Settings Scene/SettingsSceneController.swift index 3a8eff86..84eecffd 100644 --- a/NineAnimator/Controllers/Settings Scene/SettingsSceneController.swift +++ b/NineAnimator/Controllers/Settings Scene/SettingsSceneController.swift @@ -47,10 +47,11 @@ class SettingsSceneController: UITableViewController, Themable, UIAdaptivePresen @IBOutlet private weak var richPresenceStatusLabel: UILabel! @IBOutlet private weak var appIconTableViewCell: UITableViewCell! @IBOutlet private weak var currentAppIconLabel: UILabel! - + @IBOutlet private weak var forceLandscapePlayerSwitch: UISwitch! + /// The path that the Settings view controller will be navigating to private var navigatingTo: EntryPath? - + /// Dismissal handler private var onDismissal: (() -> Void)? private var _fTimerCounter = 0 { @@ -128,6 +129,10 @@ extension SettingsSceneController { NineAnimator.default.user.allowBackgroundPlayback = sender.isOn } + @IBAction private func onForceLandscapePlayerSwitchDidChange(_ sender: UISwitch) { + NineAnimator.default.user.forceLandscapePlayer = sender.isOn + } + @IBAction private func onPlaybackFallbackToBrowserDidChange(_ sender: UISwitch) { NineAnimator.default.user.playbackFallbackToBrowser = sender.isOn } @@ -300,6 +305,8 @@ extension SettingsSceneController { backgroundPlaybackSwitch.isEnabled = !pictureInPictureSwitch.isOn backgroundPlaybackSwitch.setOn(NineAnimator.default.user.allowBackgroundPlayback || (AVPictureInPictureController.isPictureInPictureSupported() && NineAnimator.default.user.allowPictureInPicturePlayback), animated: true) + forceLandscapePlayerSwitch.setOn(NineAnimator.default.user.forceLandscapePlayer, animated: true) + fallbackToBrowserSwitch.setOn( NineAnimator.default.user.playbackFallbackToBrowser, animated: true