From 3ad6cba57a7ef854351b3c0de524c166b2ad255b Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Sat, 22 Feb 2025 21:15:38 -0500 Subject: [PATCH 01/97] Create initial VLCDefaults implementation --- Sources/App/iOS/VLCAppDelegate.m | 9 +- Sources/App/tvOS/AppleTVAppDelegate.m | 1 - .../OneDrive/VLCOneDriveTableViewController.m | 2 +- Sources/Headers/VLCConstants.h | 4 - Sources/Headers/VLCTVConstants.h | 1 - Sources/Helpers/VLCDefaults.swift | 108 ++++++++++++++++++ .../Discovery/VLCMediaFileDiscoverer.m | 2 +- .../MediaCategoryViewController.swift | 16 ++- .../MediaLibraryModel/CollectionModel.swift | 5 +- .../MediaGroupViewModel.swift | 2 +- .../MediaLibraryModel/VideoModel.swift | 2 +- .../Media Library/MediaLibraryService.swift | 2 +- .../VLCNetworkServerBrowserViewController.m | 2 +- .../VLCServerBrowsingTVViewController.m | 2 +- .../Controller/SettingsController.swift | 8 +- .../Settings/Model/ActionSheetSpecifier.swift | 10 +- Sources/Settings/Model/SettingsSection.swift | 35 +++++- Sources/Settings/View/SettingsCell.swift | 5 +- .../ActionSheetSortSectionHeader.swift | 8 +- Sources/UI Elements/PresentationTheme.swift | 4 +- VLC.xcodeproj/project.pbxproj | 6 + 21 files changed, 189 insertions(+), 45 deletions(-) create mode 100644 Sources/Helpers/VLCDefaults.swift diff --git a/Sources/App/iOS/VLCAppDelegate.m b/Sources/App/iOS/VLCAppDelegate.m index d054b695f..f6be29449 100644 --- a/Sources/App/iOS/VLCAppDelegate.m +++ b/Sources/App/iOS/VLCAppDelegate.m @@ -41,6 +41,8 @@ appThemeIndex = kVLCSettingAppThemeSystem; } + [VLCDefaults.shared registerDefaults]; + NSDictionary *appDefaults = @{kVLCSettingAppTheme : @(appThemeIndex), kVLCSettingPasscodeEnableBiometricAuth : @(1), kVLCSettingContinueAudioInBackgroundKey : @(YES), @@ -78,7 +80,6 @@ kVLCSettingPlaybackLockscreenSkip : @(NO), kVLCSettingPlaybackRemoteControlSkip : @(NO), kVLCSettingOpenAppForPlayback : kVLCSettingOpenAppForPlaybackDefaultValue, - kVLCAutomaticallyPlayNextItem : @(YES), kVLCPlaylistPlayNextItem: @(YES), kVLCSettingEnableMediaCellTextScrolling : @(NO), kVLCSettingShowThumbnails : kVLCSettingShowThumbnailsDefaultValue, @@ -87,12 +88,6 @@ kVLCSettingCastingAudioPassthrough : @(NO), kVLCSettingCastingConversionQuality : @(2), kVLCForceSMBV1 : @(YES), - @"kVLCAudioLibraryGridLayoutALBUMS" : @(YES), - @"kVLCAudioLibraryGridLayoutARTISTS" : @(YES), - @"kVLCAudioLibraryGridLayoutGENRES" : @(YES), - @"kVLCVideoLibraryGridLayoutALL_VIDEOS" : @(YES), - @"kVLCVideoLibraryGridLayoutVIDEO_GROUPS" : @(YES), - @"kVLCVideoLibraryGridLayoutVLCMLMediaGroupCollections" : @(YES), kVLCPlayerShouldRememberState: @(YES), kVLCPlayerIsShuffleEnabled: kVLCPlayerIsShuffleEnabledDefaultValue, kVLCPlayerIsRepeatEnabled: kVLCPlayerIsRepeatEnabledDefaultValue, diff --git a/Sources/App/tvOS/AppleTVAppDelegate.m b/Sources/App/tvOS/AppleTVAppDelegate.m index 450251463..90d4af4b8 100644 --- a/Sources/App/tvOS/AppleTVAppDelegate.m +++ b/Sources/App/tvOS/AppleTVAppDelegate.m @@ -61,7 +61,6 @@ kVLCSettingPlaybackLockscreenSkip : @(NO), kVLCSettingPlaybackRemoteControlSkip : @(NO), kVLCSettingWiFiSharingIPv6 : kVLCSettingWiFiSharingIPv6DefaultValue, - kVLCAutomaticallyPlayNextItem : @(YES), kVLCPlayerShouldRememberState: @(YES), kVLCPlayerUIShouldHide : @(NO), kVLCSettingDownloadArtwork : @(YES), diff --git a/Sources/Cloud/Services/OneDrive/VLCOneDriveTableViewController.m b/Sources/Cloud/Services/OneDrive/VLCOneDriveTableViewController.m index 2f48bc657..66841cf29 100644 --- a/Sources/Cloud/Services/OneDrive/VLCOneDriveTableViewController.m +++ b/Sources/Cloud/Services/OneDrive/VLCOneDriveTableViewController.m @@ -132,7 +132,7 @@ NSInteger positionIndex = 0; VLCMedia *mediaToPlay = [VLCMedia mediaWithURL:url]; mediaToPlay = [_oneDriveController setMediaNameMetadata:mediaToPlay withName:selectedItem.name]; - if (![[NSUserDefaults standardUserDefaults] boolForKey:kVLCAutomaticallyPlayNextItem]) { + if (!VLCDefaults.shared.automaticallyPlayNextItem) { mediaList = [[VLCMediaList alloc] initWithArray:@[mediaToPlay]]; subtitlePath = [_oneDriveController configureSubtitleWithFileName:selectedItem.name folderItems:items]; diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index c5d22a5b1..0495899ea 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -13,16 +13,13 @@ #define kVLCSettingPasscodeOnKey @"PasscodeProtection" #define kVLCSettingPasscodeEnableBiometricAuth @"EnableBiometricAuth" -#define kVLCSettingHideLibraryInFilesApp @"HideLibraryInFilesApp" #define kVLCThemeDidChangeNotification @"themeDidChangeNotfication" #define kVLCSettingAppTheme @"darkMode" #define kVLCSettingAppThemeBright 0 #define kVLCSettingAppThemeDark 1 #define kVLCSettingAppThemeSystem 2 -#define kVLCSettingAppThemeBlack @"blackTheme" #define kVLCOptimizeItemNamesForDisplay @"MLDecrapifyTitles" #define kVLCSettingAbout @"about" -#define kVLCAutomaticallyPlayNextItem @"AutomaticallyPlayNextItem" #define kVLCPlaylistPlayNextItem @"PlaylistPlayNextItem" #define kVLCLastPlayedPlaylist @"LastPlayedPlaylist" #define kVLCIsCurrentlyPlayingPlaylist @"isPlaylistCurrentlyPlaying" @@ -118,7 +115,6 @@ #define kVLCAudioLibraryGridLayout @"kVLCAudioLibraryGridLayout" #define kVLCAudioLibraryHideFeatArtists @"kVLCAudioLibraryHideFeatArtists" #define kVLCAudioLibraryHideTrackNumbers @"kVLCAudioLibraryHideTrackNumbers" -#define kVLCVideoLibraryGridLayout @"kVLCVideoLibraryGridLayout" #define kVLCLastPlayedMediaIdentifier @"LastPlayedMediaIdentifier" #define kVLCRestoreLastPlayedMedia @"RestoreLastPlayedMedia" diff --git a/Sources/Headers/VLCTVConstants.h b/Sources/Headers/VLCTVConstants.h index 3d5e993b0..c513c81f0 100644 --- a/Sources/Headers/VLCTVConstants.h +++ b/Sources/Headers/VLCTVConstants.h @@ -68,7 +68,6 @@ #define kVLCSettingPlaybackLockscreenSkip @"playback-lockscreen-skip" #define kVLCSettingPlaybackRemoteControlSkip @"playback-remote-control-skip" #define kVLCSettingSaveHTTPUploadServerStatus @"isHTTPServerOn" -#define kVLCAutomaticallyPlayNextItem @"AutomaticallyPlayNextItem" #define kVLCPlayerUIShouldHide @"PlayerUIShouldHide" #define kVLCSettingDownloadArtwork @"download-artwork" #define kVLCSettingUseSPDIF @"kVLCSettingUseSPDIF" diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift new file mode 100644 index 000000000..e82566529 --- /dev/null +++ b/Sources/Helpers/VLCDefaults.swift @@ -0,0 +1,108 @@ +/***************************************************************************** + * VLCDefaults.swift + * VLC for iOS + ***************************************************************************** + * Copyright (c) 2025 VideoLAN. All rights reserved. + * $Id$ + * + * Authors: Craig Reyenga <craig.reyenga # gmail.com> + * + * Refer to the COPYING file of the official project for license. + *****************************************************************************/ + +@objc final class VLCDefaults: NSObject { + @objc static let shared = VLCDefaults() + + private let userDefaults = UserDefaults.standard + + private override init() {} + + @objc func registerDefaults() { + var dict = [ + Keys.appThemeBlack: false, + Keys.automaticallyPlayNextItem: true + ] + + [ + "ALBUMS", + "ARTISTS", + "GENRES", + "ALL_VIDEOS", + "VIDEO_GROUPS", + "VLCMLMediaGroupCollections" + ].forEach { s in + dict[Keys.videoLibraryGridLayout(name: s)] = true + } + + userDefaults.register(defaults: dict) + } +} + +// MARK: - Defaults + +extension VLCDefaults { + @objc var appThemeBlack: Bool { + get { + userDefaults.bool(forKey: Keys.appThemeBlack) + } + set { + userDefaults.set(newValue, forKey: Keys.appThemeBlack) + } + } + + @objc var automaticallyPlayNextItem: Bool { + get { + userDefaults.bool(forKey: Keys.automaticallyPlayNextItem) + } + set { + userDefaults.set(newValue, forKey: Keys.automaticallyPlayNextItem) + } + } + + @objc var hideLibraryInFilesApp: Bool { + get { + userDefaults.bool(forKey: Keys.hideLibraryInFilesApp) + } + set { + userDefaults.set(newValue, forKey: Keys.hideLibraryInFilesApp) + } + } + + func videoLibraryGridLayout(collectionModelName: String? = nil, name: String) -> Bool { + userDefaults.bool(forKey: Keys.videoLibraryGridLayout(collectionModelName: collectionModelName, name: name)) + } + + func setVideoLibraryGridLayout(collectionModelName: String? = nil, name: String, isGrid: Bool) { + userDefaults.set(isGrid, forKey: Keys.videoLibraryGridLayout(collectionModelName: collectionModelName, name: name)) + } +} + +// MARK: - Compatibility + +extension VLCDefaults { + @available(*, deprecated, message: "avoid using keys to access defaults directly, instead use properties on VLCDefaults") + @objc(VLCDefaultsCompat) + final class Compat: NSObject { + static let automaticallyPlayNextItemKey: String = Keys.automaticallyPlayNextItem + static let hideLibraryInFilesAppKey: String = Keys.hideLibraryInFilesApp + + override init() { + fatalError("compat struct not intended to be instantiated") + } + } +} + +// MARK: - Keys + +fileprivate enum Keys { + static let appThemeBlack = "blackTheme" + static let automaticallyPlayNextItem = "AutomaticallyPlayNextItem" + static let hideLibraryInFilesApp = "HideLibraryInFilesApp" + static let videoLibraryGridLayoutPrefix = "kVLCVideoLibraryGridLayout" + + static func videoLibraryGridLayout(collectionModelName: String? = nil, name: String) -> String { + [ + Self.videoLibraryGridLayoutPrefix, collectionModelName, name + ].compactMap { $0 }.joined() + } +} diff --git a/Sources/Media Library/Discovery/VLCMediaFileDiscoverer.m b/Sources/Media Library/Discovery/VLCMediaFileDiscoverer.m index ce034844b..c51e3f6f3 100644 --- a/Sources/Media Library/Discovery/VLCMediaFileDiscoverer.m +++ b/Sources/Media Library/Discovery/VLCMediaFileDiscoverer.m @@ -226,7 +226,7 @@ const float MediaTimerInterval = 2.f; - (void)didAddMedia:(NSTimer*)timer { #if TARGET_OS_IOS - BOOL hideMediaLibrary = [NSUserDefaults.standardUserDefaults boolForKey:kVLCSettingHideLibraryInFilesApp]; + BOOL hideMediaLibrary = VLCDefaults.shared.hideLibraryInFilesApp; [(NSURL*)[timer.userInfo valueForKey:@"fileURL"] setHidden:hideMediaLibrary recursive:NO onlyFirstLevel:NO :nil]; #endif [NSFileManager.defaultManager removeItemAtPath:[NSString pathWithComponents:@[_directoryPath, NSLocalizedString(@"MEDIALIBRARY_ADDING_PLACEHOLDER", "")]] error:nil]; diff --git a/Sources/Media Library/MediaCategories/MediaCategoryViewController.swift b/Sources/Media Library/MediaCategories/MediaCategoryViewController.swift index c221da347..42514c4d5 100644 --- a/Sources/Media Library/MediaCategories/MediaCategoryViewController.swift +++ b/Sources/Media Library/MediaCategories/MediaCategoryViewController.swift @@ -1538,9 +1538,17 @@ extension MediaCategoryViewController: ActionSheetSortSectionHeaderDelegate { isVideoModel = true } - prefix = isVideoModel ? kVLCVideoLibraryGridLayout : kVLCAudioLibraryGridLayout - suffix = collectionModelName + model.name - userDefaults.set(gridLayout, forKey: "\(prefix)\(suffix)") + switch isVideoModel { + case true: + VLCDefaults.shared.setVideoLibraryGridLayout(collectionModelName: collectionModelName, + name: model.name, + isGrid: gridLayout) + case false: + prefix = kVLCAudioLibraryGridLayout + suffix = collectionModelName + model.name + userDefaults.set(gridLayout, forKey: "\(prefix)\(suffix)") + } + setupCollectionView() cachedCellSize = .zero collectionView?.collectionViewLayout.invalidateLayout() @@ -1779,7 +1787,7 @@ extension MediaCategoryViewController: MediaLibraryBaseModelObserver { extension MediaCategoryViewController { func play(media: VLCMLMedia, at indexPath: IndexPath) { let playbackController = PlaybackService.sharedInstance() - var autoPlayNextItem: Bool = userDefaults.bool(forKey: kVLCAutomaticallyPlayNextItem) + var autoPlayNextItem: Bool = VLCDefaults.shared.automaticallyPlayNextItem playbackController.fullscreenSessionRequested = media.type() != .audio diff --git a/Sources/Media Library/MediaLibraryModel/CollectionModel.swift b/Sources/Media Library/MediaLibraryModel/CollectionModel.swift index 9bd87f214..d39b103d0 100644 --- a/Sources/Media Library/MediaLibraryModel/CollectionModel.swift +++ b/Sources/Media Library/MediaLibraryModel/CollectionModel.swift @@ -28,8 +28,9 @@ class CollectionModel: MLBaseModel { var cellType: BaseCollectionViewCell.Type { if mediaCollection is VLCMLMediaGroup { - return UserDefaults.standard.bool(forKey: "\(kVLCVideoLibraryGridLayout)\(String(describing: type(of: mediaCollection)) + name)") ? - MovieCollectionViewCell.self : MediaCollectionViewCell.self + return VLCDefaults.shared + .videoLibraryGridLayout(collectionModelName: String(describing: type(of: mediaCollection)), name: name) ? + MovieCollectionViewCell.self : MediaCollectionViewCell.self } else { return UserDefaults.standard.bool(forKey: "\(kVLCAudioLibraryGridLayout)\(String(describing: type(of: mediaCollection)) + name)") ? MediaGridCollectionCell.self : MediaCollectionViewCell.self diff --git a/Sources/Media Library/MediaLibraryModel/MediaGroupViewModel.swift b/Sources/Media Library/MediaLibraryModel/MediaGroupViewModel.swift index 43bdd193d..07c9eb299 100644 --- a/Sources/Media Library/MediaLibraryModel/MediaGroupViewModel.swift +++ b/Sources/Media Library/MediaLibraryModel/MediaGroupViewModel.swift @@ -21,7 +21,7 @@ class MediaGroupViewModel: MLBaseModel { var files: [VLCMLMediaGroup] var cellType: BaseCollectionViewCell.Type { - return UserDefaults.standard.bool(forKey: "\(kVLCVideoLibraryGridLayout)\(name)") ? MovieCollectionViewCell.self : MediaCollectionViewCell.self + return VLCDefaults.shared.videoLibraryGridLayout(name: name) ? MovieCollectionViewCell.self : MediaCollectionViewCell.self } var medialibrary: MediaLibraryService diff --git a/Sources/Media Library/MediaLibraryModel/VideoModel.swift b/Sources/Media Library/MediaLibraryModel/VideoModel.swift index d438d50f4..2ed299581 100644 --- a/Sources/Media Library/MediaLibraryModel/VideoModel.swift +++ b/Sources/Media Library/MediaLibraryModel/VideoModel.swift @@ -20,7 +20,7 @@ class VideoModel: MediaModel { var files = [VLCMLMedia]() var cellType: BaseCollectionViewCell.Type { - return UserDefaults.standard.bool(forKey: "\(kVLCVideoLibraryGridLayout)\(name)") ? MovieCollectionViewCell.self : MediaCollectionViewCell.self + return VLCDefaults.shared.videoLibraryGridLayout(name: name) ? MovieCollectionViewCell.self : MediaCollectionViewCell.self } var medialibrary: MediaLibraryService diff --git a/Sources/Media Library/MediaLibraryService.swift b/Sources/Media Library/MediaLibraryService.swift index 4a218f2e7..1771acbf6 100644 --- a/Sources/Media Library/MediaLibraryService.swift +++ b/Sources/Media Library/MediaLibraryService.swift @@ -190,7 +190,7 @@ private extension MediaLibraryService { private func startMediaLibrary(on path: String) { let excludeMediaLibrary = !UserDefaults.standard.bool(forKey: kVLCSettingBackupMediaLibrary) - let hideML = UserDefaults.standard.bool(forKey: kVLCSettingHideLibraryInFilesApp) + let hideML = VLCDefaults.shared.hideLibraryInFilesApp excludeFromDeviceBackup(excludeMediaLibrary) hideMediaLibrary(hideML) diff --git a/Sources/Network/Server Browsing/View Controllers/VLCNetworkServerBrowserViewController.m b/Sources/Network/Server Browsing/View Controllers/VLCNetworkServerBrowserViewController.m index fa54c61ca..81e2354dc 100644 --- a/Sources/Network/Server Browsing/View Controllers/VLCNetworkServerBrowserViewController.m +++ b/Sources/Network/Server Browsing/View Controllers/VLCNetworkServerBrowserViewController.m @@ -273,7 +273,7 @@ { id<VLCNetworkServerBrowserItem> item; NSInteger row = indexPath.row; - BOOL singlePlayback = ![[NSUserDefaults standardUserDefaults] boolForKey:kVLCAutomaticallyPlayNextItem]; + BOOL singlePlayback = !VLCDefaults.shared.automaticallyPlayNextItem; if (self.searchController.isActive) { if (row < _searchArray.count) { item = _searchArray[row]; diff --git a/Sources/Network/Server Browsing/View Controllers/VLCServerBrowsingTVViewController.m b/Sources/Network/Server Browsing/View Controllers/VLCServerBrowsingTVViewController.m index d2f7355fd..6e21e5c30 100644 --- a/Sources/Network/Server Browsing/View Controllers/VLCServerBrowsingTVViewController.m +++ b/Sources/Network/Server Browsing/View Controllers/VLCServerBrowsingTVViewController.m @@ -284,7 +284,7 @@ // would make sence if item came from search which isn't // currently the case on the TV - const BOOL singlePlayback = ![[NSUserDefaults standardUserDefaults] boolForKey:kVLCAutomaticallyPlayNextItem]; + const BOOL singlePlayback = !VLCDefaults.shared.automaticallyPlayNextItem; [self didSelectItem:item index:row singlePlayback:singlePlayback]; } diff --git a/Sources/Settings/Controller/SettingsController.swift b/Sources/Settings/Controller/SettingsController.swift index bd9aa32be..653f413f1 100644 --- a/Sources/Settings/Controller/SettingsController.swift +++ b/Sources/Settings/Controller/SettingsController.swift @@ -256,7 +256,7 @@ class SettingsController: UITableViewController { actionSheet.numberOfColums = numberOfColumns present(actionSheet, animated: false) { - if preferenceKey != kVLCAutomaticallyPlayNextItem { + if preferenceKey != VLCDefaults.Compat.automaticallyPlayNextItemKey { self.actionSheet.collectionView.selectItem(at: self.specifierManager.selectedIndex, animated: false, scrollPosition: .centeredVertically) } } @@ -432,7 +432,7 @@ extension SettingsController: SettingsCellDelegate { switch preferenceKey { case kVLCSettingPasscodeOnKey: passcodeLockSwitchOn(state: isOn) - case kVLCSettingHideLibraryInFilesApp: + case VLCDefaults.Compat.hideLibraryInFilesAppKey: medialibraryHidingLockSwitchOn(state: isOn) case kVLCSettingBackupMediaLibrary: mediaLibraryBackupActivateSwitchOn(state: isOn) @@ -510,10 +510,10 @@ extension SettingsController: ActionSheetSpecifierDelegate { func actionSheetSpecifierHandleToggleSwitch(for cell: ActionSheetCell, state: Bool) { switch cell.identifier { case .blackBackground: - userDefaults.setValue(state, forKey: kVLCSettingAppThemeBlack) + VLCDefaults.shared.appThemeBlack = state PresentationTheme.themeDidUpdate() case .playNextItem: - userDefaults.setValue(state, forKey: kVLCAutomaticallyPlayNextItem) + VLCDefaults.shared.automaticallyPlayNextItem = state case .playlistPlayNextItem: userDefaults.setValue(state, forKey: kVLCPlaylistPlayNextItem) default: diff --git a/Sources/Settings/Model/ActionSheetSpecifier.swift b/Sources/Settings/Model/ActionSheetSpecifier.swift index ed4e4db9f..3fb840895 100644 --- a/Sources/Settings/Model/ActionSheetSpecifier.swift +++ b/Sources/Settings/Model/ActionSheetSpecifier.swift @@ -66,7 +66,7 @@ extension ActionSheetSpecifier: ActionSheetDelegate { return } - guard preferenceKey != kVLCAutomaticallyPlayNextItem else { + guard preferenceKey != VLCDefaults.Compat.automaticallyPlayNextItemKey else { // Disable the selection for the automatically play next item options return } @@ -132,7 +132,7 @@ extension ActionSheetSpecifier: ActionSheetDataSource { PresentationTheme.current.isDark && indexPath.row == numberOfRows() - 1 { // Update the black background option cell cell.setAccessoryType(to: .toggleSwitch) - cell.setToggleSwitch(state: UserDefaults.standard.bool(forKey: kVLCSettingAppThemeBlack)) + cell.setToggleSwitch(state: VLCDefaults.shared.appThemeBlack) cell.name.text = settingsBundle.localizedString(forKey: "SETTINGS_THEME_BLACK", value: "", table: "Root") let cellIdentifier = ActionSheetCellIdentifier.blackBackground cell.identifier = cellIdentifier @@ -141,12 +141,12 @@ extension ActionSheetSpecifier: ActionSheetDataSource { cell.delegate = self return cell - } else if preferenceKey == kVLCAutomaticallyPlayNextItem { + } else if preferenceKey == VLCDefaults.Compat.automaticallyPlayNextItemKey { cell.setAccessoryType(to: .toggleSwitch) let isFirstRow: Bool = indexPath.row == 0 if isFirstRow { - cell.setToggleSwitch(state: userDefaults.bool(forKey: kVLCAutomaticallyPlayNextItem)) + cell.setToggleSwitch(state: VLCDefaults.shared.automaticallyPlayNextItem) } else { cell.setToggleSwitch(state: userDefaults.bool(forKey: kVLCPlaylistPlayNextItem)) } @@ -166,7 +166,7 @@ extension ActionSheetSpecifier: ActionSheetDataSource { extension ActionSheetSpecifier: ActionSheetCellDelegate { func actionSheetCellShouldUpdateColors() -> Bool { - guard preferenceKey != kVLCAutomaticallyPlayNextItem else { + guard preferenceKey != VLCDefaults.Compat.automaticallyPlayNextItemKey else { return false } diff --git a/Sources/Settings/Model/SettingsSection.swift b/Sources/Settings/Model/SettingsSection.swift index a7b6ffbe5..bba6e1160 100644 --- a/Sources/Settings/Model/SettingsSection.swift +++ b/Sources/Settings/Model/SettingsSection.swift @@ -48,6 +48,10 @@ struct SettingsItem: Equatable { return Self(title: title, subtitle: subtitle, action: .toggle(Toggle(preferenceKey: preferenceKey))) } + static func toggle(title: String, subtitle: String?, keyPath: WritableKeyPath<VLCDefaults, Bool>) -> Self { + return Self(title: title, subtitle: subtitle, action: .toggle(Toggle(keyPath: keyPath))) + } + enum Action: Equatable { case isLoading case toggle(Toggle) @@ -62,10 +66,17 @@ struct SettingsItem: Equatable { final class Toggle: Equatable { typealias Observer = (Bool) -> Void - let preferenceKey: String + let preferenceKey: String? + let keyPath: WritableKeyPath<VLCDefaults, Bool>? var isOn: Bool { - UserDefaults.standard.bool(forKey: preferenceKey) + if let keyPath = keyPath { + VLCDefaults.shared[keyPath: keyPath] + } else if let preferenceKey = preferenceKey { + UserDefaults.standard.bool(forKey: preferenceKey) + } else { + fatalError() + } } private var observers: [Int: Observer] = [:] @@ -79,11 +90,25 @@ struct SettingsItem: Equatable { init(preferenceKey: String) { self.preferenceKey = preferenceKey + self.keyPath = nil + NotificationCenter.default.addObserver(self, selector: #selector(didChange), name: UserDefaults.didChangeNotification, object: nil) + } + + init(keyPath: WritableKeyPath<VLCDefaults, Bool>) { + self.preferenceKey = nil + self.keyPath = keyPath NotificationCenter.default.addObserver(self, selector: #selector(didChange), name: UserDefaults.didChangeNotification, object: nil) } func set(isOn: Bool) { - UserDefaults.standard.set(isOn, forKey: preferenceKey) + if let keyPath = keyPath { + var defaults = VLCDefaults.shared + defaults[keyPath: keyPath] = isOn + } else if let preferenceKey = preferenceKey { + UserDefaults.standard.set(isOn, forKey: preferenceKey) + } else { + fatalError() + } } // does not call out initially. @@ -229,7 +254,7 @@ enum GenericOptions { } static var automaticallyPlayNextItem: SettingsItem { - let k = kVLCAutomaticallyPlayNextItem + let k = VLCDefaults.Compat.automaticallyPlayNextItemKey return .init(title: "SETTINGS_NETWORK_PLAY_ALL", subtitle: Localizer.getSubtitle(for: k), action: .showActionSheet(title: "SETTINGS_NETWORK_PLAY_ALL", preferenceKey: k, hasInfo: false)) @@ -306,7 +331,7 @@ enum PrivacyOptions { static var hideLibraryInFilesApp: SettingsItem { .toggle(title: "SETTINGS_HIDE_LIBRARY_IN_FILES_APP", subtitle: "SETTINGS_HIDE_LIBRARY_IN_FILES_APP_SUBTITLE", - preferenceKey: kVLCSettingHideLibraryInFilesApp) + keyPath: \.hideLibraryInFilesApp) } static func section() -> SettingsSection? { diff --git a/Sources/Settings/View/SettingsCell.swift b/Sources/Settings/View/SettingsCell.swift index 0f9a69edc..c67c32751 100644 --- a/Sources/Settings/View/SettingsCell.swift +++ b/Sources/Settings/View/SettingsCell.swift @@ -288,7 +288,10 @@ class SettingsCell: UITableViewCell { switch settingsItem.action { case let .toggle(toggle): toggle.set(isOn: sender.isOn) - delegate?.settingsCellDidChangeSwitchState(cell: self, preferenceKey: toggle.preferenceKey, isOn: sender.isOn) + // TODO: we should get rid of the delegate entirely, and perform side effects within SettingSection + if let preferenceKey = toggle.preferenceKey { + delegate?.settingsCellDidChangeSwitchState(cell: self, preferenceKey: preferenceKey, isOn: sender.isOn) + } default: // we should never get here; only toggles have a switch diff --git a/Sources/UI Elements/ActionSheet/ActionSheetSortSectionHeader.swift b/Sources/UI Elements/ActionSheet/ActionSheetSortSectionHeader.swift index 0e277e786..ba8961acf 100644 --- a/Sources/UI Elements/ActionSheet/ActionSheetSortSectionHeader.swift +++ b/Sources/UI Elements/ActionSheet/ActionSheetSortSectionHeader.swift @@ -251,8 +251,12 @@ class ActionSheetSortSectionHeader: ActionSheetSectionHeader { } private func setSwitchIsOnFromUserDefaults() { - let key = isVideoModel ? kVLCVideoLibraryGridLayout : kVLCAudioLibraryGridLayout - layoutChangeSwitch.isOn = UserDefaults.standard.bool(forKey: key + modelType) + switch isVideoModel { + case true: + layoutChangeSwitch.isOn = VLCDefaults.shared.videoLibraryGridLayout(name: modelType) + case false: + layoutChangeSwitch.isOn = UserDefaults.standard.bool(forKey: kVLCAudioLibraryGridLayout + modelType) + } } private func setupStackView() { diff --git a/Sources/UI Elements/PresentationTheme.swift b/Sources/UI Elements/PresentationTheme.swift index 10585824d..560b40079 100644 --- a/Sources/UI Elements/PresentationTheme.swift +++ b/Sources/UI Elements/PresentationTheme.swift @@ -117,7 +117,7 @@ enum PresentationThemeType: Int { } var isBlack: Bool { - return UserDefaults.standard.bool(forKey: kVLCSettingAppThemeBlack) + VLCDefaults.shared.appThemeBlack } static var current: PresentationTheme = { @@ -157,7 +157,7 @@ enum PresentationThemeType: Int { var presentationTheme = PresentationTheme.brightTheme var darkTheme: PresentationTheme - if UserDefaults.standard.bool(forKey: kVLCSettingAppThemeBlack) { + if VLCDefaults.shared.appThemeBlack { darkTheme = PresentationTheme.blackTheme } else { darkTheme = PresentationTheme.darkTheme diff --git a/VLC.xcodeproj/project.pbxproj b/VLC.xcodeproj/project.pbxproj index 4f743280f..29a3de130 100644 --- a/VLC.xcodeproj/project.pbxproj +++ b/VLC.xcodeproj/project.pbxproj @@ -95,6 +95,8 @@ 4342C3C327474CA000E52334 /* SortedMediaFiles.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4342C3C227474CA000E52334 /* SortedMediaFiles.swift */; }; 444E5BFA24C6081B0003B69C /* PasscodeLockController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 444E5BF924C6081A0003B69C /* PasscodeLockController.swift */; }; 444E5C0024C719480003B69C /* AboutController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 444E5BFF24C719480003B69C /* AboutController.swift */; }; + 446AA2322D6A91620026F3C8 /* VLCDefaults.swift in Sources */ = {isa = PBXBuildFile; fileRef = 446AA2312D6A91520026F3C8 /* VLCDefaults.swift */; }; + 446AA2332D6A91620026F3C8 /* VLCDefaults.swift in Sources */ = {isa = PBXBuildFile; fileRef = 446AA2312D6A91520026F3C8 /* VLCDefaults.swift */; }; 44B5822024E434FD001A2583 /* MediaGridCollectionCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 44B5821F24E434FD001A2583 /* MediaGridCollectionCell.swift */; }; 44C8BBA324AF2B5C003F8940 /* FeedbackGenerators.swift in Sources */ = {isa = PBXBuildFile; fileRef = 44C8BBA224AF2B5C003F8940 /* FeedbackGenerators.swift */; }; 44C8BBAE24AF36F4003F8940 /* SettingsController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 44C8BBA624AF36F4003F8940 /* SettingsController.swift */; }; @@ -1012,6 +1014,7 @@ 4342C3C227474CA000E52334 /* SortedMediaFiles.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SortedMediaFiles.swift; sourceTree = "<group>"; }; 444E5BF924C6081A0003B69C /* PasscodeLockController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PasscodeLockController.swift; sourceTree = "<group>"; }; 444E5BFF24C719480003B69C /* AboutController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AboutController.swift; sourceTree = "<group>"; }; + 446AA2312D6A91520026F3C8 /* VLCDefaults.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VLCDefaults.swift; sourceTree = "<group>"; }; 44B5821F24E434FD001A2583 /* MediaGridCollectionCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MediaGridCollectionCell.swift; sourceTree = "<group>"; }; 44C8BBA224AF2B5C003F8940 /* FeedbackGenerators.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FeedbackGenerators.swift; sourceTree = "<group>"; }; 44C8BBA624AF36F4003F8940 /* SettingsController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SettingsController.swift; sourceTree = "<group>"; }; @@ -1898,6 +1901,7 @@ 44C8BBA124AF2B5C003F8940 /* Helpers */ = { isa = PBXGroup; children = ( + 446AA2312D6A91520026F3C8 /* VLCDefaults.swift */, 419A2C651F37A4B70069D224 /* VLCStringsForLocalization.m */, 4152F1611FEF19BD00F1908B /* KeychainCoordinator.swift */, 7D0C209A28C89F5400CCFFEF /* Network */, @@ -4462,6 +4466,7 @@ 7D50C6A42BBD20DF00B9F1A0 /* VLCDownloadController.m in Sources */, 7D50C6A52BBD20DF00B9F1A0 /* RemoteNetworkCell.swift in Sources */, 7D50C6A62BBD20DF00B9F1A0 /* VLCNetworkLoginDataSourceLogin.m in Sources */, + 446AA2332D6A91620026F3C8 /* VLCDefaults.swift in Sources */, 7D50C6A72BBD20DF00B9F1A0 /* VLCAccessibilityIdentifier.swift in Sources */, 7D50C6A82BBD20DF00B9F1A0 /* VLCPagingViewController.swift in Sources */, 7D50C6A92BBD20DF00B9F1A0 /* VLCLocalNetworkServiceBrowserBonjour.m in Sources */, @@ -4563,6 +4568,7 @@ 7DBF605C2B5D652900F16BB4 /* VLCFirstStepsDonateViewController.m in Sources */, 7D1471752B88A7BA00AB642B /* VLCCharge.m in Sources */, DD3EFF451BDEBCE500B68579 /* VLCLocalNetworkServiceBrowserManualConnect.m in Sources */, + 446AA2322D6A91620026F3C8 /* VLCDefaults.swift in Sources */, 8DF966B121188BDB00D0FCD6 /* EditController.swift in Sources */, 8D144D6322298E8E00984C46 /* AudioMiniPlayer.swift in Sources */, 7DC7BAB528C8958900109F28 /* UIColor+Presets.m in Sources */, -- GitLab From b7bb6bd4d1dc9802f24179d6fb217c9843390f76 Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Sun, 23 Feb 2025 11:37:00 -0500 Subject: [PATCH 02/97] Convert kVLCPlayerShouldRememberState --- Sources/App/iOS/VLCAppDelegate.m | 1 - Sources/App/tvOS/AppleTVAppDelegate.m | 1 - Sources/Headers/VLCConstants.h | 1 - Sources/Headers/VLCTVConstants.h | 1 - Sources/Helpers/VLCDefaults.swift | 13 ++++++++++++- Sources/Playback/Control/VLCPlaybackService.m | 6 +++--- .../Playback/Control/VLCPlayerDisplayController.m | 2 +- .../Player/VideoPlayer-iOS/PlayerController.swift | 2 +- .../VLCFullscreenMovieTVViewController.m | 2 +- Sources/Settings/Model/SettingsSection.swift | 2 +- 10 files changed, 19 insertions(+), 12 deletions(-) diff --git a/Sources/App/iOS/VLCAppDelegate.m b/Sources/App/iOS/VLCAppDelegate.m index f6be29449..419a552a3 100644 --- a/Sources/App/iOS/VLCAppDelegate.m +++ b/Sources/App/iOS/VLCAppDelegate.m @@ -88,7 +88,6 @@ kVLCSettingCastingAudioPassthrough : @(NO), kVLCSettingCastingConversionQuality : @(2), kVLCForceSMBV1 : @(YES), - kVLCPlayerShouldRememberState: @(YES), kVLCPlayerIsShuffleEnabled: kVLCPlayerIsShuffleEnabledDefaultValue, kVLCPlayerIsRepeatEnabled: kVLCPlayerIsRepeatEnabledDefaultValue, kVLCSettingPlaybackSpeedDefaultValue: @(1.0), diff --git a/Sources/App/tvOS/AppleTVAppDelegate.m b/Sources/App/tvOS/AppleTVAppDelegate.m index 90d4af4b8..319663038 100644 --- a/Sources/App/tvOS/AppleTVAppDelegate.m +++ b/Sources/App/tvOS/AppleTVAppDelegate.m @@ -61,7 +61,6 @@ kVLCSettingPlaybackLockscreenSkip : @(NO), kVLCSettingPlaybackRemoteControlSkip : @(NO), kVLCSettingWiFiSharingIPv6 : kVLCSettingWiFiSharingIPv6DefaultValue, - kVLCPlayerShouldRememberState: @(YES), kVLCPlayerUIShouldHide : @(NO), kVLCSettingDownloadArtwork : @(YES), kVLCForceSMBV1 : @(YES), diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index 0495899ea..ffc5df590 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -120,7 +120,6 @@ #define kVLCRestoreLastPlayedMedia @"RestoreLastPlayedMedia" #define kVLCPlayerOpenInMiniPlayer @"OpenInMiniPlayer" -#define kVLCPlayerShouldRememberState @"PlayerShouldRememberState" #define kVLCPlayerShouldRememberBrightness @"PlayerShouldRememberBrightness" #define KVLCPlayerBrightness @"playerbrightness" #define kVLCPlayerIsShuffleEnabled @"PlayerIsShuffleEnabled" diff --git a/Sources/Headers/VLCTVConstants.h b/Sources/Headers/VLCTVConstants.h index c513c81f0..bbad3101a 100644 --- a/Sources/Headers/VLCTVConstants.h +++ b/Sources/Headers/VLCTVConstants.h @@ -80,7 +80,6 @@ #define kVLCLastPlayedMediaIdentifier @"LastPlayedMediaIdentifier" #define kVLCPlayerOpenInMiniPlayer @"OpenInMiniPlayer" -#define kVLCPlayerShouldRememberState @"PlayerShouldRememberState" #define kVLCPlayerIsShuffleEnabled @"PlayerIsShuffleEnabled" #define kVLCPlayerIsShuffleEnabledDefaultValue @NO #define kVLCPlayerIsRepeatEnabled @"PlayerIsRepeatEnabled" diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index e82566529..af695a925 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -20,7 +20,8 @@ @objc func registerDefaults() { var dict = [ Keys.appThemeBlack: false, - Keys.automaticallyPlayNextItem: true + Keys.automaticallyPlayNextItem: true, + Keys.playerShouldRememberState: true ] [ @@ -68,6 +69,15 @@ extension VLCDefaults { } } + @objc var playerShouldRememberState: Bool { + get { + userDefaults.bool(forKey: Keys.playerShouldRememberState) + } + set { + userDefaults.set(newValue, forKey: Keys.playerShouldRememberState) + } + } + func videoLibraryGridLayout(collectionModelName: String? = nil, name: String) -> Bool { userDefaults.bool(forKey: Keys.videoLibraryGridLayout(collectionModelName: collectionModelName, name: name)) } @@ -98,6 +108,7 @@ fileprivate enum Keys { static let appThemeBlack = "blackTheme" static let automaticallyPlayNextItem = "AutomaticallyPlayNextItem" static let hideLibraryInFilesApp = "HideLibraryInFilesApp" + static let playerShouldRememberState = "PlayerShouldRememberState" static let videoLibraryGridLayoutPrefix = "kVLCVideoLibraryGridLayout" static func videoLibraryGridLayout(collectionModelName: String? = nil, name: String) -> String { diff --git a/Sources/Playback/Control/VLCPlaybackService.m b/Sources/Playback/Control/VLCPlaybackService.m index 75663a087..27ea48621 100644 --- a/Sources/Playback/Control/VLCPlaybackService.m +++ b/Sources/Playback/Control/VLCPlaybackService.m @@ -322,7 +322,7 @@ NSString *const VLCLastPlaylistPlayedMedia = @"LastPlaylistPlayedMedia"; [_mediaPlayer setDeinterlace:deinterlace withFilter:@"blend"]; [_listPlayer setMediaList:self.mediaList]; - if ([defaults boolForKey:kVLCPlayerShouldRememberState]) { + if (VLCDefaults.shared.playerShouldRememberState) { VLCRepeatMode repeatMode = [defaults integerForKey:kVLCPlayerIsRepeatEnabled]; [_listPlayer setRepeatMode:repeatMode]; } @@ -581,7 +581,7 @@ NSString *const VLCLastPlaylistPlayedMedia = @"LastPlaylistPlayedMedia"; [[NSNotificationCenter defaultCenter] postNotificationName:VLCPlaybackServicePlaybackModeUpdated object:self]; NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; - if ([defaults boolForKey:kVLCPlayerShouldRememberState]) { + if (VLCDefaults.shared.playerShouldRememberState) { [defaults setInteger:repeatMode forKey:kVLCPlayerIsRepeatEnabled]; } } @@ -1019,7 +1019,7 @@ NSString *const VLCLastPlaylistPlayedMedia = @"LastPlaylistPlayedMedia"; [[NSNotificationCenter defaultCenter] postNotificationName:VLCPlaybackServiceShuffleModeUpdated object:self]; NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; - if ([[defaults valueForKey:kVLCPlayerShouldRememberState] boolValue]) { + if (VLCDefaults.shared.playerShouldRememberState) { [defaults setBool:shuffleMode forKey:kVLCPlayerIsShuffleEnabled]; } } diff --git a/Sources/Playback/Control/VLCPlayerDisplayController.m b/Sources/Playback/Control/VLCPlayerDisplayController.m index 0ce8275dc..b614d2875 100644 --- a/Sources/Playback/Control/VLCPlayerDisplayController.m +++ b/Sources/Playback/Control/VLCPlayerDisplayController.m @@ -485,7 +485,7 @@ NSString *const VLCPlayerDisplayControllerHideMiniPlayer = @"VLCPlayerDisplayCon // Properly set the shuffle and repeat mode NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults]; - if ([userDefaults boolForKey:kVLCPlayerShouldRememberState]) { + if (VLCDefaults.shared.playerShouldRememberState) { _playbackController.shuffleMode = [userDefaults boolForKey:kVLCPlayerIsShuffleEnabled]; NSInteger repeatMode = [userDefaults integerForKey:kVLCPlayerIsRepeatEnabled]; _playbackController.repeatMode = repeatMode; diff --git a/Sources/Playback/Player/VideoPlayer-iOS/PlayerController.swift b/Sources/Playback/Player/VideoPlayer-iOS/PlayerController.swift index 07217a3b4..a57146ff7 100644 --- a/Sources/Playback/Player/VideoPlayer-iOS/PlayerController.swift +++ b/Sources/Playback/Player/VideoPlayer-iOS/PlayerController.swift @@ -79,7 +79,7 @@ class PlayerController: NSObject { } var isRememberStateEnabled: Bool { - return UserDefaults.standard.bool(forKey: kVLCPlayerShouldRememberState) + return VLCDefaults.shared.playerShouldRememberState } var isRememberBrightnessEnabled: Bool { diff --git a/Sources/Playback/Player/VideoPlayer-tvOS/VLCFullscreenMovieTVViewController.m b/Sources/Playback/Player/VideoPlayer-tvOS/VLCFullscreenMovieTVViewController.m index c1d89fe98..2dc666639 100644 --- a/Sources/Playback/Player/VideoPlayer-tvOS/VLCFullscreenMovieTVViewController.m +++ b/Sources/Playback/Player/VideoPlayer-tvOS/VLCFullscreenMovieTVViewController.m @@ -172,7 +172,7 @@ typedef NS_ENUM(NSInteger, VLCPlayerScanState) vpc.delegate = self; NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; - if ([defaults boolForKey:kVLCPlayerShouldRememberState]) { + if (VLCDefaults.shared.playerShouldRememberState) { vpc.shuffleMode = [defaults boolForKey:kVLCPlayerIsShuffleEnabled]; vpc.repeatMode = [defaults integerForKey:kVLCPlayerIsRepeatEnabled]; } diff --git a/Sources/Settings/Model/SettingsSection.swift b/Sources/Settings/Model/SettingsSection.swift index bba6e1160..cd403ac73 100644 --- a/Sources/Settings/Model/SettingsSection.swift +++ b/Sources/Settings/Model/SettingsSection.swift @@ -269,7 +269,7 @@ enum GenericOptions { static var rememberPlayerState: SettingsItem { .toggle(title: "SETTINGS_REMEMBER_PLAYER_STATE", subtitle: nil, - preferenceKey: kVLCPlayerShouldRememberState) + keyPath: \.playerShouldRememberState) } static var restoreLastPlayedMedia: SettingsItem { -- GitLab From 36da06f23633dfc35b23dc187a91212c7717254d Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Sun, 23 Feb 2025 12:25:24 -0500 Subject: [PATCH 03/97] Convert kVLCSettingDefaultPreampLevel --- Sources/App/iOS/VLCAppDelegate.m | 1 - Sources/App/tvOS/AppleTVAppDelegate.m | 1 - Sources/Headers/VLCConstants.h | 1 - Sources/Headers/VLCTVConstants.h | 1 - Sources/Helpers/VLCDefaults.swift | 21 +++++++++++++++++-- Sources/Playback/Control/VLCPlaybackService.m | 6 +++--- Sources/Settings/Model/SettingsSection.swift | 2 +- 7 files changed, 23 insertions(+), 10 deletions(-) diff --git a/Sources/App/iOS/VLCAppDelegate.m b/Sources/App/iOS/VLCAppDelegate.m index 419a552a3..23730e89a 100644 --- a/Sources/App/iOS/VLCAppDelegate.m +++ b/Sources/App/iOS/VLCAppDelegate.m @@ -47,7 +47,6 @@ kVLCSettingPasscodeEnableBiometricAuth : @(1), kVLCSettingContinueAudioInBackgroundKey : @(YES), kVLCSettingStretchAudio : @(YES), - kVLCSettingDefaultPreampLevel : @(6), kVLCSettingTextEncoding : kVLCSettingTextEncodingDefaultValue, kVLCSettingSkipLoopFilter : kVLCSettingSkipLoopFilterNonRef, kVLCSettingSubtitlesFont : kVLCSettingSubtitlesFontDefaultValue, diff --git a/Sources/App/tvOS/AppleTVAppDelegate.m b/Sources/App/tvOS/AppleTVAppDelegate.m index 319663038..f27344108 100644 --- a/Sources/App/tvOS/AppleTVAppDelegate.m +++ b/Sources/App/tvOS/AppleTVAppDelegate.m @@ -42,7 +42,6 @@ NSDictionary *appDefaults = @{kVLCSettingContinueAudioInBackgroundKey : @(YES), kVLCSettingStretchAudio : @(YES), - kVLCSettingDefaultPreampLevel : @(6), kVLCSettingTextEncoding : kVLCSettingTextEncodingDefaultValue, kVLCSettingSkipLoopFilter : kVLCSettingSkipLoopFilterNonRef, kVLCSettingSubtitlesFont : kVLCSettingSubtitlesFontDefaultValue, diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index ffc5df590..c079f2176 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -27,7 +27,6 @@ #define kVLCSettingEnableMediaCellTextScrolling @"EnableMediaCellTextScrolling" #define kVLCSettingContinueAudioInBackgroundKey @"BackgroundAudioPlayback" #define kVLCSettingStretchAudio @"audio-time-stretch" -#define kVLCSettingDefaultPreampLevel @"pre-amp-level" #define kVLCSettingTextEncoding @"subsdec-encoding" #define kVLCSettingTextEncodingDefaultValue @"Windows-1252" #define kVLCSettingSkipLoopFilter @"avcodec-skiploopfilter" diff --git a/Sources/Headers/VLCTVConstants.h b/Sources/Headers/VLCTVConstants.h index bbad3101a..ab6f3850c 100644 --- a/Sources/Headers/VLCTVConstants.h +++ b/Sources/Headers/VLCTVConstants.h @@ -56,7 +56,6 @@ #define kVLCSettingStretchAudioOnValue @"1" #define kVLCSettingStretchAudioOffValue @"0" #define kVLCSettingContinueAudioInBackgroundKey @"BackgroundAudioPlayback" -#define kVLCSettingDefaultPreampLevel @"pre-amp-level" #define kVLCSettingSubtitlesFilePath @"sub-file" #define kVLCSettingEqualizerProfile @"EqualizerProfile" #define kVLCSettingEqualizerProfileDisabled @"EqualizerDisabled" diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index af695a925..7e6a6feb4 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -18,10 +18,15 @@ private override init() {} @objc func registerDefaults() { - var dict = [ + var dict: [String: Any] = [ + // bools Keys.appThemeBlack: false, Keys.automaticallyPlayNextItem: true, - Keys.playerShouldRememberState: true + Keys.hideLibraryInFilesApp: false, + Keys.playerShouldRememberState: true, + + // numbers + Keys.defaultPreampLevel: Float(6) ] [ @@ -78,6 +83,15 @@ extension VLCDefaults { } } + @objc var defaultPreampLevel: Float { + get { + userDefaults.float(forKey: Keys.defaultPreampLevel) + } + set { + userDefaults.set(newValue, forKey: Keys.defaultPreampLevel) + } + } + func videoLibraryGridLayout(collectionModelName: String? = nil, name: String) -> Bool { userDefaults.bool(forKey: Keys.videoLibraryGridLayout(collectionModelName: collectionModelName, name: name)) } @@ -95,6 +109,7 @@ extension VLCDefaults { final class Compat: NSObject { static let automaticallyPlayNextItemKey: String = Keys.automaticallyPlayNextItem static let hideLibraryInFilesAppKey: String = Keys.hideLibraryInFilesApp + static let defaultPreampLevelKey: String = Keys.defaultPreampLevel override init() { fatalError("compat struct not intended to be instantiated") @@ -109,6 +124,8 @@ fileprivate enum Keys { static let automaticallyPlayNextItem = "AutomaticallyPlayNextItem" static let hideLibraryInFilesApp = "HideLibraryInFilesApp" static let playerShouldRememberState = "PlayerShouldRememberState" + static let defaultPreampLevel = "pre-amp-level" + static let videoLibraryGridLayoutPrefix = "kVLCVideoLibraryGridLayout" static func videoLibraryGridLayout(collectionModelName: String? = nil, name: String) -> String { diff --git a/Sources/Playback/Control/VLCPlaybackService.m b/Sources/Playback/Control/VLCPlaybackService.m index 27ea48621..cf657d5a9 100644 --- a/Sources/Playback/Control/VLCPlaybackService.m +++ b/Sources/Playback/Control/VLCPlaybackService.m @@ -350,7 +350,7 @@ NSString *const VLCLastPlaylistPlayedMedia = @"LastPlaylistPlayedMedia"; unsigned int profile = (unsigned int)[userDefaults integerForKey:kVLCSettingEqualizerProfile]; equalizer = [[VLCAudioEqualizer alloc] initWithPreset:presets[profile]]; } else { - float preampValue = [userDefaults floatForKey:kVLCSettingDefaultPreampLevel]; + float preampValue = VLCDefaults.shared.defaultPreampLevel; equalizer = [[VLCAudioEqualizer alloc] init]; equalizer.preAmplification = preampValue; } @@ -1405,7 +1405,7 @@ NSString *const VLCLastPlaylistPlayedMedia = @"LastPlaylistPlayedMedia"; _mediaPlayer.equalizer = nil; [userDefaults setBool:YES forKey:kVLCSettingEqualizerProfileDisabled]; - float preampValue = [userDefaults floatForKey:kVLCSettingDefaultPreampLevel]; + float preampValue = VLCDefaults.shared.defaultPreampLevel; if (preampValue != 6.0) { APLog(@"Enforcing presumbly disabled equalizer due to custom preamp value of %f2.0", preampValue); VLCAudioEqualizer *eq = [[VLCAudioEqualizer alloc] init]; @@ -1442,7 +1442,7 @@ NSString *const VLCLastPlaylistPlayedMedia = @"LastPlaylistPlayedMedia"; return equalizer.preAmplification; } - return [[NSUserDefaults standardUserDefaults] floatForKey:kVLCSettingDefaultPreampLevel]; + return VLCDefaults.shared.defaultPreampLevel; } - (unsigned int)numberOfBands diff --git a/Sources/Settings/Model/SettingsSection.swift b/Sources/Settings/Model/SettingsSection.swift index cd403ac73..9d19927ba 100644 --- a/Sources/Settings/Model/SettingsSection.swift +++ b/Sources/Settings/Model/SettingsSection.swift @@ -621,7 +621,7 @@ enum CastingOptions { enum AudioOptions { static var preampLevel: SettingsItem { - let k = kVLCSettingDefaultPreampLevel + let k = VLCDefaults.Compat.defaultPreampLevelKey return .init(title: "SETTINGS_AUDIO_PREAMP_LEVEL", subtitle: Localizer.getSubtitle(for: k), action: .showActionSheet(title: "SETTINGS_AUDIO_PREAMP_LEVEL", preferenceKey: k, hasInfo: false)) -- GitLab From 2d53bf868485e0f5b434cdb9256fd144f5d4b193 Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Sun, 23 Feb 2025 12:31:34 -0500 Subject: [PATCH 04/97] Convert kVLCShowRemainingTime --- Sources/Headers/VLCConstants.h | 1 - Sources/Helpers/VLCDefaults.swift | 11 +++++++++++ .../VideoPlayer-iOS/MediaScrubProgressBar.swift | 6 ++---- .../Player/VideoPlayer-iOS/PlayerController.swift | 2 +- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index c079f2176..48449e6ae 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -105,7 +105,6 @@ #define kVLCForceSMBV1 @"smb-force-v1" -#define kVLCShowRemainingTime @"show-remaining-time" #define kVLCRecentURLs @"recent-urls" #define kVLCRecentURLTitles @"recent-url-titles" #define kVLCPrivateWebStreaming @"private-streaming" diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index 7e6a6feb4..78f751488 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -24,6 +24,7 @@ Keys.automaticallyPlayNextItem: true, Keys.hideLibraryInFilesApp: false, Keys.playerShouldRememberState: true, + Keys.showRemainingTime: false, // numbers Keys.defaultPreampLevel: Float(6) @@ -92,6 +93,15 @@ extension VLCDefaults { } } + @objc var showRemainingTime: Bool { + get { + userDefaults.bool(forKey: Keys.showRemainingTime) + } + set { + userDefaults.set(newValue, forKey: Keys.showRemainingTime) + } + } + func videoLibraryGridLayout(collectionModelName: String? = nil, name: String) -> Bool { userDefaults.bool(forKey: Keys.videoLibraryGridLayout(collectionModelName: collectionModelName, name: name)) } @@ -125,6 +135,7 @@ fileprivate enum Keys { static let hideLibraryInFilesApp = "HideLibraryInFilesApp" static let playerShouldRememberState = "PlayerShouldRememberState" static let defaultPreampLevel = "pre-amp-level" + static let showRemainingTime = "show-remaining-time" static let videoLibraryGridLayoutPrefix = "kVLCVideoLibraryGridLayout" diff --git a/Sources/Playback/Player/VideoPlayer-iOS/MediaScrubProgressBar.swift b/Sources/Playback/Player/VideoPlayer-iOS/MediaScrubProgressBar.swift index 46e083249..3dea3fb01 100644 --- a/Sources/Playback/Player/VideoPlayer-iOS/MediaScrubProgressBar.swift +++ b/Sources/Playback/Player/VideoPlayer-iOS/MediaScrubProgressBar.swift @@ -417,8 +417,7 @@ fileprivate enum RemainingTimeMode { case remaining static var current: RemainingTimeMode { - let userDefault = UserDefaults.standard - let currentSetting = userDefault.bool(forKey: kVLCShowRemainingTime) + let currentSetting = VLCDefaults.shared.showRemainingTime switch currentSetting { case true: return .remaining @@ -428,8 +427,7 @@ fileprivate enum RemainingTimeMode { @discardableResult static func toggle() -> RemainingTimeMode { - let userDefault = UserDefaults.standard - userDefault.set(!userDefault.bool(forKey: kVLCShowRemainingTime), forKey: kVLCShowRemainingTime) + VLCDefaults.shared.showRemainingTime.toggle() return current } } diff --git a/Sources/Playback/Player/VideoPlayer-iOS/PlayerController.swift b/Sources/Playback/Player/VideoPlayer-iOS/PlayerController.swift index a57146ff7..35ffe295b 100644 --- a/Sources/Playback/Player/VideoPlayer-iOS/PlayerController.swift +++ b/Sources/Playback/Player/VideoPlayer-iOS/PlayerController.swift @@ -41,7 +41,7 @@ class PlayerController: NSObject { // MARK: - UserDefaults computed properties getters var displayRemainingTime: Bool { - return UserDefaults.standard.bool(forKey: kVLCShowRemainingTime) + return VLCDefaults.shared.showRemainingTime } var isVolumeGestureEnabled: Bool { -- GitLab From 8e8a5e0d401f97773775690acf03cc1a8e247add Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Sun, 23 Feb 2025 12:40:18 -0500 Subject: [PATCH 05/97] Convert kVLCPlayerShouldRememberBrightness --- Sources/Headers/VLCConstants.h | 1 - Sources/Helpers/VLCDefaults.swift | 11 +++++++++++ .../Player/VideoPlayer-iOS/PlayerController.swift | 2 +- .../VideoPlayer-iOS/VideoPlayerViewController.swift | 4 ++-- Sources/Settings/Model/SettingsSection.swift | 2 +- 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index 48449e6ae..007005537 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -118,7 +118,6 @@ #define kVLCRestoreLastPlayedMedia @"RestoreLastPlayedMedia" #define kVLCPlayerOpenInMiniPlayer @"OpenInMiniPlayer" -#define kVLCPlayerShouldRememberBrightness @"PlayerShouldRememberBrightness" #define KVLCPlayerBrightness @"playerbrightness" #define kVLCPlayerIsShuffleEnabled @"PlayerIsShuffleEnabled" #define kVLCPlayerIsShuffleEnabledDefaultValue @NO diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index 78f751488..368cad2fa 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -23,6 +23,7 @@ Keys.appThemeBlack: false, Keys.automaticallyPlayNextItem: true, Keys.hideLibraryInFilesApp: false, + Keys.playerShouldRememberBrightness: false, Keys.playerShouldRememberState: true, Keys.showRemainingTime: false, @@ -75,6 +76,15 @@ extension VLCDefaults { } } + @objc var playerShouldRememberBrightness: Bool { + get { + userDefaults.bool(forKey: Keys.playerShouldRememberBrightness) + } + set { + userDefaults.set(newValue, forKey: Keys.playerShouldRememberBrightness) + } + } + @objc var playerShouldRememberState: Bool { get { userDefaults.bool(forKey: Keys.playerShouldRememberState) @@ -133,6 +143,7 @@ fileprivate enum Keys { static let appThemeBlack = "blackTheme" static let automaticallyPlayNextItem = "AutomaticallyPlayNextItem" static let hideLibraryInFilesApp = "HideLibraryInFilesApp" + static let playerShouldRememberBrightness = "PlayerShouldRememberBrightness" static let playerShouldRememberState = "PlayerShouldRememberState" static let defaultPreampLevel = "pre-amp-level" static let showRemainingTime = "show-remaining-time" diff --git a/Sources/Playback/Player/VideoPlayer-iOS/PlayerController.swift b/Sources/Playback/Player/VideoPlayer-iOS/PlayerController.swift index 35ffe295b..905e474c3 100644 --- a/Sources/Playback/Player/VideoPlayer-iOS/PlayerController.swift +++ b/Sources/Playback/Player/VideoPlayer-iOS/PlayerController.swift @@ -83,7 +83,7 @@ class PlayerController: NSObject { } var isRememberBrightnessEnabled: Bool { - return UserDefaults.standard.bool(forKey: kVLCPlayerShouldRememberBrightness) + return VLCDefaults.shared.playerShouldRememberBrightness } @objc override init() { diff --git a/Sources/Playback/Player/VideoPlayer-iOS/VideoPlayerViewController.swift b/Sources/Playback/Player/VideoPlayer-iOS/VideoPlayerViewController.swift index 33dde55a8..45f6a1978 100644 --- a/Sources/Playback/Player/VideoPlayer-iOS/VideoPlayerViewController.swift +++ b/Sources/Playback/Player/VideoPlayer-iOS/VideoPlayerViewController.swift @@ -402,7 +402,7 @@ class VideoPlayerViewController: PlayerViewController { #if os(iOS) let defaults = UserDefaults.standard - if defaults.bool(forKey: kVLCPlayerShouldRememberBrightness) { + if VLCDefaults.shared.playerShouldRememberBrightness { if let brightness = defaults.value(forKey: KVLCPlayerBrightness) as? CGFloat { animateBrightness(to: brightness) self.brightnessControl.value = Float(brightness) @@ -469,7 +469,7 @@ class VideoPlayerViewController: PlayerViewController { deviceMotion.stopDeviceMotion() #if os(iOS) let defaults = UserDefaults.standard - if defaults.bool(forKey: kVLCPlayerShouldRememberBrightness) { + if VLCDefaults.shared.playerShouldRememberBrightness { let currentBrightness = UIScreen.main.brightness self.brightnessControl.value = Float(currentBrightness) // helper in indicating change in the system brightness defaults.set(currentBrightness, forKey: KVLCPlayerBrightness) diff --git a/Sources/Settings/Model/SettingsSection.swift b/Sources/Settings/Model/SettingsSection.swift index 9d19927ba..111e144fe 100644 --- a/Sources/Settings/Model/SettingsSection.swift +++ b/Sources/Settings/Model/SettingsSection.swift @@ -518,7 +518,7 @@ enum VideoOptions { static var rememberPlayerBrightness: SettingsItem { .toggle(title: "SETTINGS_REMEMBER_PLAYER_BRIGHTNESS", subtitle: nil, - preferenceKey: kVLCPlayerShouldRememberBrightness) + keyPath: \.playerShouldRememberBrightness) } static var lockRotation: SettingsItem { -- GitLab From 921f5918d1b2846f0caf51c978a5bb3e65ab1233 Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Sun, 23 Feb 2025 14:13:18 -0500 Subject: [PATCH 06/97] Convert kVLCRestoreLastPlayedMedia --- Sources/App/iOS/VLCAppDelegate.m | 3 +-- Sources/Headers/VLCConstants.h | 1 - Sources/Helpers/VLCDefaults.swift | 11 +++++++++++ Sources/Settings/Model/SettingsSection.swift | 2 +- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Sources/App/iOS/VLCAppDelegate.m b/Sources/App/iOS/VLCAppDelegate.m index 23730e89a..18586299e 100644 --- a/Sources/App/iOS/VLCAppDelegate.m +++ b/Sources/App/iOS/VLCAppDelegate.m @@ -92,7 +92,6 @@ kVLCSettingPlaybackSpeedDefaultValue: @(1.0), kVLCPlayerShowPlaybackSpeedShortcut: @(NO), kVLCSettingAlwaysPlayURLs: @(NO), - kVLCRestoreLastPlayedMedia: @(YES), kVLCSettingPlayerControlDuration: kVLCSettingPlayerControlDurationDefaultValue, kVLCSettingPauseWhenShowingControls: @(NO) }; @@ -325,7 +324,7 @@ - (void)recoverLastPlayingMedia { NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; - if (![defaults boolForKey:kVLCRestoreLastPlayedMedia]) { + if (!VLCDefaults.shared.restoreLastPlayedMedia) { return; } diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index 007005537..a078fcdbf 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -115,7 +115,6 @@ #define kVLCAudioLibraryHideTrackNumbers @"kVLCAudioLibraryHideTrackNumbers" #define kVLCLastPlayedMediaIdentifier @"LastPlayedMediaIdentifier" -#define kVLCRestoreLastPlayedMedia @"RestoreLastPlayedMedia" #define kVLCPlayerOpenInMiniPlayer @"OpenInMiniPlayer" #define KVLCPlayerBrightness @"playerbrightness" diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index 368cad2fa..92ea4a7f7 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -25,6 +25,7 @@ Keys.hideLibraryInFilesApp: false, Keys.playerShouldRememberBrightness: false, Keys.playerShouldRememberState: true, + Keys.restoreLastPlayedMedia: true, Keys.showRemainingTime: false, // numbers @@ -94,6 +95,15 @@ extension VLCDefaults { } } + @objc var restoreLastPlayedMedia: Bool { + get { + userDefaults.bool(forKey: Keys.restoreLastPlayedMedia) + } + set { + userDefaults.set(newValue, forKey: Keys.restoreLastPlayedMedia) + } + } + @objc var defaultPreampLevel: Float { get { userDefaults.float(forKey: Keys.defaultPreampLevel) @@ -145,6 +155,7 @@ fileprivate enum Keys { static let hideLibraryInFilesApp = "HideLibraryInFilesApp" static let playerShouldRememberBrightness = "PlayerShouldRememberBrightness" static let playerShouldRememberState = "PlayerShouldRememberState" + static let restoreLastPlayedMedia = "RestoreLastPlayedMedia" static let defaultPreampLevel = "pre-amp-level" static let showRemainingTime = "show-remaining-time" diff --git a/Sources/Settings/Model/SettingsSection.swift b/Sources/Settings/Model/SettingsSection.swift index 111e144fe..9555fc069 100644 --- a/Sources/Settings/Model/SettingsSection.swift +++ b/Sources/Settings/Model/SettingsSection.swift @@ -275,7 +275,7 @@ enum GenericOptions { static var restoreLastPlayedMedia: SettingsItem { .toggle(title: "SETTINGS_RESTORE_LAST_PLAYED_MEDIA", subtitle: nil, - preferenceKey: kVLCRestoreLastPlayedMedia) + keyPath: \.restoreLastPlayedMedia) } static func section() -> SettingsSection? { -- GitLab From aa0268c44c16bc4e05b1edb53708e82e708fe790 Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Sun, 23 Feb 2025 15:12:26 -0500 Subject: [PATCH 07/97] Re-order existing defaults before continuing. --- Sources/Helpers/VLCDefaults.swift | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index 92ea4a7f7..a7a3e2b9a 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -50,6 +50,9 @@ // MARK: - Defaults extension VLCDefaults { + + // Bools + @objc var appThemeBlack: Bool { get { userDefaults.bool(forKey: Keys.appThemeBlack) @@ -104,24 +107,28 @@ extension VLCDefaults { } } - @objc var defaultPreampLevel: Float { + @objc var showRemainingTime: Bool { get { - userDefaults.float(forKey: Keys.defaultPreampLevel) + userDefaults.bool(forKey: Keys.showRemainingTime) } set { - userDefaults.set(newValue, forKey: Keys.defaultPreampLevel) + userDefaults.set(newValue, forKey: Keys.showRemainingTime) } } - @objc var showRemainingTime: Bool { + // Numbers + + @objc var defaultPreampLevel: Float { get { - userDefaults.bool(forKey: Keys.showRemainingTime) + userDefaults.float(forKey: Keys.defaultPreampLevel) } set { - userDefaults.set(newValue, forKey: Keys.showRemainingTime) + userDefaults.set(newValue, forKey: Keys.defaultPreampLevel) } } + // Other + func videoLibraryGridLayout(collectionModelName: String? = nil, name: String) -> Bool { userDefaults.bool(forKey: Keys.videoLibraryGridLayout(collectionModelName: collectionModelName, name: name)) } @@ -152,18 +159,16 @@ extension VLCDefaults { fileprivate enum Keys { static let appThemeBlack = "blackTheme" static let automaticallyPlayNextItem = "AutomaticallyPlayNextItem" + static let defaultPreampLevel = "pre-amp-level" static let hideLibraryInFilesApp = "HideLibraryInFilesApp" static let playerShouldRememberBrightness = "PlayerShouldRememberBrightness" static let playerShouldRememberState = "PlayerShouldRememberState" static let restoreLastPlayedMedia = "RestoreLastPlayedMedia" - static let defaultPreampLevel = "pre-amp-level" static let showRemainingTime = "show-remaining-time" - static let videoLibraryGridLayoutPrefix = "kVLCVideoLibraryGridLayout" - static func videoLibraryGridLayout(collectionModelName: String? = nil, name: String) -> String { [ - Self.videoLibraryGridLayoutPrefix, collectionModelName, name + "kVLCVideoLibraryGridLayout", collectionModelName, name ].compactMap { $0 }.joined() } } -- GitLab From 68ad0ef12789246528e289941357d51cac6de72f Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Sun, 23 Feb 2025 15:18:01 -0500 Subject: [PATCH 08/97] Convert kVLCSettingEnableMediaCellTextScrolling --- Sources/App/iOS/VLCAppDelegate.m | 1 - Sources/Headers/VLCConstants.h | 1 - Sources/Helpers/VLCDefaults.swift | 11 +++++++++++ .../MediaCategoryCells/MediaCollectionViewCell.swift | 2 +- .../MediaCategoryCells/MediaGridCollectionCell.swift | 2 +- Sources/Settings/Model/SettingsSection.swift | 2 +- 6 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Sources/App/iOS/VLCAppDelegate.m b/Sources/App/iOS/VLCAppDelegate.m index 18586299e..4b76356c3 100644 --- a/Sources/App/iOS/VLCAppDelegate.m +++ b/Sources/App/iOS/VLCAppDelegate.m @@ -80,7 +80,6 @@ kVLCSettingPlaybackRemoteControlSkip : @(NO), kVLCSettingOpenAppForPlayback : kVLCSettingOpenAppForPlaybackDefaultValue, kVLCPlaylistPlayNextItem: @(YES), - kVLCSettingEnableMediaCellTextScrolling : @(NO), kVLCSettingShowThumbnails : kVLCSettingShowThumbnailsDefaultValue, kVLCSettingShowArtworks : kVLCSettingShowArtworksDefaultValue, kVLCSettingBackupMediaLibrary : kVLCSettingBackupMediaLibraryDefaultValue, diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index a078fcdbf..d9ec86095 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -24,7 +24,6 @@ #define kVLCLastPlayedPlaylist @"LastPlayedPlaylist" #define kVLCIsCurrentlyPlayingPlaylist @"isPlaylistCurrentlyPlaying" #define kVLCCurrentPlaylistMediasQueue @"currentPlaylistMediasQueue" -#define kVLCSettingEnableMediaCellTextScrolling @"EnableMediaCellTextScrolling" #define kVLCSettingContinueAudioInBackgroundKey @"BackgroundAudioPlayback" #define kVLCSettingStretchAudio @"audio-time-stretch" #define kVLCSettingTextEncoding @"subsdec-encoding" diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index a7a3e2b9a..d8c672deb 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -22,6 +22,7 @@ // bools Keys.appThemeBlack: false, Keys.automaticallyPlayNextItem: true, + Keys.enableMediaCellTextScrolling: false, Keys.hideLibraryInFilesApp: false, Keys.playerShouldRememberBrightness: false, Keys.playerShouldRememberState: true, @@ -71,6 +72,15 @@ extension VLCDefaults { } } + @objc var enableMediaCellTextScrolling: Bool { + get { + userDefaults.bool(forKey: Keys.enableMediaCellTextScrolling) + } + set { + userDefaults.set(newValue, forKey: Keys.enableMediaCellTextScrolling) + } + } + @objc var hideLibraryInFilesApp: Bool { get { userDefaults.bool(forKey: Keys.hideLibraryInFilesApp) @@ -160,6 +170,7 @@ fileprivate enum Keys { static let appThemeBlack = "blackTheme" static let automaticallyPlayNextItem = "AutomaticallyPlayNextItem" static let defaultPreampLevel = "pre-amp-level" + static let enableMediaCellTextScrolling = "EnableMediaCellTextScrolling" static let hideLibraryInFilesApp = "HideLibraryInFilesApp" static let playerShouldRememberBrightness = "PlayerShouldRememberBrightness" static let playerShouldRememberState = "PlayerShouldRememberState" diff --git a/Sources/Media Library/MediaCategoryCells/MediaCollectionViewCell.swift b/Sources/Media Library/MediaCategoryCells/MediaCollectionViewCell.swift index ebf09f30f..63d5fb35f 100644 --- a/Sources/Media Library/MediaCategoryCells/MediaCollectionViewCell.swift +++ b/Sources/Media Library/MediaCategoryCells/MediaCollectionViewCell.swift @@ -106,7 +106,7 @@ class MediaCollectionViewCell: BaseCollectionViewCell, UIScrollViewDelegate { } private var enableMarquee: Bool { - return !UserDefaults.standard.bool(forKey: kVLCSettingEnableMediaCellTextScrolling) + return !VLCDefaults.shared.enableMediaCellTextScrolling } // MARK: - Init diff --git a/Sources/Media Library/MediaCategoryCells/MediaGridCollectionCell.swift b/Sources/Media Library/MediaCategoryCells/MediaGridCollectionCell.swift index b77ae39e5..6c074ea1d 100644 --- a/Sources/Media Library/MediaCategoryCells/MediaGridCollectionCell.swift +++ b/Sources/Media Library/MediaCategoryCells/MediaGridCollectionCell.swift @@ -146,7 +146,7 @@ class MediaGridCollectionCell: BaseCollectionViewCell { } private var enableMarquee: Bool { - return !userDefaults.bool(forKey: kVLCSettingEnableMediaCellTextScrolling) + return !VLCDefaults.shared.enableMediaCellTextScrolling } override init(frame: CGRect) { diff --git a/Sources/Settings/Model/SettingsSection.swift b/Sources/Settings/Model/SettingsSection.swift index 9555fc069..aea03b61d 100644 --- a/Sources/Settings/Model/SettingsSection.swift +++ b/Sources/Settings/Model/SettingsSection.swift @@ -263,7 +263,7 @@ enum GenericOptions { static var enableTextScrollingInMediaList: SettingsItem { .toggle(title: "SETTINGS_ENABLE_MEDIA_CELL_TEXT_SCROLLING", subtitle: nil, - preferenceKey: kVLCSettingEnableMediaCellTextScrolling) + keyPath: \.enableMediaCellTextScrolling) } static var rememberPlayerState: SettingsItem { -- GitLab From d19464e7828503ac8b413e074434eb92c1ebe57a Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Sun, 23 Feb 2025 15:23:05 -0500 Subject: [PATCH 09/97] Convert kVLCPlaylistPlayNextItem --- Sources/App/iOS/VLCAppDelegate.m | 1 - Sources/Headers/VLCConstants.h | 1 - Sources/Helpers/VLCDefaults.swift | 11 +++++++++++ .../MediaCategories/MediaCategoryViewController.swift | 2 +- Sources/Settings/Controller/SettingsController.swift | 2 +- Sources/Settings/Model/ActionSheetSpecifier.swift | 2 +- 6 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Sources/App/iOS/VLCAppDelegate.m b/Sources/App/iOS/VLCAppDelegate.m index 4b76356c3..1eaac2f6b 100644 --- a/Sources/App/iOS/VLCAppDelegate.m +++ b/Sources/App/iOS/VLCAppDelegate.m @@ -79,7 +79,6 @@ kVLCSettingPlaybackLockscreenSkip : @(NO), kVLCSettingPlaybackRemoteControlSkip : @(NO), kVLCSettingOpenAppForPlayback : kVLCSettingOpenAppForPlaybackDefaultValue, - kVLCPlaylistPlayNextItem: @(YES), kVLCSettingShowThumbnails : kVLCSettingShowThumbnailsDefaultValue, kVLCSettingShowArtworks : kVLCSettingShowArtworksDefaultValue, kVLCSettingBackupMediaLibrary : kVLCSettingBackupMediaLibraryDefaultValue, diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index d9ec86095..08133310d 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -20,7 +20,6 @@ #define kVLCSettingAppThemeSystem 2 #define kVLCOptimizeItemNamesForDisplay @"MLDecrapifyTitles" #define kVLCSettingAbout @"about" -#define kVLCPlaylistPlayNextItem @"PlaylistPlayNextItem" #define kVLCLastPlayedPlaylist @"LastPlayedPlaylist" #define kVLCIsCurrentlyPlayingPlaylist @"isPlaylistCurrentlyPlaying" #define kVLCCurrentPlaylistMediasQueue @"currentPlaylistMediasQueue" diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index d8c672deb..db0cf1b44 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -26,6 +26,7 @@ Keys.hideLibraryInFilesApp: false, Keys.playerShouldRememberBrightness: false, Keys.playerShouldRememberState: true, + Keys.playlistPlayNextItem: true, Keys.restoreLastPlayedMedia: true, Keys.showRemainingTime: false, @@ -108,6 +109,15 @@ extension VLCDefaults { } } + @objc var playlistPlayNextItem: Bool { + get { + userDefaults.bool(forKey: Keys.playlistPlayNextItem) + } + set { + userDefaults.set(newValue, forKey: Keys.playlistPlayNextItem) + } + } + @objc var restoreLastPlayedMedia: Bool { get { userDefaults.bool(forKey: Keys.restoreLastPlayedMedia) @@ -174,6 +184,7 @@ fileprivate enum Keys { static let hideLibraryInFilesApp = "HideLibraryInFilesApp" static let playerShouldRememberBrightness = "PlayerShouldRememberBrightness" static let playerShouldRememberState = "PlayerShouldRememberState" + static let playlistPlayNextItem = "PlaylistPlayNextItem" static let restoreLastPlayedMedia = "RestoreLastPlayedMedia" static let showRemainingTime = "show-remaining-time" diff --git a/Sources/Media Library/MediaCategories/MediaCategoryViewController.swift b/Sources/Media Library/MediaCategories/MediaCategoryViewController.swift index 42514c4d5..bf417ba96 100644 --- a/Sources/Media Library/MediaCategories/MediaCategoryViewController.swift +++ b/Sources/Media Library/MediaCategories/MediaCategoryViewController.swift @@ -1793,7 +1793,7 @@ extension MediaCategoryViewController { if let model = model as? CollectionModel, model.mediaCollection is VLCMLPlaylist { - autoPlayNextItem = userDefaults.bool(forKey: kVLCPlaylistPlayNextItem) + autoPlayNextItem = VLCDefaults.shared.playlistPlayNextItem } if !autoPlayNextItem { diff --git a/Sources/Settings/Controller/SettingsController.swift b/Sources/Settings/Controller/SettingsController.swift index 653f413f1..6c275775f 100644 --- a/Sources/Settings/Controller/SettingsController.swift +++ b/Sources/Settings/Controller/SettingsController.swift @@ -515,7 +515,7 @@ extension SettingsController: ActionSheetSpecifierDelegate { case .playNextItem: VLCDefaults.shared.automaticallyPlayNextItem = state case .playlistPlayNextItem: - userDefaults.setValue(state, forKey: kVLCPlaylistPlayNextItem) + VLCDefaults.shared.playlistPlayNextItem = state default: break } diff --git a/Sources/Settings/Model/ActionSheetSpecifier.swift b/Sources/Settings/Model/ActionSheetSpecifier.swift index 3fb840895..9d59fb1e9 100644 --- a/Sources/Settings/Model/ActionSheetSpecifier.swift +++ b/Sources/Settings/Model/ActionSheetSpecifier.swift @@ -148,7 +148,7 @@ extension ActionSheetSpecifier: ActionSheetDataSource { if isFirstRow { cell.setToggleSwitch(state: VLCDefaults.shared.automaticallyPlayNextItem) } else { - cell.setToggleSwitch(state: userDefaults.bool(forKey: kVLCPlaylistPlayNextItem)) + cell.setToggleSwitch(state: VLCDefaults.shared.playlistPlayNextItem) } let cellIdentifier: ActionSheetCellIdentifier = isFirstRow ? .playNextItem : .playlistPlayNextItem -- GitLab From 05a32981b2a9d3687a55bd7ac5360691e9c10ede Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Sun, 23 Feb 2025 18:59:34 -0500 Subject: [PATCH 10/97] Convert kVLCSettingHardwareDecoding --- Sources/About/AboutController.swift | 2 +- Sources/App/iOS/VLCAppDelegate.m | 1 - Sources/App/tvOS/AppleTVAppDelegate.m | 1 - Sources/Headers/VLCConstants.h | 2 -- Sources/Headers/VLCTVConstants.h | 2 -- Sources/Helpers/VLCDefaults.swift | 33 +++++++++++++++++-- Sources/Playback/Control/VLCPlaybackService.m | 3 +- Sources/Settings/Model/SettingsSection.swift | 2 +- 8 files changed, 35 insertions(+), 11 deletions(-) diff --git a/Sources/About/AboutController.swift b/Sources/About/AboutController.swift index 3072c947a..866719e29 100644 --- a/Sources/About/AboutController.swift +++ b/Sources/About/AboutController.swift @@ -192,7 +192,7 @@ class AboutController: UIViewController, MFMailComposeViewControllerDelegate, UI locale.regionCode!, bundleShortVersionString, VLCLibrary.shared().changeset, - defaults.integer(forKey: kVLCSettingHardwareDecoding), + VLCDefaults.shared.hardwareDecoding == .hardware ? 0 : 1, defaults.integer(forKey: kVLCSettingNetworkCaching), defaults.integer(forKey: kVLCSettingSkipLoopFilter), defaults.integer(forKey: kVLCSettingNetworkRTSPTCP), diff --git a/Sources/App/iOS/VLCAppDelegate.m b/Sources/App/iOS/VLCAppDelegate.m index 1eaac2f6b..13a875f06 100644 --- a/Sources/App/iOS/VLCAppDelegate.m +++ b/Sources/App/iOS/VLCAppDelegate.m @@ -54,7 +54,6 @@ kVLCSettingSubtitlesFontSize : kVLCSettingSubtitlesFontSizeDefaultValue, kVLCSettingSubtitlesBoldFont: kVLCSettingSubtitlesBoldFontDefaultValue, kVLCSettingDeinterlace : kVLCSettingDeinterlaceDefaultValue, - kVLCSettingHardwareDecoding : kVLCSettingHardwareDecodingDefault, kVLCSettingNetworkCaching : kVLCSettingNetworkCachingDefaultValue, kVLCSettingVolumeGesture : @(YES), kVLCSettingPlayPauseGesture : @(YES), diff --git a/Sources/App/tvOS/AppleTVAppDelegate.m b/Sources/App/tvOS/AppleTVAppDelegate.m index f27344108..23f8c8bdd 100644 --- a/Sources/App/tvOS/AppleTVAppDelegate.m +++ b/Sources/App/tvOS/AppleTVAppDelegate.m @@ -49,7 +49,6 @@ kVLCSettingSubtitlesFontSize : kVLCSettingSubtitlesFontSizeDefaultValue, kVLCSettingSubtitlesBoldFont: kVLCSettingSubtitlesBoldFontDefaultValue, kVLCSettingDeinterlace : kVLCSettingDeinterlaceDefaultValue, - kVLCSettingHardwareDecoding : kVLCSettingHardwareDecodingDefault, kVLCSettingNetworkCaching : kVLCSettingNetworkCachingDefaultValue, kVLCSettingNetworkRTSPTCP : @(NO), kVLCSettingNetworkSatIPChannelListUrl : @"", diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index 08133310d..5b0d243e3 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -43,8 +43,6 @@ #define kVLCSubtitlesCacheFolderName @"cached-subtitles" #define kVLCSettingDeinterlace @"deinterlace" #define kVLCSettingDeinterlaceDefaultValue @(-1) -#define kVLCSettingHardwareDecoding @"codec" -#define kVLCSettingHardwareDecodingDefault @"" #define kVLCSettingRotationLock @"kVLCSettingRotationLock" #define kVLCSettingNetworkCaching @"network-caching" #define kVLCSettingNetworkCachingDefaultValue @(999) diff --git a/Sources/Headers/VLCTVConstants.h b/Sources/Headers/VLCTVConstants.h index ab6f3850c..2419b2cd4 100644 --- a/Sources/Headers/VLCTVConstants.h +++ b/Sources/Headers/VLCTVConstants.h @@ -39,8 +39,6 @@ #define kVLCSettingSkipLoopFilterNonKey @(3) #define kVLCSettingDeinterlace @"deinterlace" #define kVLCSettingDeinterlaceDefaultValue @(-1) -#define kVLCSettingHardwareDecoding @"codec" -#define kVLCSettingHardwareDecodingDefault @"" #define kVLCSettingSubtitlesFont @"quartztext-font" #define kVLCSettingSubtitlesFontDefaultValue @"HelveticaNeue" #define kVLCSettingSubtitlesFontSize @"quartztext-rel-fontsize" diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index db0cf1b44..007d29af6 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -31,7 +31,10 @@ Keys.showRemainingTime: false, // numbers - Keys.defaultPreampLevel: Float(6) + Keys.defaultPreampLevel: Float(6), + + // other + Keys.hardwareDecoding: HardwareDecoding.hardware.rawValue ] [ @@ -82,6 +85,23 @@ extension VLCDefaults { } } + var hardwareDecoding: HardwareDecoding { + get { + guard let v = userDefaults.string(forKey: Keys.hardwareDecoding) else { + return HardwareDecoding.hardware + } + + return HardwareDecoding(rawValue: v) ?? .hardware + } + set { + userDefaults.set(newValue.rawValue, forKey: Keys.hardwareDecoding) + } + } + + @objc var hardwareDecodingObjC: String { + hardwareDecoding.rawValue + } + @objc var hideLibraryInFilesApp: Bool { get { userDefaults.bool(forKey: Keys.hideLibraryInFilesApp) @@ -165,8 +185,9 @@ extension VLCDefaults { @objc(VLCDefaultsCompat) final class Compat: NSObject { static let automaticallyPlayNextItemKey: String = Keys.automaticallyPlayNextItem - static let hideLibraryInFilesAppKey: String = Keys.hideLibraryInFilesApp static let defaultPreampLevelKey: String = Keys.defaultPreampLevel + @objc static let hardwareDecodingKey: String = Keys.hardwareDecoding + static let hideLibraryInFilesAppKey: String = Keys.hideLibraryInFilesApp override init() { fatalError("compat struct not intended to be instantiated") @@ -174,6 +195,13 @@ extension VLCDefaults { } } +extension VLCDefaults { + enum HardwareDecoding: String { + case software = "avcodec,all" + case hardware = "" + } +} + // MARK: - Keys fileprivate enum Keys { @@ -181,6 +209,7 @@ fileprivate enum Keys { static let automaticallyPlayNextItem = "AutomaticallyPlayNextItem" static let defaultPreampLevel = "pre-amp-level" static let enableMediaCellTextScrolling = "EnableMediaCellTextScrolling" + static let hardwareDecoding = "codec" static let hideLibraryInFilesApp = "HideLibraryInFilesApp" static let playerShouldRememberBrightness = "PlayerShouldRememberBrightness" static let playerShouldRememberState = "PlayerShouldRememberState" diff --git a/Sources/Playback/Control/VLCPlaybackService.m b/Sources/Playback/Control/VLCPlaybackService.m index cf657d5a9..13ed2ddea 100644 --- a/Sources/Playback/Control/VLCPlaybackService.m +++ b/Sources/Playback/Control/VLCPlaybackService.m @@ -1778,10 +1778,11 @@ NSString *const VLCLastPlaylistPlayedMedia = @"LastPlaylistPlayedMedia"; - (NSDictionary *)mediaOptionsDictionary { NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; + NSString *codecKey = VLCDefaultsCompat.hardwareDecodingKey; return @{ kVLCSettingNetworkCaching : [defaults objectForKey:kVLCSettingNetworkCaching], kVLCSettingTextEncoding : [defaults objectForKey:kVLCSettingTextEncoding], kVLCSettingSkipLoopFilter : [defaults objectForKey:kVLCSettingSkipLoopFilter], - kVLCSettingHardwareDecoding : [defaults objectForKey:kVLCSettingHardwareDecoding], + codecKey : VLCDefaults.shared.hardwareDecodingObjC, kVLCSettingNetworkRTSPTCP : [defaults objectForKey:kVLCSettingNetworkRTSPTCP] }; } diff --git a/Sources/Settings/Model/SettingsSection.swift b/Sources/Settings/Model/SettingsSection.swift index aea03b61d..1bcd46c8a 100644 --- a/Sources/Settings/Model/SettingsSection.swift +++ b/Sources/Settings/Model/SettingsSection.swift @@ -509,7 +509,7 @@ enum VideoOptions { } static var hardwareDecoding: SettingsItem { - let k = kVLCSettingHardwareDecoding + let k = VLCDefaults.Compat.hardwareDecodingKey return .init(title: "SETTINGS_HWDECODING", subtitle: Localizer.getSubtitle(for: k), action: .showActionSheet(title: "SETTINGS_HWDECODING", preferenceKey: k, hasInfo: true)) -- GitLab From cab7563ae7a4d14fbdb02e25045a31b94dc385a9 Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Sun, 23 Feb 2025 19:18:02 -0500 Subject: [PATCH 11/97] Convert kVLCSettingNetworkCaching --- Sources/About/AboutController.swift | 4 +- Sources/App/iOS/VLCAppDelegate.m | 1 - Sources/App/tvOS/AppleTVAppDelegate.m | 1 - Sources/Headers/VLCConstants.h | 2 - Sources/Headers/VLCTVConstants.h | 2 - Sources/Helpers/VLCDefaults.swift | 65 ++++++++++++++----- Sources/Playback/Control/VLCPlaybackService.m | 5 +- Sources/Settings/Model/SettingsSection.swift | 2 +- 8 files changed, 54 insertions(+), 28 deletions(-) diff --git a/Sources/About/AboutController.swift b/Sources/About/AboutController.swift index 866719e29..ac7592252 100644 --- a/Sources/About/AboutController.swift +++ b/Sources/About/AboutController.swift @@ -192,8 +192,8 @@ class AboutController: UIViewController, MFMailComposeViewControllerDelegate, UI locale.regionCode!, bundleShortVersionString, VLCLibrary.shared().changeset, - VLCDefaults.shared.hardwareDecoding == .hardware ? 0 : 1, - defaults.integer(forKey: kVLCSettingNetworkCaching), + VLCDefaults.shared.hardwareDecoding == .hardware ? 0 : 1, // TODO: unsure + VLCDefaults.shared.networkCaching.rawValue, defaults.integer(forKey: kVLCSettingSkipLoopFilter), defaults.integer(forKey: kVLCSettingNetworkRTSPTCP), defaults.integer(forKey: kVLCSettingStretchAudio)) diff --git a/Sources/App/iOS/VLCAppDelegate.m b/Sources/App/iOS/VLCAppDelegate.m index 13a875f06..7e4b8014e 100644 --- a/Sources/App/iOS/VLCAppDelegate.m +++ b/Sources/App/iOS/VLCAppDelegate.m @@ -54,7 +54,6 @@ kVLCSettingSubtitlesFontSize : kVLCSettingSubtitlesFontSizeDefaultValue, kVLCSettingSubtitlesBoldFont: kVLCSettingSubtitlesBoldFontDefaultValue, kVLCSettingDeinterlace : kVLCSettingDeinterlaceDefaultValue, - kVLCSettingNetworkCaching : kVLCSettingNetworkCachingDefaultValue, kVLCSettingVolumeGesture : @(YES), kVLCSettingPlayPauseGesture : @(YES), kVLCSettingBrightnessGesture : @(YES), diff --git a/Sources/App/tvOS/AppleTVAppDelegate.m b/Sources/App/tvOS/AppleTVAppDelegate.m index 23f8c8bdd..fa646694d 100644 --- a/Sources/App/tvOS/AppleTVAppDelegate.m +++ b/Sources/App/tvOS/AppleTVAppDelegate.m @@ -49,7 +49,6 @@ kVLCSettingSubtitlesFontSize : kVLCSettingSubtitlesFontSizeDefaultValue, kVLCSettingSubtitlesBoldFont: kVLCSettingSubtitlesBoldFontDefaultValue, kVLCSettingDeinterlace : kVLCSettingDeinterlaceDefaultValue, - kVLCSettingNetworkCaching : kVLCSettingNetworkCachingDefaultValue, kVLCSettingNetworkRTSPTCP : @(NO), kVLCSettingNetworkSatIPChannelListUrl : @"", kVLCSettingEqualizerProfileDisabled : @(YES), diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index 5b0d243e3..bb4517d71 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -44,8 +44,6 @@ #define kVLCSettingDeinterlace @"deinterlace" #define kVLCSettingDeinterlaceDefaultValue @(-1) #define kVLCSettingRotationLock @"kVLCSettingRotationLock" -#define kVLCSettingNetworkCaching @"network-caching" -#define kVLCSettingNetworkCachingDefaultValue @(999) #define kVLCSettingNetworkRTSPTCP @"rtsp-tcp" #define kVLCSaveDebugLogs @"kVLCSaveDebugLogs" #define kVLCSettingNetworkSatIPChannelList @"satip-channelist" diff --git a/Sources/Headers/VLCTVConstants.h b/Sources/Headers/VLCTVConstants.h index 2419b2cd4..92fc0705b 100644 --- a/Sources/Headers/VLCTVConstants.h +++ b/Sources/Headers/VLCTVConstants.h @@ -26,8 +26,6 @@ #define kSupportedProtocolSchemes @"(rtsp|mms|mmsh|udp|rtp|rtmp|sftp|ftp|smb)$" #define kVLCSettingPlaybackSpeedDefaultValue @"playback-speed" -#define kVLCSettingNetworkCaching @"network-caching" -#define kVLCSettingNetworkCachingDefaultValue @(999) #define kVLCSettingNetworkRTSPTCP @"rtsp-tcp" #define kVLCSaveDebugLogs @"kVLCSaveDebugLogs" #define kVLCSettingNetworkSatIPChannelList @"satip-channelist" diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index 007d29af6..9057447fe 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -34,7 +34,8 @@ Keys.defaultPreampLevel: Float(6), // other - Keys.hardwareDecoding: HardwareDecoding.hardware.rawValue + Keys.hardwareDecoding: HardwareDecoding.hardware.rawValue, + Keys.networkCaching: NetworkCaching.normal.rawValue, ] [ @@ -85,23 +86,6 @@ extension VLCDefaults { } } - var hardwareDecoding: HardwareDecoding { - get { - guard let v = userDefaults.string(forKey: Keys.hardwareDecoding) else { - return HardwareDecoding.hardware - } - - return HardwareDecoding(rawValue: v) ?? .hardware - } - set { - userDefaults.set(newValue.rawValue, forKey: Keys.hardwareDecoding) - } - } - - @objc var hardwareDecodingObjC: String { - hardwareDecoding.rawValue - } - @objc var hideLibraryInFilesApp: Bool { get { userDefaults.bool(forKey: Keys.hideLibraryInFilesApp) @@ -169,6 +153,37 @@ extension VLCDefaults { // Other + var hardwareDecoding: HardwareDecoding { + get { + guard let v = userDefaults.string(forKey: Keys.hardwareDecoding) else { + return HardwareDecoding.hardware + } + + return HardwareDecoding(rawValue: v) ?? .hardware + } + set { + userDefaults.set(newValue.rawValue, forKey: Keys.hardwareDecoding) + } + } + + @objc var hardwareDecodingObjC: String { + hardwareDecoding.rawValue + } + + var networkCaching: NetworkCaching { + get { + let v = userDefaults.integer(forKey: Keys.networkCaching) + return NetworkCaching(rawValue: v) ?? .normal + } + set { + userDefaults.set(newValue.rawValue, forKey: Keys.networkCaching) + } + } + + @objc var networkCachingObjC: Int { + networkCaching.rawValue + } + func videoLibraryGridLayout(collectionModelName: String? = nil, name: String) -> Bool { userDefaults.bool(forKey: Keys.videoLibraryGridLayout(collectionModelName: collectionModelName, name: name)) } @@ -188,6 +203,7 @@ extension VLCDefaults { static let defaultPreampLevelKey: String = Keys.defaultPreampLevel @objc static let hardwareDecodingKey: String = Keys.hardwareDecoding static let hideLibraryInFilesAppKey: String = Keys.hideLibraryInFilesApp + @objc static let networkCachingKey: String = Keys.networkCaching override init() { fatalError("compat struct not intended to be instantiated") @@ -195,6 +211,8 @@ extension VLCDefaults { } } +// MARK: - Value Types + extension VLCDefaults { enum HardwareDecoding: String { case software = "avcodec,all" @@ -202,6 +220,16 @@ extension VLCDefaults { } } +extension VLCDefaults { + enum NetworkCaching: Int { + case lowest = 333 + case low = 666 + case normal = 999 + case high = 1667 + case highest = 3333 + } +} + // MARK: - Keys fileprivate enum Keys { @@ -211,6 +239,7 @@ fileprivate enum Keys { static let enableMediaCellTextScrolling = "EnableMediaCellTextScrolling" static let hardwareDecoding = "codec" static let hideLibraryInFilesApp = "HideLibraryInFilesApp" + static let networkCaching = "network-caching" static let playerShouldRememberBrightness = "PlayerShouldRememberBrightness" static let playerShouldRememberState = "PlayerShouldRememberState" static let playlistPlayNextItem = "PlaylistPlayNextItem" diff --git a/Sources/Playback/Control/VLCPlaybackService.m b/Sources/Playback/Control/VLCPlaybackService.m index 13ed2ddea..1e5ee9886 100644 --- a/Sources/Playback/Control/VLCPlaybackService.m +++ b/Sources/Playback/Control/VLCPlaybackService.m @@ -1778,8 +1778,11 @@ NSString *const VLCLastPlaylistPlayedMedia = @"LastPlaylistPlayedMedia"; - (NSDictionary *)mediaOptionsDictionary { NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; + NSString *codecKey = VLCDefaultsCompat.hardwareDecodingKey; - return @{ kVLCSettingNetworkCaching : [defaults objectForKey:kVLCSettingNetworkCaching], + NSString *networkCachingKey = VLCDefaultsCompat.networkCachingKey; + + return @{ networkCachingKey : [NSNumber numberWithInteger: VLCDefaults.shared.networkCachingObjC], kVLCSettingTextEncoding : [defaults objectForKey:kVLCSettingTextEncoding], kVLCSettingSkipLoopFilter : [defaults objectForKey:kVLCSettingSkipLoopFilter], codecKey : VLCDefaults.shared.hardwareDecodingObjC, diff --git a/Sources/Settings/Model/SettingsSection.swift b/Sources/Settings/Model/SettingsSection.swift index 1bcd46c8a..d37ef488e 100644 --- a/Sources/Settings/Model/SettingsSection.swift +++ b/Sources/Settings/Model/SettingsSection.swift @@ -715,7 +715,7 @@ enum MediaLibraryOptions { enum NetworkOptions { static var networkCachingLevel: SettingsItem { - let k = kVLCSettingNetworkCaching + let k = VLCDefaults.Compat.networkCachingKey return .init(title: "SETTINGS_NETWORK_CACHING_TITLE", subtitle: Localizer.getSubtitle(for: k), action: .showActionSheet(title: "SETTINGS_NETWORK_CACHING_TITLE", preferenceKey: k, hasInfo: true)) -- GitLab From eba6b4bce4f2cec37ab2980040f0065ffeb8d9cc Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Sun, 23 Feb 2025 19:31:01 -0500 Subject: [PATCH 12/97] Convert kVLCSettingStretchAudio --- Sources/About/AboutController.swift | 2 +- Sources/App/iOS/VLCAppDelegate.m | 1 - Sources/App/tvOS/AppleTVAppDelegate.m | 1 - Sources/Headers/VLCConstants.h | 1 - Sources/Headers/VLCTVConstants.h | 3 --- Sources/Helpers/VLCDefaults.swift | 12 ++++++++++++ Sources/Playback/Control/VLCPlaybackService.m | 4 ++-- Sources/Settings/Model/SettingsSection.swift | 2 +- 8 files changed, 16 insertions(+), 10 deletions(-) diff --git a/Sources/About/AboutController.swift b/Sources/About/AboutController.swift index ac7592252..41c352cb8 100644 --- a/Sources/About/AboutController.swift +++ b/Sources/About/AboutController.swift @@ -196,7 +196,7 @@ class AboutController: UIViewController, MFMailComposeViewControllerDelegate, UI VLCDefaults.shared.networkCaching.rawValue, defaults.integer(forKey: kVLCSettingSkipLoopFilter), defaults.integer(forKey: kVLCSettingNetworkRTSPTCP), - defaults.integer(forKey: kVLCSettingStretchAudio)) + VLCDefaults.shared.stretchAudio ? 1 : 0) // TODO: unsure return prefilledFeedback } diff --git a/Sources/App/iOS/VLCAppDelegate.m b/Sources/App/iOS/VLCAppDelegate.m index 7e4b8014e..0dd0ea96a 100644 --- a/Sources/App/iOS/VLCAppDelegate.m +++ b/Sources/App/iOS/VLCAppDelegate.m @@ -46,7 +46,6 @@ NSDictionary *appDefaults = @{kVLCSettingAppTheme : @(appThemeIndex), kVLCSettingPasscodeEnableBiometricAuth : @(1), kVLCSettingContinueAudioInBackgroundKey : @(YES), - kVLCSettingStretchAudio : @(YES), kVLCSettingTextEncoding : kVLCSettingTextEncodingDefaultValue, kVLCSettingSkipLoopFilter : kVLCSettingSkipLoopFilterNonRef, kVLCSettingSubtitlesFont : kVLCSettingSubtitlesFontDefaultValue, diff --git a/Sources/App/tvOS/AppleTVAppDelegate.m b/Sources/App/tvOS/AppleTVAppDelegate.m index fa646694d..adb06c5ef 100644 --- a/Sources/App/tvOS/AppleTVAppDelegate.m +++ b/Sources/App/tvOS/AppleTVAppDelegate.m @@ -41,7 +41,6 @@ NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; NSDictionary *appDefaults = @{kVLCSettingContinueAudioInBackgroundKey : @(YES), - kVLCSettingStretchAudio : @(YES), kVLCSettingTextEncoding : kVLCSettingTextEncodingDefaultValue, kVLCSettingSkipLoopFilter : kVLCSettingSkipLoopFilterNonRef, kVLCSettingSubtitlesFont : kVLCSettingSubtitlesFontDefaultValue, diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index bb4517d71..c1dd0e90b 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -24,7 +24,6 @@ #define kVLCIsCurrentlyPlayingPlaylist @"isPlaylistCurrentlyPlaying" #define kVLCCurrentPlaylistMediasQueue @"currentPlaylistMediasQueue" #define kVLCSettingContinueAudioInBackgroundKey @"BackgroundAudioPlayback" -#define kVLCSettingStretchAudio @"audio-time-stretch" #define kVLCSettingTextEncoding @"subsdec-encoding" #define kVLCSettingTextEncodingDefaultValue @"Windows-1252" #define kVLCSettingSkipLoopFilter @"avcodec-skiploopfilter" diff --git a/Sources/Headers/VLCTVConstants.h b/Sources/Headers/VLCTVConstants.h index 92fc0705b..44e5f215e 100644 --- a/Sources/Headers/VLCTVConstants.h +++ b/Sources/Headers/VLCTVConstants.h @@ -48,9 +48,6 @@ #define kVLCSubtitlesCacheFolderName @"cached-subtitles" #define kVLCSettingTextEncoding @"subsdec-encoding" #define kVLCSettingTextEncodingDefaultValue @"Windows-1252" -#define kVLCSettingStretchAudio @"audio-time-stretch" -#define kVLCSettingStretchAudioOnValue @"1" -#define kVLCSettingStretchAudioOffValue @"0" #define kVLCSettingContinueAudioInBackgroundKey @"BackgroundAudioPlayback" #define kVLCSettingSubtitlesFilePath @"sub-file" #define kVLCSettingEqualizerProfile @"EqualizerProfile" diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index 9057447fe..06332d782 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -29,6 +29,7 @@ Keys.playlistPlayNextItem: true, Keys.restoreLastPlayedMedia: true, Keys.showRemainingTime: false, + Keys.stretchAudio: true, // numbers Keys.defaultPreampLevel: Float(6), @@ -140,6 +141,15 @@ extension VLCDefaults { } } + @objc var stretchAudio: Bool { + get { + userDefaults.bool(forKey: Keys.stretchAudio) + } + set { + userDefaults.set(newValue, forKey: Keys.stretchAudio) + } + } + // Numbers @objc var defaultPreampLevel: Float { @@ -204,6 +214,7 @@ extension VLCDefaults { @objc static let hardwareDecodingKey: String = Keys.hardwareDecoding static let hideLibraryInFilesAppKey: String = Keys.hideLibraryInFilesApp @objc static let networkCachingKey: String = Keys.networkCaching + @objc static let stretchAudioKey: String = Keys.stretchAudio override init() { fatalError("compat struct not intended to be instantiated") @@ -245,6 +256,7 @@ fileprivate enum Keys { static let playlistPlayNextItem = "PlaylistPlayNextItem" static let restoreLastPlayedMedia = "RestoreLastPlayedMedia" static let showRemainingTime = "show-remaining-time" + static let stretchAudio = "audio-time-stretch" static func videoLibraryGridLayout(collectionModelName: String? = nil, name: String) -> String { [ diff --git a/Sources/Playback/Control/VLCPlaybackService.m b/Sources/Playback/Control/VLCPlaybackService.m index 1e5ee9886..a0d7ab601 100644 --- a/Sources/Playback/Control/VLCPlaybackService.m +++ b/Sources/Playback/Control/VLCPlaybackService.m @@ -246,7 +246,7 @@ NSString *const VLCLastPlaylistPlayedMedia = @"LastPlaylistPlayedMedia"; * media player instance however, potentially initialising an additional library instance * for this is costly, so this should be done only if needed */ NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults]; - BOOL audioTimeStretch = [[userDefaults objectForKey:kVLCSettingStretchAudio] boolValue]; + BOOL audioTimeStretch = VLCDefaults.shared.stretchAudio; NSMutableArray *libVLCOptions = [NSMutableArray array]; #if TARGET_OS_IOS BOOL chromecastPassthrough = [[userDefaults objectForKey:kVLCSettingCastingAudioPassthrough] boolValue]; @@ -259,7 +259,7 @@ NSString *const VLCLastPlaylistPlayedMedia = @"LastPlaylistPlayedMedia"; } #endif if (!audioTimeStretch) { - [libVLCOptions addObject:[NSString stringWithFormat:@"--no-%@", kVLCSettingStretchAudio]]; + [libVLCOptions addObject:@"--no-audio-time-stretch"]; } if (libVLCOptions.count > 0) { _listPlayer = [[VLCMediaListPlayer alloc] initWithOptions:libVLCOptions diff --git a/Sources/Settings/Model/SettingsSection.swift b/Sources/Settings/Model/SettingsSection.swift index d37ef488e..4b3b482fa 100644 --- a/Sources/Settings/Model/SettingsSection.swift +++ b/Sources/Settings/Model/SettingsSection.swift @@ -630,7 +630,7 @@ enum AudioOptions { static var timeStretchingAudio: SettingsItem { .toggle(title: "SETTINGS_TIME_STRETCH_AUDIO", subtitle: "SETTINGS_TIME_STRETCH_AUDIO_LONG", - preferenceKey: kVLCSettingStretchAudio) + keyPath: \.stretchAudio) } static var audioPlaybackInBackground: SettingsItem { -- GitLab From 05fc93100fbeee5a563f250878857baaf2d1bfe1 Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Sun, 23 Feb 2025 19:34:43 -0500 Subject: [PATCH 13/97] Convert kVLCSettingPauseWhenShowingControls --- Sources/App/iOS/VLCAppDelegate.m | 3 +-- Sources/Headers/VLCConstants.h | 1 - Sources/Helpers/VLCDefaults.swift | 13 +++++++++++++ .../VideoPlayer-iOS/VideoPlayerViewController.swift | 2 +- Sources/Settings/Model/SettingsSection.swift | 2 +- 5 files changed, 16 insertions(+), 5 deletions(-) diff --git a/Sources/App/iOS/VLCAppDelegate.m b/Sources/App/iOS/VLCAppDelegate.m index 0dd0ea96a..94b733077 100644 --- a/Sources/App/iOS/VLCAppDelegate.m +++ b/Sources/App/iOS/VLCAppDelegate.m @@ -87,8 +87,7 @@ kVLCSettingPlaybackSpeedDefaultValue: @(1.0), kVLCPlayerShowPlaybackSpeedShortcut: @(NO), kVLCSettingAlwaysPlayURLs: @(NO), - kVLCSettingPlayerControlDuration: kVLCSettingPlayerControlDurationDefaultValue, - kVLCSettingPauseWhenShowingControls: @(NO) + kVLCSettingPlayerControlDuration: kVLCSettingPlayerControlDurationDefaultValue }; [defaults registerDefaults:appDefaults]; } diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index c1dd0e90b..e3db10db6 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -94,7 +94,6 @@ #define kVLCSettingDisableSubtitles @"kVLCSettingDisableSubtitles" #define kVLCSettingPlayerControlDuration @"kVLCSettingPlayerControlDuration" #define kVLCSettingPlayerControlDurationDefaultValue @(4) -#define kVLCSettingPauseWhenShowingControls @"kVLCSettingPauseWhenShowingControls" #define kVLCForceSMBV1 @"smb-force-v1" diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index 06332d782..1bed758b1 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -24,6 +24,7 @@ Keys.automaticallyPlayNextItem: true, Keys.enableMediaCellTextScrolling: false, Keys.hideLibraryInFilesApp: false, + Keys.pauseWhenShowingControls: false, Keys.playerShouldRememberBrightness: false, Keys.playerShouldRememberState: true, Keys.playlistPlayNextItem: true, @@ -96,6 +97,15 @@ extension VLCDefaults { } } + @objc var pauseWhenShowingControls: Bool { + get { + userDefaults.bool(forKey: Keys.pauseWhenShowingControls) + } + set { + userDefaults.set(newValue, forKey: Keys.pauseWhenShowingControls) + } + } + @objc var playerShouldRememberBrightness: Bool { get { userDefaults.bool(forKey: Keys.playerShouldRememberBrightness) @@ -244,6 +254,8 @@ extension VLCDefaults { // MARK: - Keys fileprivate enum Keys { + // Avoid ever changing these values. Some are used as parameters in functions. + // Changing a value also causes the locally stored value to become unreachable. static let appThemeBlack = "blackTheme" static let automaticallyPlayNextItem = "AutomaticallyPlayNextItem" static let defaultPreampLevel = "pre-amp-level" @@ -251,6 +263,7 @@ fileprivate enum Keys { static let hardwareDecoding = "codec" static let hideLibraryInFilesApp = "HideLibraryInFilesApp" static let networkCaching = "network-caching" + static let pauseWhenShowingControls = "kVLCSettingPauseWhenShowingControls" static let playerShouldRememberBrightness = "PlayerShouldRememberBrightness" static let playerShouldRememberState = "PlayerShouldRememberState" static let playlistPlayNextItem = "PlaylistPlayNextItem" diff --git a/Sources/Playback/Player/VideoPlayer-iOS/VideoPlayerViewController.swift b/Sources/Playback/Player/VideoPlayer-iOS/VideoPlayerViewController.swift index 45f6a1978..e99c878c4 100644 --- a/Sources/Playback/Player/VideoPlayer-iOS/VideoPlayerViewController.swift +++ b/Sources/Playback/Player/VideoPlayer-iOS/VideoPlayerViewController.swift @@ -992,7 +992,7 @@ class VideoPlayerViewController: PlayerViewController { } @objc func handleTapOnVideo() { - if UserDefaults.standard.bool(forKey: kVLCSettingPauseWhenShowingControls) && playbackService.isPlaying { + if VLCDefaults.shared.pauseWhenShowingControls && playbackService.isPlaying { playbackService.pause() } diff --git a/Sources/Settings/Model/SettingsSection.swift b/Sources/Settings/Model/SettingsSection.swift index 4b3b482fa..7f6ba5929 100644 --- a/Sources/Settings/Model/SettingsSection.swift +++ b/Sources/Settings/Model/SettingsSection.swift @@ -762,7 +762,7 @@ enum Accessibility { static var pauseWhenShowingControls: SettingsItem { .toggle(title: "SETTINGS_PAUSE_WHEN_SHOWING_CONTROLS", subtitle: nil, - preferenceKey: kVLCSettingPauseWhenShowingControls) + keyPath: \.pauseWhenShowingControls) } static func section() -> SettingsSection? { -- GitLab From 7c2382cb3aa6257f6971db6c3122ec9d9f211efe Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Sun, 23 Feb 2025 20:14:34 -0500 Subject: [PATCH 14/97] Convert kVLCForceSMBV1 --- Sources/App/iOS/VLCAppDelegate.m | 1 - Sources/App/tvOS/AppleTVAppDelegate.m | 1 - Sources/Headers/VLCConstants.h | 2 -- Sources/Headers/VLCTVConstants.h | 2 -- Sources/Helpers/VLCDefaults.swift | 11 +++++++++++ .../Protocols/SMB/VLCLocalNetworkServiceBrowserDSM.m | 5 +++-- Sources/Settings/Model/SettingsSection.swift | 2 +- 7 files changed, 15 insertions(+), 9 deletions(-) diff --git a/Sources/App/iOS/VLCAppDelegate.m b/Sources/App/iOS/VLCAppDelegate.m index 94b733077..72e5a6e23 100644 --- a/Sources/App/iOS/VLCAppDelegate.m +++ b/Sources/App/iOS/VLCAppDelegate.m @@ -81,7 +81,6 @@ kVLCSettingBackupMediaLibrary : kVLCSettingBackupMediaLibraryDefaultValue, kVLCSettingCastingAudioPassthrough : @(NO), kVLCSettingCastingConversionQuality : @(2), - kVLCForceSMBV1 : @(YES), kVLCPlayerIsShuffleEnabled: kVLCPlayerIsShuffleEnabledDefaultValue, kVLCPlayerIsRepeatEnabled: kVLCPlayerIsRepeatEnabledDefaultValue, kVLCSettingPlaybackSpeedDefaultValue: @(1.0), diff --git a/Sources/App/tvOS/AppleTVAppDelegate.m b/Sources/App/tvOS/AppleTVAppDelegate.m index adb06c5ef..09b990bb3 100644 --- a/Sources/App/tvOS/AppleTVAppDelegate.m +++ b/Sources/App/tvOS/AppleTVAppDelegate.m @@ -59,7 +59,6 @@ kVLCSettingWiFiSharingIPv6 : kVLCSettingWiFiSharingIPv6DefaultValue, kVLCPlayerUIShouldHide : @(NO), kVLCSettingDownloadArtwork : @(YES), - kVLCForceSMBV1 : @(YES), kVLCSettingBackupMediaLibrary : kVLCSettingBackupMediaLibraryDefaultValue, kVLCSettingPlaybackSpeedDefaultValue: @(1.0)}; [defaults registerDefaults:appDefaults]; diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index e3db10db6..dc6087605 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -95,8 +95,6 @@ #define kVLCSettingPlayerControlDuration @"kVLCSettingPlayerControlDuration" #define kVLCSettingPlayerControlDurationDefaultValue @(4) -#define kVLCForceSMBV1 @"smb-force-v1" - #define kVLCRecentURLs @"recent-urls" #define kVLCRecentURLTitles @"recent-url-titles" #define kVLCPrivateWebStreaming @"private-streaming" diff --git a/Sources/Headers/VLCTVConstants.h b/Sources/Headers/VLCTVConstants.h index 44e5f215e..65dea1558 100644 --- a/Sources/Headers/VLCTVConstants.h +++ b/Sources/Headers/VLCTVConstants.h @@ -90,6 +90,4 @@ #define kVLCSettingCastingAudioPassthrough @"sout-chromecast-audio-passthrough" #define kVLCSettingCastingConversionQuality @"sout-chromecast-conversion-quality" -#define kVLCForceSMBV1 @"smb-force-v1" - #define kVLCSettingReset @"kVLCSettingReset" diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index 1bed758b1..8c06732c4 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -23,6 +23,7 @@ Keys.appThemeBlack: false, Keys.automaticallyPlayNextItem: true, Keys.enableMediaCellTextScrolling: false, + Keys.forceSMBV1: true, Keys.hideLibraryInFilesApp: false, Keys.pauseWhenShowingControls: false, Keys.playerShouldRememberBrightness: false, @@ -88,6 +89,15 @@ extension VLCDefaults { } } + @objc var forceSMBV1: Bool { + get { + userDefaults.bool(forKey: Keys.forceSMBV1) + } + set { + userDefaults.set(newValue, forKey: Keys.forceSMBV1) + } + } + @objc var hideLibraryInFilesApp: Bool { get { userDefaults.bool(forKey: Keys.hideLibraryInFilesApp) @@ -260,6 +270,7 @@ fileprivate enum Keys { static let automaticallyPlayNextItem = "AutomaticallyPlayNextItem" static let defaultPreampLevel = "pre-amp-level" static let enableMediaCellTextScrolling = "EnableMediaCellTextScrolling" + static let forceSMBV1 = "smb-force-v1" static let hardwareDecoding = "codec" static let hideLibraryInFilesApp = "HideLibraryInFilesApp" static let networkCaching = "network-caching" diff --git a/Sources/Network/Server Browsing/Data/Protocols/SMB/VLCLocalNetworkServiceBrowserDSM.m b/Sources/Network/Server Browsing/Data/Protocols/SMB/VLCLocalNetworkServiceBrowserDSM.m index dd1e48b7e..d584a5029 100644 --- a/Sources/Network/Server Browsing/Data/Protocols/SMB/VLCLocalNetworkServiceBrowserDSM.m +++ b/Sources/Network/Server Browsing/Data/Protocols/SMB/VLCLocalNetworkServiceBrowserDSM.m @@ -12,6 +12,7 @@ #import "VLCLocalNetworkServiceBrowserDSM.h" #import "VLCNetworkServerLoginInformation.h" +#import "VLC-Swift.h" @interface VLCLocalNetworkServiceDSM () + (void)registerLoginInformation; @@ -110,8 +111,8 @@ static NSString *const VLCLocalNetworkServiceDSMWorkgroupIdentifier = @"VLCLocal @"smb-pwd" : password ?: @"", @"smb-domain" : workgroup?: @"WORKGROUP", }.mutableCopy; - if ([[NSUserDefaults standardUserDefaults] boolForKey:kVLCForceSMBV1]) { - mediaOptions[kVLCForceSMBV1] = [NSNull null]; + if (VLCDefaults.shared.forceSMBV1) { + mediaOptions[@"smb-force-v1"] = [NSNull null]; } [media addOptions:mediaOptions]; return [[self alloc] initWithMedia:media options:mediaOptions]; diff --git a/Sources/Settings/Model/SettingsSection.swift b/Sources/Settings/Model/SettingsSection.swift index 7f6ba5929..0092dee4e 100644 --- a/Sources/Settings/Model/SettingsSection.swift +++ b/Sources/Settings/Model/SettingsSection.swift @@ -730,7 +730,7 @@ enum NetworkOptions { static var forceSMBv1: SettingsItem { .toggle(title: "SETTINGS_FORCE_SMBV1", subtitle: "SETTINGS_FORCE_SMBV1_LONG", - preferenceKey: kVLCForceSMBV1) + keyPath: \.forceSMBV1) } static var rtspctp: SettingsItem { -- GitLab From 3c2309203f3a4c7ca322fe7d851151e594aa4b93 Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Sun, 23 Feb 2025 20:20:17 -0500 Subject: [PATCH 15/97] Convert kVLCPlayerShowPlaybackSpeedShortcut --- Sources/App/iOS/VLCAppDelegate.m | 1 - Sources/Headers/VLCConstants.h | 1 - Sources/Helpers/VLCDefaults.swift | 11 +++++++++++ .../Playback/Player/AudioPlayer/AudioPlayerView.swift | 2 +- .../AudioPlayer/AudioPlayerViewController.swift | 2 +- .../VideoPlayer-iOS/Subviews/PlaybackSpeedView.swift | 4 ++-- 6 files changed, 15 insertions(+), 6 deletions(-) diff --git a/Sources/App/iOS/VLCAppDelegate.m b/Sources/App/iOS/VLCAppDelegate.m index 72e5a6e23..f3c43dea7 100644 --- a/Sources/App/iOS/VLCAppDelegate.m +++ b/Sources/App/iOS/VLCAppDelegate.m @@ -84,7 +84,6 @@ kVLCPlayerIsShuffleEnabled: kVLCPlayerIsShuffleEnabledDefaultValue, kVLCPlayerIsRepeatEnabled: kVLCPlayerIsRepeatEnabledDefaultValue, kVLCSettingPlaybackSpeedDefaultValue: @(1.0), - kVLCPlayerShowPlaybackSpeedShortcut: @(NO), kVLCSettingAlwaysPlayURLs: @(NO), kVLCSettingPlayerControlDuration: kVLCSettingPlayerControlDurationDefaultValue }; diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index dc6087605..cbaf9c0bc 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -112,7 +112,6 @@ #define kVLCPlayerIsShuffleEnabledDefaultValue @NO #define kVLCPlayerIsRepeatEnabled @"PlayerIsRepeatEnabled" #define kVLCPlayerIsRepeatEnabledDefaultValue @(0) -#define kVLCPlayerShowPlaybackSpeedShortcut @"kVLCPlayerShowPlaybackSpeedShortcut" #define kVLCCustomProfileEnabled @"kVLCCustomProfileEnabled" #define kVLCCustomEqualizerProfiles @"kVLCCustomEqualizerProfiles" diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index 8c06732c4..6b009ae0b 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -28,6 +28,7 @@ Keys.pauseWhenShowingControls: false, Keys.playerShouldRememberBrightness: false, Keys.playerShouldRememberState: true, + Keys.playerShowPlaybackSpeedShortcut: false, Keys.playlistPlayNextItem: true, Keys.restoreLastPlayedMedia: true, Keys.showRemainingTime: false, @@ -134,6 +135,15 @@ extension VLCDefaults { } } + @objc var playerShowPlaybackSpeedShortcut: Bool { + get { + userDefaults.bool(forKey: Keys.playerShowPlaybackSpeedShortcut) + } + set { + userDefaults.set(newValue, forKey: Keys.playerShowPlaybackSpeedShortcut) + } + } + @objc var playlistPlayNextItem: Bool { get { userDefaults.bool(forKey: Keys.playlistPlayNextItem) @@ -277,6 +287,7 @@ fileprivate enum Keys { static let pauseWhenShowingControls = "kVLCSettingPauseWhenShowingControls" static let playerShouldRememberBrightness = "PlayerShouldRememberBrightness" static let playerShouldRememberState = "PlayerShouldRememberState" + static let playerShowPlaybackSpeedShortcut = "kVLCPlayerShowPlaybackSpeedShortcut" static let playlistPlayNextItem = "PlaylistPlayNextItem" static let restoreLastPlayedMedia = "RestoreLastPlayedMedia" static let showRemainingTime = "show-remaining-time" diff --git a/Sources/Playback/Player/AudioPlayer/AudioPlayerView.swift b/Sources/Playback/Player/AudioPlayer/AudioPlayerView.swift index 1b94c4be2..3d1e96d45 100644 --- a/Sources/Playback/Player/AudioPlayer/AudioPlayerView.swift +++ b/Sources/Playback/Player/AudioPlayer/AudioPlayerView.swift @@ -576,7 +576,7 @@ class AudioPlayerView: UIView, UIGestureRecognizerDelegate { secondaryControlStackView.addArrangedSubview(playbackSpeedButton) - let displaySecondaryStackView: Bool = UserDefaults.standard.bool(forKey: kVLCPlayerShowPlaybackSpeedShortcut) + let displaySecondaryStackView: Bool = VLCDefaults.shared.playerShowPlaybackSpeedShortcut secondaryControlStackView.isHidden = !displaySecondaryStackView } diff --git a/Sources/Playback/Player/AudioPlayer/AudioPlayerViewController.swift b/Sources/Playback/Player/AudioPlayer/AudioPlayerViewController.swift index 189fcee32..522f61680 100644 --- a/Sources/Playback/Player/AudioPlayer/AudioPlayerViewController.swift +++ b/Sources/Playback/Player/AudioPlayer/AudioPlayerViewController.swift @@ -126,7 +126,7 @@ class AudioPlayerViewController: PlayerViewController { mediaScrubProgressBar.shouldHideScrubLabels = false #endif - let displayShortcutView: Bool = UserDefaults.standard.bool(forKey: kVLCPlayerShowPlaybackSpeedShortcut) + let displayShortcutView: Bool = VLCDefaults.shared.playerShowPlaybackSpeedShortcut audioPlayerView.shouldDisplaySecondaryStackView(displayShortcutView) } diff --git a/Sources/Playback/Player/VideoPlayer-iOS/Subviews/PlaybackSpeedView.swift b/Sources/Playback/Player/VideoPlayer-iOS/Subviews/PlaybackSpeedView.swift index d81e91b2e..0c5cf9f98 100644 --- a/Sources/Playback/Player/VideoPlayer-iOS/Subviews/PlaybackSpeedView.swift +++ b/Sources/Playback/Player/VideoPlayer-iOS/Subviews/PlaybackSpeedView.swift @@ -164,7 +164,7 @@ class PlaybackSpeedView: UIView { shortcutLabel.text = NSLocalizedString("DISPLAY_PLAYBACK_SPEED_SHORTCUT", comment: "") shortcutLabel.accessibilityLabel = NSLocalizedString("DISPLAY_PLAYBACK_SPEED_SHORTCUT", comment: "") shortcutLabel.accessibilityHint = NSLocalizedString("DISPLAY_PLAYBACK_SPEED_SHORTCUT_HINT", comment: "") - shortcutSwitch.isOn = UserDefaults.standard.bool(forKey: kVLCPlayerShowPlaybackSpeedShortcut) + shortcutSwitch.isOn = VLCDefaults.shared.playerShowPlaybackSpeedShortcut } @objc func playbackSpeedHasChanged(_ notification: NSNotification) { @@ -345,7 +345,7 @@ class PlaybackSpeedView: UIView { @IBAction func handleShortcutSwitch(_ sender: Any) { let isSwitchOn: Bool = shortcutSwitch.isOn - UserDefaults.standard.setValue(isSwitchOn, forKey: kVLCPlayerShowPlaybackSpeedShortcut) + VLCDefaults.shared.playerShowPlaybackSpeedShortcut = isSwitchOn delegate?.playbackSpeedViewHandleShortcutSwitchChange(displayView: isSwitchOn) } } -- GitLab From a67e68956ccd0f72634806d06a62127923d8a753 Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Sun, 23 Feb 2025 20:26:59 -0500 Subject: [PATCH 16/97] Convert kVLCSettingPasscodeEnableBiometricAuth --- Sources/App/iOS/VLCAppDelegate.m | 3 +-- Sources/Headers/VLCConstants.h | 1 - Sources/Helpers/VLCDefaults.swift | 11 +++++++++++ Sources/Settings/Model/SettingsSection.swift | 6 +++--- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/Sources/App/iOS/VLCAppDelegate.m b/Sources/App/iOS/VLCAppDelegate.m index f3c43dea7..647385d5e 100644 --- a/Sources/App/iOS/VLCAppDelegate.m +++ b/Sources/App/iOS/VLCAppDelegate.m @@ -44,7 +44,6 @@ [VLCDefaults.shared registerDefaults]; NSDictionary *appDefaults = @{kVLCSettingAppTheme : @(appThemeIndex), - kVLCSettingPasscodeEnableBiometricAuth : @(1), kVLCSettingContinueAudioInBackgroundKey : @(YES), kVLCSettingTextEncoding : kVLCSettingTextEncodingDefaultValue, kVLCSettingSkipLoopFilter : kVLCSettingSkipLoopFilterNonRef, @@ -261,7 +260,7 @@ { if ([[VLCKeychainCoordinator passcodeService] hasSecret]) { //TODO: Dismiss playback - BOOL allowBiometricAuthentication = [[NSUserDefaults standardUserDefaults] boolForKey:kVLCSettingPasscodeEnableBiometricAuth]; + BOOL allowBiometricAuthentication = VLCDefaults.shared.passcodeEnableBiometricAuth; [[VLCKeychainCoordinator passcodeService] validateSecretWithAllowBiometricAuthentication:allowBiometricAuthentication diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index cbaf9c0bc..32af749ea 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -12,7 +12,6 @@ *****************************************************************************/ #define kVLCSettingPasscodeOnKey @"PasscodeProtection" -#define kVLCSettingPasscodeEnableBiometricAuth @"EnableBiometricAuth" #define kVLCThemeDidChangeNotification @"themeDidChangeNotfication" #define kVLCSettingAppTheme @"darkMode" #define kVLCSettingAppThemeBright 0 diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index 6b009ae0b..dbb34cf12 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -25,6 +25,7 @@ Keys.enableMediaCellTextScrolling: false, Keys.forceSMBV1: true, Keys.hideLibraryInFilesApp: false, + Keys.passcodeEnableBiometricAuth: true, Keys.pauseWhenShowingControls: false, Keys.playerShouldRememberBrightness: false, Keys.playerShouldRememberState: true, @@ -135,6 +136,15 @@ extension VLCDefaults { } } + @objc var passcodeEnableBiometricAuth: Bool { + get { + userDefaults.bool(forKey: Keys.passcodeEnableBiometricAuth) + } + set { + userDefaults.set(newValue, forKey: Keys.passcodeEnableBiometricAuth) + } + } + @objc var playerShowPlaybackSpeedShortcut: Bool { get { userDefaults.bool(forKey: Keys.playerShowPlaybackSpeedShortcut) @@ -284,6 +294,7 @@ fileprivate enum Keys { static let hardwareDecoding = "codec" static let hideLibraryInFilesApp = "HideLibraryInFilesApp" static let networkCaching = "network-caching" + static let passcodeEnableBiometricAuth = "EnableBiometricAuth" static let pauseWhenShowingControls = "kVLCSettingPauseWhenShowingControls" static let playerShouldRememberBrightness = "PlayerShouldRememberBrightness" static let playerShouldRememberState = "PlayerShouldRememberState" diff --git a/Sources/Settings/Model/SettingsSection.swift b/Sources/Settings/Model/SettingsSection.swift index 0092dee4e..d48437397 100644 --- a/Sources/Settings/Model/SettingsSection.swift +++ b/Sources/Settings/Model/SettingsSection.swift @@ -309,15 +309,15 @@ enum PrivacyOptions { case .touchID: return .toggle(title: "SETTINGS_PASSCODE_LOCK_ALLOWTOUCHID", subtitle: nil, - preferenceKey: kVLCSettingPasscodeEnableBiometricAuth) + keyPath: \.passcodeEnableBiometricAuth) case .faceID: return .toggle(title: "SETTINGS_PASSCODE_LOCK_ALLOWFACEID", subtitle: nil, - preferenceKey: kVLCSettingPasscodeEnableBiometricAuth) + keyPath: \.passcodeEnableBiometricAuth) case .opticID: return .toggle(title: "SETTINGS_PASSCODE_LOCK_ALLOWOPTICID", subtitle: nil, - preferenceKey: kVLCSettingPasscodeEnableBiometricAuth) + keyPath: \.passcodeEnableBiometricAuth) case .none: fallthrough @unknown default: -- GitLab From 73299145ccbc9c28008516b8c4d89c9280a940f0 Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Sun, 23 Feb 2025 20:33:29 -0500 Subject: [PATCH 17/97] Convert kVLCSettingContinueAudioInBackgroundKey --- Sources/App/iOS/VLCAppDelegate.m | 1 - Sources/App/tvOS/AppleTVAppDelegate.m | 3 +-- Sources/Headers/VLCConstants.h | 1 - Sources/Headers/VLCTVConstants.h | 1 - Sources/Helpers/VLCDefaults.swift | 11 +++++++++++ Sources/Playback/Control/VLCPlaybackService.m | 3 +-- Sources/Settings/Model/SettingsSection.swift | 2 +- 7 files changed, 14 insertions(+), 8 deletions(-) diff --git a/Sources/App/iOS/VLCAppDelegate.m b/Sources/App/iOS/VLCAppDelegate.m index 647385d5e..0e2e589f1 100644 --- a/Sources/App/iOS/VLCAppDelegate.m +++ b/Sources/App/iOS/VLCAppDelegate.m @@ -44,7 +44,6 @@ [VLCDefaults.shared registerDefaults]; NSDictionary *appDefaults = @{kVLCSettingAppTheme : @(appThemeIndex), - kVLCSettingContinueAudioInBackgroundKey : @(YES), kVLCSettingTextEncoding : kVLCSettingTextEncodingDefaultValue, kVLCSettingSkipLoopFilter : kVLCSettingSkipLoopFilterNonRef, kVLCSettingSubtitlesFont : kVLCSettingSubtitlesFontDefaultValue, diff --git a/Sources/App/tvOS/AppleTVAppDelegate.m b/Sources/App/tvOS/AppleTVAppDelegate.m index 09b990bb3..69ecd9cec 100644 --- a/Sources/App/tvOS/AppleTVAppDelegate.m +++ b/Sources/App/tvOS/AppleTVAppDelegate.m @@ -40,8 +40,7 @@ { NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; - NSDictionary *appDefaults = @{kVLCSettingContinueAudioInBackgroundKey : @(YES), - kVLCSettingTextEncoding : kVLCSettingTextEncodingDefaultValue, + NSDictionary *appDefaults = @{kVLCSettingTextEncoding : kVLCSettingTextEncodingDefaultValue, kVLCSettingSkipLoopFilter : kVLCSettingSkipLoopFilterNonRef, kVLCSettingSubtitlesFont : kVLCSettingSubtitlesFontDefaultValue, kVLCSettingSubtitlesFontColor : kVLCSettingSubtitlesFontColorDefaultValue, diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index 32af749ea..94593244c 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -22,7 +22,6 @@ #define kVLCLastPlayedPlaylist @"LastPlayedPlaylist" #define kVLCIsCurrentlyPlayingPlaylist @"isPlaylistCurrentlyPlaying" #define kVLCCurrentPlaylistMediasQueue @"currentPlaylistMediasQueue" -#define kVLCSettingContinueAudioInBackgroundKey @"BackgroundAudioPlayback" #define kVLCSettingTextEncoding @"subsdec-encoding" #define kVLCSettingTextEncodingDefaultValue @"Windows-1252" #define kVLCSettingSkipLoopFilter @"avcodec-skiploopfilter" diff --git a/Sources/Headers/VLCTVConstants.h b/Sources/Headers/VLCTVConstants.h index 65dea1558..b99f0f6ea 100644 --- a/Sources/Headers/VLCTVConstants.h +++ b/Sources/Headers/VLCTVConstants.h @@ -48,7 +48,6 @@ #define kVLCSubtitlesCacheFolderName @"cached-subtitles" #define kVLCSettingTextEncoding @"subsdec-encoding" #define kVLCSettingTextEncodingDefaultValue @"Windows-1252" -#define kVLCSettingContinueAudioInBackgroundKey @"BackgroundAudioPlayback" #define kVLCSettingSubtitlesFilePath @"sub-file" #define kVLCSettingEqualizerProfile @"EqualizerProfile" #define kVLCSettingEqualizerProfileDisabled @"EqualizerDisabled" diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index dbb34cf12..2647a9962 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -22,6 +22,7 @@ // bools Keys.appThemeBlack: false, Keys.automaticallyPlayNextItem: true, + Keys.continueAudioInBackground: true, Keys.enableMediaCellTextScrolling: false, Keys.forceSMBV1: true, Keys.hideLibraryInFilesApp: false, @@ -82,6 +83,15 @@ extension VLCDefaults { } } + @objc var continueAudioInBackgroundKey: Bool { + get { + userDefaults.bool(forKey: Keys.continueAudioInBackground) + } + set { + userDefaults.set(newValue, forKey: Keys.continueAudioInBackground) + } + } + @objc var enableMediaCellTextScrolling: Bool { get { userDefaults.bool(forKey: Keys.enableMediaCellTextScrolling) @@ -288,6 +298,7 @@ fileprivate enum Keys { // Changing a value also causes the locally stored value to become unreachable. static let appThemeBlack = "blackTheme" static let automaticallyPlayNextItem = "AutomaticallyPlayNextItem" + static let continueAudioInBackground = "BackgroundAudioPlayback" static let defaultPreampLevel = "pre-amp-level" static let enableMediaCellTextScrolling = "EnableMediaCellTextScrolling" static let forceSMBV1 = "smb-force-v1" diff --git a/Sources/Playback/Control/VLCPlaybackService.m b/Sources/Playback/Control/VLCPlaybackService.m index a0d7ab601..4f4658d01 100644 --- a/Sources/Playback/Control/VLCPlaybackService.m +++ b/Sources/Playback/Control/VLCPlaybackService.m @@ -1721,8 +1721,7 @@ NSString *const VLCLastPlaylistPlayedMedia = @"LastPlaylistPlayedMedia"; #if !TARGET_OS_TV [self savePlaybackState]; #endif - if (![self isPlayingOnExternalScreen] - && ![[[NSUserDefaults standardUserDefaults] objectForKey:kVLCSettingContinueAudioInBackgroundKey] boolValue]) { + if (![self isPlayingOnExternalScreen] && !VLCDefaults.shared.continueAudioInBackgroundKey) { if ([_mediaPlayer isPlaying]) { [_mediaPlayer pause]; _shouldResumePlaying = YES; diff --git a/Sources/Settings/Model/SettingsSection.swift b/Sources/Settings/Model/SettingsSection.swift index d48437397..e901ccd69 100644 --- a/Sources/Settings/Model/SettingsSection.swift +++ b/Sources/Settings/Model/SettingsSection.swift @@ -636,7 +636,7 @@ enum AudioOptions { static var audioPlaybackInBackground: SettingsItem { .toggle(title: "SETTINGS_BACKGROUND_AUDIO", subtitle: nil, - preferenceKey: kVLCSettingContinueAudioInBackgroundKey) + keyPath: \.continueAudioInBackgroundKey) } static func section() -> SettingsSection? { -- GitLab From a87662022cbceeb2bc9cd1fd2a2cd344769dfc15 Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Sun, 23 Feb 2025 20:38:17 -0500 Subject: [PATCH 18/97] Convert kVLCSettingVolumeGesture --- Sources/App/iOS/VLCAppDelegate.m | 1 - Sources/Headers/VLCConstants.h | 1 - Sources/Helpers/VLCDefaults.swift | 11 +++++++++++ .../Player/VideoPlayer-iOS/PlayerController.swift | 2 +- Sources/Settings/Model/SettingsSection.swift | 2 +- 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Sources/App/iOS/VLCAppDelegate.m b/Sources/App/iOS/VLCAppDelegate.m index 0e2e589f1..f4cdc6358 100644 --- a/Sources/App/iOS/VLCAppDelegate.m +++ b/Sources/App/iOS/VLCAppDelegate.m @@ -51,7 +51,6 @@ kVLCSettingSubtitlesFontSize : kVLCSettingSubtitlesFontSizeDefaultValue, kVLCSettingSubtitlesBoldFont: kVLCSettingSubtitlesBoldFontDefaultValue, kVLCSettingDeinterlace : kVLCSettingDeinterlaceDefaultValue, - kVLCSettingVolumeGesture : @(YES), kVLCSettingPlayPauseGesture : @(YES), kVLCSettingBrightnessGesture : @(YES), kVLCSettingSeekGesture : @(YES), diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index 94593244c..bda56283f 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -47,7 +47,6 @@ #define kVLCSettingNetworkSatIPChannelListCustom @"CustomList" #define kVLCSettingNetworkSatIPChannelListUrl @"satip-channellist-url" #define kVLCSettingsDecrapifyTitles @"MLDecrapifyTitles" -#define kVLCSettingVolumeGesture @"EnableVolumeGesture" #define kVLCSettingPlayPauseGesture @"EnablePlayPauseGesture" #define kVLCSettingBrightnessGesture @"EnableBrightnessGesture" #define kVLCSettingSeekGesture @"EnableSeekGesture" diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index 2647a9962..d0b2b52f6 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -35,6 +35,7 @@ Keys.restoreLastPlayedMedia: true, Keys.showRemainingTime: false, Keys.stretchAudio: true, + Keys.volumeGesture: true, // numbers Keys.defaultPreampLevel: Float(6), @@ -200,6 +201,15 @@ extension VLCDefaults { } } + @objc var volumeGesture: Bool { + get { + userDefaults.bool(forKey: Keys.volumeGesture) + } + set { + userDefaults.set(newValue, forKey: Keys.volumeGesture) + } + } + // Numbers @objc var defaultPreampLevel: Float { @@ -314,6 +324,7 @@ fileprivate enum Keys { static let restoreLastPlayedMedia = "RestoreLastPlayedMedia" static let showRemainingTime = "show-remaining-time" static let stretchAudio = "audio-time-stretch" + static let volumeGesture = "EnableVolumeGesture" static func videoLibraryGridLayout(collectionModelName: String? = nil, name: String) -> String { [ diff --git a/Sources/Playback/Player/VideoPlayer-iOS/PlayerController.swift b/Sources/Playback/Player/VideoPlayer-iOS/PlayerController.swift index 905e474c3..97568f313 100644 --- a/Sources/Playback/Player/VideoPlayer-iOS/PlayerController.swift +++ b/Sources/Playback/Player/VideoPlayer-iOS/PlayerController.swift @@ -45,7 +45,7 @@ class PlayerController: NSObject { } var isVolumeGestureEnabled: Bool { - return UserDefaults.standard.bool(forKey: kVLCSettingVolumeGesture) + return VLCDefaults.shared.volumeGesture } var isPlayPauseGestureEnabled: Bool { diff --git a/Sources/Settings/Model/SettingsSection.swift b/Sources/Settings/Model/SettingsSection.swift index e901ccd69..4432dad11 100644 --- a/Sources/Settings/Model/SettingsSection.swift +++ b/Sources/Settings/Model/SettingsSection.swift @@ -349,7 +349,7 @@ enum GestureControlOptions { static var swipeUpDownForVolume: SettingsItem { .toggle(title: "SETTINGS_GESTURES_VOLUME", subtitle: nil, - preferenceKey: kVLCSettingVolumeGesture) + keyPath: \.volumeGesture) } static var twoFingerTap: SettingsItem { -- GitLab From 485ca9b978dc03dfe3bd3efc5d0158bd89fcef7c Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Sun, 23 Feb 2025 20:42:10 -0500 Subject: [PATCH 19/97] Convert kVLCSettingPlayPauseGesture --- Sources/App/iOS/VLCAppDelegate.m | 1 - Sources/Headers/VLCConstants.h | 1 - Sources/Helpers/VLCDefaults.swift | 11 +++++++++++ .../Player/VideoPlayer-iOS/PlayerController.swift | 2 +- Sources/Settings/Model/SettingsSection.swift | 2 +- 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Sources/App/iOS/VLCAppDelegate.m b/Sources/App/iOS/VLCAppDelegate.m index f4cdc6358..d35b4b196 100644 --- a/Sources/App/iOS/VLCAppDelegate.m +++ b/Sources/App/iOS/VLCAppDelegate.m @@ -51,7 +51,6 @@ kVLCSettingSubtitlesFontSize : kVLCSettingSubtitlesFontSizeDefaultValue, kVLCSettingSubtitlesBoldFont: kVLCSettingSubtitlesBoldFontDefaultValue, kVLCSettingDeinterlace : kVLCSettingDeinterlaceDefaultValue, - kVLCSettingPlayPauseGesture : @(YES), kVLCSettingBrightnessGesture : @(YES), kVLCSettingSeekGesture : @(YES), kVLCSettingCloseGesture : @(YES), diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index bda56283f..fdebf95dd 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -47,7 +47,6 @@ #define kVLCSettingNetworkSatIPChannelListCustom @"CustomList" #define kVLCSettingNetworkSatIPChannelListUrl @"satip-channellist-url" #define kVLCSettingsDecrapifyTitles @"MLDecrapifyTitles" -#define kVLCSettingPlayPauseGesture @"EnablePlayPauseGesture" #define kVLCSettingBrightnessGesture @"EnableBrightnessGesture" #define kVLCSettingSeekGesture @"EnableSeekGesture" #define kVLCSettingCloseGesture @"EnableCloseGesture" diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index d0b2b52f6..6d59391fd 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -32,6 +32,7 @@ Keys.playerShouldRememberState: true, Keys.playerShowPlaybackSpeedShortcut: false, Keys.playlistPlayNextItem: true, + Keys.playPauseGesture: true, Keys.restoreLastPlayedMedia: true, Keys.showRemainingTime: false, Keys.stretchAudio: true, @@ -174,6 +175,15 @@ extension VLCDefaults { } } + @objc var playPauseGesture: Bool { + get { + userDefaults.bool(forKey: Keys.playPauseGesture) + } + set { + userDefaults.set(newValue, forKey: Keys.playPauseGesture) + } + } + @objc var restoreLastPlayedMedia: Bool { get { userDefaults.bool(forKey: Keys.restoreLastPlayedMedia) @@ -321,6 +331,7 @@ fileprivate enum Keys { static let playerShouldRememberState = "PlayerShouldRememberState" static let playerShowPlaybackSpeedShortcut = "kVLCPlayerShowPlaybackSpeedShortcut" static let playlistPlayNextItem = "PlaylistPlayNextItem" + static let playPauseGesture = "EnablePlayPauseGesture" static let restoreLastPlayedMedia = "RestoreLastPlayedMedia" static let showRemainingTime = "show-remaining-time" static let stretchAudio = "audio-time-stretch" diff --git a/Sources/Playback/Player/VideoPlayer-iOS/PlayerController.swift b/Sources/Playback/Player/VideoPlayer-iOS/PlayerController.swift index 97568f313..b3a1d30d1 100644 --- a/Sources/Playback/Player/VideoPlayer-iOS/PlayerController.swift +++ b/Sources/Playback/Player/VideoPlayer-iOS/PlayerController.swift @@ -49,7 +49,7 @@ class PlayerController: NSObject { } var isPlayPauseGestureEnabled: Bool { - return UserDefaults.standard.bool(forKey: kVLCSettingPlayPauseGesture) + return VLCDefaults.shared.playPauseGesture } var isBrightnessGestureEnabled: Bool { diff --git a/Sources/Settings/Model/SettingsSection.swift b/Sources/Settings/Model/SettingsSection.swift index 4432dad11..90703fed7 100644 --- a/Sources/Settings/Model/SettingsSection.swift +++ b/Sources/Settings/Model/SettingsSection.swift @@ -355,7 +355,7 @@ enum GestureControlOptions { static var twoFingerTap: SettingsItem { .toggle(title: "SETTINGS_GESTURES_PLAYPAUSE", subtitle: nil, - preferenceKey: kVLCSettingPlayPauseGesture) + keyPath: \.playPauseGesture) } static var swipeUpDownForBrightness: SettingsItem { -- GitLab From 1438dbec2442208d1b9fd07ee18f17c9ec0143e6 Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Sun, 23 Feb 2025 20:55:37 -0500 Subject: [PATCH 20/97] Convert kVLCSettingDownloadArtwork, fix tvOS build --- Sources/App/tvOS/AppleTVAppDelegate.m | 1 - Sources/Headers/VLCTVConstants.h | 1 - Sources/Helpers/VLCDefaults.swift | 11 +++++++++++ .../VLCServerBrowsingTVViewController.m | 3 ++- .../VLCFullscreenMovieTVViewController.m | 1 + VLC.xcodeproj/project.pbxproj | 2 ++ 6 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Sources/App/tvOS/AppleTVAppDelegate.m b/Sources/App/tvOS/AppleTVAppDelegate.m index 69ecd9cec..dcc83b9b6 100644 --- a/Sources/App/tvOS/AppleTVAppDelegate.m +++ b/Sources/App/tvOS/AppleTVAppDelegate.m @@ -57,7 +57,6 @@ kVLCSettingPlaybackRemoteControlSkip : @(NO), kVLCSettingWiFiSharingIPv6 : kVLCSettingWiFiSharingIPv6DefaultValue, kVLCPlayerUIShouldHide : @(NO), - kVLCSettingDownloadArtwork : @(YES), kVLCSettingBackupMediaLibrary : kVLCSettingBackupMediaLibraryDefaultValue, kVLCSettingPlaybackSpeedDefaultValue: @(1.0)}; [defaults registerDefaults:appDefaults]; diff --git a/Sources/Headers/VLCTVConstants.h b/Sources/Headers/VLCTVConstants.h index b99f0f6ea..270c33e11 100644 --- a/Sources/Headers/VLCTVConstants.h +++ b/Sources/Headers/VLCTVConstants.h @@ -60,7 +60,6 @@ #define kVLCSettingPlaybackRemoteControlSkip @"playback-remote-control-skip" #define kVLCSettingSaveHTTPUploadServerStatus @"isHTTPServerOn" #define kVLCPlayerUIShouldHide @"PlayerUIShouldHide" -#define kVLCSettingDownloadArtwork @"download-artwork" #define kVLCSettingUseSPDIF @"kVLCSettingUseSPDIF" #define kVLCSettingBackupMediaLibrary @"BackupMediaLibrary" #define kVLCSettingBackupMediaLibraryDefaultValue @NO diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index 6d59391fd..458fca3be 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -23,6 +23,7 @@ Keys.appThemeBlack: false, Keys.automaticallyPlayNextItem: true, Keys.continueAudioInBackground: true, + Keys.downloadArtwork: true, Keys.enableMediaCellTextScrolling: false, Keys.forceSMBV1: true, Keys.hideLibraryInFilesApp: false, @@ -85,6 +86,15 @@ extension VLCDefaults { } } + @objc var downloadArtwork: Bool { + get { + userDefaults.bool(forKey: Keys.downloadArtwork) + } + set { + userDefaults.set(newValue, forKey: Keys.downloadArtwork) + } + } + @objc var continueAudioInBackgroundKey: Bool { get { userDefaults.bool(forKey: Keys.continueAudioInBackground) @@ -320,6 +330,7 @@ fileprivate enum Keys { static let automaticallyPlayNextItem = "AutomaticallyPlayNextItem" static let continueAudioInBackground = "BackgroundAudioPlayback" static let defaultPreampLevel = "pre-amp-level" + static let downloadArtwork = "download-artwork" static let enableMediaCellTextScrolling = "EnableMediaCellTextScrolling" static let forceSMBV1 = "smb-force-v1" static let hardwareDecoding = "codec" diff --git a/Sources/Network/Server Browsing/View Controllers/VLCServerBrowsingTVViewController.m b/Sources/Network/Server Browsing/View Controllers/VLCServerBrowsingTVViewController.m index 6e21e5c30..78fe65da8 100644 --- a/Sources/Network/Server Browsing/View Controllers/VLCServerBrowsingTVViewController.m +++ b/Sources/Network/Server Browsing/View Controllers/VLCServerBrowsingTVViewController.m @@ -18,6 +18,7 @@ #import "GRKArrayDiff+UICollectionView.h" #import "VLCFavoriteService.h" #import "VLCAppCoordinator.h" +#import "VLC-Swift.h" @interface VLCServerBrowsingTVViewController () { @@ -47,7 +48,7 @@ self.title = serverBrowser.title; - self.downloadArtwork = [[NSUserDefaults standardUserDefaults] boolForKey:kVLCSettingDownloadArtwork]; + self.downloadArtwork = VLCDefaults.shared.downloadArtwork; } return self; } diff --git a/Sources/Playback/Player/VideoPlayer-tvOS/VLCFullscreenMovieTVViewController.m b/Sources/Playback/Player/VideoPlayer-tvOS/VLCFullscreenMovieTVViewController.m index 2dc666639..aa77adb90 100644 --- a/Sources/Playback/Player/VideoPlayer-tvOS/VLCFullscreenMovieTVViewController.m +++ b/Sources/Playback/Player/VideoPlayer-tvOS/VLCFullscreenMovieTVViewController.m @@ -18,6 +18,7 @@ #import "VLCNetworkImageView.h" #import "VLCMetaData.h" #import "VLCActivityManager.h" +#import "VLC-Swift.h" typedef NS_ENUM(NSInteger, VLCPlayerScanState) { diff --git a/VLC.xcodeproj/project.pbxproj b/VLC.xcodeproj/project.pbxproj index 29a3de130..ce107c770 100644 --- a/VLC.xcodeproj/project.pbxproj +++ b/VLC.xcodeproj/project.pbxproj @@ -97,6 +97,7 @@ 444E5C0024C719480003B69C /* AboutController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 444E5BFF24C719480003B69C /* AboutController.swift */; }; 446AA2322D6A91620026F3C8 /* VLCDefaults.swift in Sources */ = {isa = PBXBuildFile; fileRef = 446AA2312D6A91520026F3C8 /* VLCDefaults.swift */; }; 446AA2332D6A91620026F3C8 /* VLCDefaults.swift in Sources */ = {isa = PBXBuildFile; fileRef = 446AA2312D6A91520026F3C8 /* VLCDefaults.swift */; }; + 446AA2342D6C08C50026F3C8 /* VLCDefaults.swift in Sources */ = {isa = PBXBuildFile; fileRef = 446AA2312D6A91520026F3C8 /* VLCDefaults.swift */; }; 44B5822024E434FD001A2583 /* MediaGridCollectionCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 44B5821F24E434FD001A2583 /* MediaGridCollectionCell.swift */; }; 44C8BBA324AF2B5C003F8940 /* FeedbackGenerators.swift in Sources */ = {isa = PBXBuildFile; fileRef = 44C8BBA224AF2B5C003F8940 /* FeedbackGenerators.swift */; }; 44C8BBAE24AF36F4003F8940 /* SettingsController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 44C8BBA624AF36F4003F8940 /* SettingsController.swift */; }; @@ -4244,6 +4245,7 @@ 6C5B0C9E27A43098005AE25B /* PlaybackServiceAdjustFilter.swift in Sources */, 7DC869B828CB794A00EE99F8 /* VLCDeletionCapableViewController.m in Sources */, DD4089F21BF6467E0022745E /* VLCPlaybackInfoTVCollectionViewCell.m in Sources */, + 446AA2342D6C08C50026F3C8 /* VLCDefaults.swift in Sources */, 4342C3C327474CA000E52334 /* SortedMediaFiles.swift in Sources */, DD3EAC0A1BE2192A003668DA /* VLCServerBrowsingController.m in Sources */, D9B36AF62AF4020000A10C99 /* AspectRatio.swift in Sources */, -- GitLab From 2cd10c61460f14e39dfc4153c035aa0e86fffc1c Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Sun, 23 Feb 2025 21:05:00 -0500 Subject: [PATCH 21/97] Convert kVLCSettingBrightnessGesture --- Sources/App/iOS/VLCAppDelegate.m | 1 - Sources/Headers/VLCConstants.h | 1 - Sources/Helpers/VLCDefaults.swift | 11 +++++++++++ .../Player/VideoPlayer-iOS/PlayerController.swift | 2 +- Sources/Settings/Model/SettingsSection.swift | 2 +- 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Sources/App/iOS/VLCAppDelegate.m b/Sources/App/iOS/VLCAppDelegate.m index d35b4b196..e38f15bdb 100644 --- a/Sources/App/iOS/VLCAppDelegate.m +++ b/Sources/App/iOS/VLCAppDelegate.m @@ -51,7 +51,6 @@ kVLCSettingSubtitlesFontSize : kVLCSettingSubtitlesFontSizeDefaultValue, kVLCSettingSubtitlesBoldFont: kVLCSettingSubtitlesBoldFontDefaultValue, kVLCSettingDeinterlace : kVLCSettingDeinterlaceDefaultValue, - kVLCSettingBrightnessGesture : @(YES), kVLCSettingSeekGesture : @(YES), kVLCSettingCloseGesture : @(YES), kVLCSettingPlaybackLongTouchSpeedUp : @(YES), diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index fdebf95dd..4a8aabe14 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -47,7 +47,6 @@ #define kVLCSettingNetworkSatIPChannelListCustom @"CustomList" #define kVLCSettingNetworkSatIPChannelListUrl @"satip-channellist-url" #define kVLCSettingsDecrapifyTitles @"MLDecrapifyTitles" -#define kVLCSettingBrightnessGesture @"EnableBrightnessGesture" #define kVLCSettingSeekGesture @"EnableSeekGesture" #define kVLCSettingCloseGesture @"EnableCloseGesture" #define kVLCSettingVideoFullscreenPlayback @"AlwaysUseFullscreenForVideo" diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index 458fca3be..6b0c25234 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -22,6 +22,7 @@ // bools Keys.appThemeBlack: false, Keys.automaticallyPlayNextItem: true, + Keys.brightnessGesture: true, Keys.continueAudioInBackground: true, Keys.downloadArtwork: true, Keys.enableMediaCellTextScrolling: false, @@ -86,6 +87,15 @@ extension VLCDefaults { } } + @objc var brightnessGesture: Bool { + get { + userDefaults.bool(forKey: Keys.brightnessGesture) + } + set { + userDefaults.set(newValue, forKey: Keys.brightnessGesture) + } + } + @objc var downloadArtwork: Bool { get { userDefaults.bool(forKey: Keys.downloadArtwork) @@ -328,6 +338,7 @@ fileprivate enum Keys { // Changing a value also causes the locally stored value to become unreachable. static let appThemeBlack = "blackTheme" static let automaticallyPlayNextItem = "AutomaticallyPlayNextItem" + static let brightnessGesture = "EnableBrightnessGesture" static let continueAudioInBackground = "BackgroundAudioPlayback" static let defaultPreampLevel = "pre-amp-level" static let downloadArtwork = "download-artwork" diff --git a/Sources/Playback/Player/VideoPlayer-iOS/PlayerController.swift b/Sources/Playback/Player/VideoPlayer-iOS/PlayerController.swift index b3a1d30d1..dd7a05432 100644 --- a/Sources/Playback/Player/VideoPlayer-iOS/PlayerController.swift +++ b/Sources/Playback/Player/VideoPlayer-iOS/PlayerController.swift @@ -53,7 +53,7 @@ class PlayerController: NSObject { } var isBrightnessGestureEnabled: Bool { - return UserDefaults.standard.bool(forKey: kVLCSettingBrightnessGesture) + return VLCDefaults.shared.brightnessGesture } var isSwipeSeekGestureEnabled: Bool { diff --git a/Sources/Settings/Model/SettingsSection.swift b/Sources/Settings/Model/SettingsSection.swift index 90703fed7..d57b44505 100644 --- a/Sources/Settings/Model/SettingsSection.swift +++ b/Sources/Settings/Model/SettingsSection.swift @@ -361,7 +361,7 @@ enum GestureControlOptions { static var swipeUpDownForBrightness: SettingsItem { .toggle(title: "SETTINGS_GESTURES_BRIGHTNESS", subtitle: nil, - preferenceKey: kVLCSettingBrightnessGesture) + keyPath: \.brightnessGesture) } static var swipeRightLeftToSeek: SettingsItem { -- GitLab From aa44131f80117bd403027c848c8832d05521458c Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Sun, 23 Feb 2025 21:10:01 -0500 Subject: [PATCH 22/97] Convert kVLCSettingSeekGesture --- Sources/App/iOS/VLCAppDelegate.m | 1 - Sources/Headers/VLCConstants.h | 1 - Sources/Helpers/VLCDefaults.swift | 11 +++++++++++ .../Player/VideoPlayer-iOS/PlayerController.swift | 2 +- Sources/Settings/Model/SettingsSection.swift | 2 +- 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Sources/App/iOS/VLCAppDelegate.m b/Sources/App/iOS/VLCAppDelegate.m index e38f15bdb..abfbd22d4 100644 --- a/Sources/App/iOS/VLCAppDelegate.m +++ b/Sources/App/iOS/VLCAppDelegate.m @@ -51,7 +51,6 @@ kVLCSettingSubtitlesFontSize : kVLCSettingSubtitlesFontSizeDefaultValue, kVLCSettingSubtitlesBoldFont: kVLCSettingSubtitlesBoldFontDefaultValue, kVLCSettingDeinterlace : kVLCSettingDeinterlaceDefaultValue, - kVLCSettingSeekGesture : @(YES), kVLCSettingCloseGesture : @(YES), kVLCSettingPlaybackLongTouchSpeedUp : @(YES), kVLCSettingVideoFullscreenPlayback : @(YES), diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index 4a8aabe14..999852f64 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -47,7 +47,6 @@ #define kVLCSettingNetworkSatIPChannelListCustom @"CustomList" #define kVLCSettingNetworkSatIPChannelListUrl @"satip-channellist-url" #define kVLCSettingsDecrapifyTitles @"MLDecrapifyTitles" -#define kVLCSettingSeekGesture @"EnableSeekGesture" #define kVLCSettingCloseGesture @"EnableCloseGesture" #define kVLCSettingVideoFullscreenPlayback @"AlwaysUseFullscreenForVideo" #define kVLCSettingContinuePlayback @"ContinuePlayback" diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index 6b0c25234..c0d2c6885 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -36,6 +36,7 @@ Keys.playlistPlayNextItem: true, Keys.playPauseGesture: true, Keys.restoreLastPlayedMedia: true, + Keys.seekGesture: true, Keys.showRemainingTime: false, Keys.stretchAudio: true, Keys.volumeGesture: true, @@ -213,6 +214,15 @@ extension VLCDefaults { } } + @objc var seekGesture: Bool { + get { + userDefaults.bool(forKey: Keys.seekGesture) + } + set { + userDefaults.set(newValue, forKey: Keys.seekGesture) + } + } + @objc var showRemainingTime: Bool { get { userDefaults.bool(forKey: Keys.showRemainingTime) @@ -355,6 +365,7 @@ fileprivate enum Keys { static let playlistPlayNextItem = "PlaylistPlayNextItem" static let playPauseGesture = "EnablePlayPauseGesture" static let restoreLastPlayedMedia = "RestoreLastPlayedMedia" + static let seekGesture = "EnableSeekGesture" static let showRemainingTime = "show-remaining-time" static let stretchAudio = "audio-time-stretch" static let volumeGesture = "EnableVolumeGesture" diff --git a/Sources/Playback/Player/VideoPlayer-iOS/PlayerController.swift b/Sources/Playback/Player/VideoPlayer-iOS/PlayerController.swift index dd7a05432..854835f8f 100644 --- a/Sources/Playback/Player/VideoPlayer-iOS/PlayerController.swift +++ b/Sources/Playback/Player/VideoPlayer-iOS/PlayerController.swift @@ -57,7 +57,7 @@ class PlayerController: NSObject { } var isSwipeSeekGestureEnabled: Bool { - return UserDefaults.standard.bool(forKey: kVLCSettingSeekGesture) + return VLCDefaults.shared.seekGesture } var isCloseGestureEnabled: Bool { diff --git a/Sources/Settings/Model/SettingsSection.swift b/Sources/Settings/Model/SettingsSection.swift index d57b44505..950d55f5b 100644 --- a/Sources/Settings/Model/SettingsSection.swift +++ b/Sources/Settings/Model/SettingsSection.swift @@ -367,7 +367,7 @@ enum GestureControlOptions { static var swipeRightLeftToSeek: SettingsItem { .toggle(title: "SETTINGS_GESTURES_SEEK", subtitle: nil, - preferenceKey: kVLCSettingSeekGesture) + keyPath: \.seekGesture) } static var pinchToClose: SettingsItem { -- GitLab From c9450a3c22719265061538e1e1df3b84fe999776 Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Sun, 23 Feb 2025 21:14:21 -0500 Subject: [PATCH 23/97] Convert kVLCSettingCloseGesture --- Sources/App/iOS/VLCAppDelegate.m | 1 - Sources/Headers/VLCConstants.h | 1 - Sources/Helpers/VLCDefaults.swift | 11 +++++++++++ .../Player/VideoPlayer-iOS/PlayerController.swift | 2 +- Sources/Settings/Model/SettingsSection.swift | 2 +- 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Sources/App/iOS/VLCAppDelegate.m b/Sources/App/iOS/VLCAppDelegate.m index abfbd22d4..0bc8a935f 100644 --- a/Sources/App/iOS/VLCAppDelegate.m +++ b/Sources/App/iOS/VLCAppDelegate.m @@ -51,7 +51,6 @@ kVLCSettingSubtitlesFontSize : kVLCSettingSubtitlesFontSizeDefaultValue, kVLCSettingSubtitlesBoldFont: kVLCSettingSubtitlesBoldFontDefaultValue, kVLCSettingDeinterlace : kVLCSettingDeinterlaceDefaultValue, - kVLCSettingCloseGesture : @(YES), kVLCSettingPlaybackLongTouchSpeedUp : @(YES), kVLCSettingVideoFullscreenPlayback : @(YES), kVLCSettingContinuePlayback : @(1), diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index 999852f64..607b22558 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -47,7 +47,6 @@ #define kVLCSettingNetworkSatIPChannelListCustom @"CustomList" #define kVLCSettingNetworkSatIPChannelListUrl @"satip-channellist-url" #define kVLCSettingsDecrapifyTitles @"MLDecrapifyTitles" -#define kVLCSettingCloseGesture @"EnableCloseGesture" #define kVLCSettingVideoFullscreenPlayback @"AlwaysUseFullscreenForVideo" #define kVLCSettingContinuePlayback @"ContinuePlayback" #define kVLCSettingContinueAudioPlayback @"ContinueAudioPlayback" diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index c0d2c6885..cc2881a79 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -23,6 +23,7 @@ Keys.appThemeBlack: false, Keys.automaticallyPlayNextItem: true, Keys.brightnessGesture: true, + Keys.closeGesture: true, Keys.continueAudioInBackground: true, Keys.downloadArtwork: true, Keys.enableMediaCellTextScrolling: false, @@ -97,6 +98,15 @@ extension VLCDefaults { } } + @objc var closeGesture: Bool { + get { + userDefaults.bool(forKey: Keys.closeGesture) + } + set { + userDefaults.set(newValue, forKey: Keys.closeGesture) + } + } + @objc var downloadArtwork: Bool { get { userDefaults.bool(forKey: Keys.downloadArtwork) @@ -349,6 +359,7 @@ fileprivate enum Keys { static let appThemeBlack = "blackTheme" static let automaticallyPlayNextItem = "AutomaticallyPlayNextItem" static let brightnessGesture = "EnableBrightnessGesture" + static let closeGesture = "EnableCloseGesture" static let continueAudioInBackground = "BackgroundAudioPlayback" static let defaultPreampLevel = "pre-amp-level" static let downloadArtwork = "download-artwork" diff --git a/Sources/Playback/Player/VideoPlayer-iOS/PlayerController.swift b/Sources/Playback/Player/VideoPlayer-iOS/PlayerController.swift index 854835f8f..84fd49bb2 100644 --- a/Sources/Playback/Player/VideoPlayer-iOS/PlayerController.swift +++ b/Sources/Playback/Player/VideoPlayer-iOS/PlayerController.swift @@ -61,7 +61,7 @@ class PlayerController: NSObject { } var isCloseGestureEnabled: Bool { - return UserDefaults.standard.bool(forKey: kVLCSettingCloseGesture) + return VLCDefaults.shared.closeGesture } var isSpeedUpGestureEnabled: Bool { diff --git a/Sources/Settings/Model/SettingsSection.swift b/Sources/Settings/Model/SettingsSection.swift index 950d55f5b..a59f844ac 100644 --- a/Sources/Settings/Model/SettingsSection.swift +++ b/Sources/Settings/Model/SettingsSection.swift @@ -373,7 +373,7 @@ enum GestureControlOptions { static var pinchToClose: SettingsItem { .toggle(title: "SETTINGS_GESTURES_CLOSE", subtitle: nil, - preferenceKey: kVLCSettingCloseGesture) + keyPath: \.closeGesture) } static var forwardBackwardEqual: SettingsItem { -- GitLab From 654132b08e6c1a70a3ed2bcc5d8e9a31826781a0 Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Sun, 23 Feb 2025 21:25:55 -0500 Subject: [PATCH 24/97] Convert kVLCSettingShowThumbnails --- Sources/App/iOS/VLCAppDelegate.m | 1 - Sources/Headers/VLCConstants.h | 2 -- Sources/Helpers/VLCDefaults.swift | 11 +++++++++++ .../MediaLibraryModel/MediaLibraryBaseModel.swift | 2 +- .../Media Library/MediaLibraryModel/MediaModel.swift | 2 +- Sources/Settings/Model/SettingsSection.swift | 2 +- 6 files changed, 14 insertions(+), 6 deletions(-) diff --git a/Sources/App/iOS/VLCAppDelegate.m b/Sources/App/iOS/VLCAppDelegate.m index 0bc8a935f..28608aa0f 100644 --- a/Sources/App/iOS/VLCAppDelegate.m +++ b/Sources/App/iOS/VLCAppDelegate.m @@ -69,7 +69,6 @@ kVLCSettingPlaybackLockscreenSkip : @(NO), kVLCSettingPlaybackRemoteControlSkip : @(NO), kVLCSettingOpenAppForPlayback : kVLCSettingOpenAppForPlaybackDefaultValue, - kVLCSettingShowThumbnails : kVLCSettingShowThumbnailsDefaultValue, kVLCSettingShowArtworks : kVLCSettingShowArtworksDefaultValue, kVLCSettingBackupMediaLibrary : kVLCSettingBackupMediaLibraryDefaultValue, kVLCSettingCastingAudioPassthrough : @(NO), diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index 607b22558..4a112cd76 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -71,8 +71,6 @@ #define kVLCSettingPlaybackRemoteControlSkip @"playback-remote-control-skip" #define kVLCSettingOpenAppForPlayback @"open-app-for-playback" #define kVLCSettingOpenAppForPlaybackDefaultValue @YES -#define kVLCSettingShowThumbnails @"ShowThumbnails" -#define kVLCSettingShowThumbnailsDefaultValue @YES #define kVLCSettingShowArtworks @"ShowArtworks" #define kVLCSettingShowArtworksDefaultValue @YES #define kVLCSettingsDisableGrouping @"MLDisableGrouping" diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index cc2881a79..0ba099797 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -39,6 +39,7 @@ Keys.restoreLastPlayedMedia: true, Keys.seekGesture: true, Keys.showRemainingTime: false, + Keys.showThumbnails: true, Keys.stretchAudio: true, Keys.volumeGesture: true, @@ -242,6 +243,15 @@ extension VLCDefaults { } } + @objc var showThumbnails: Bool { + get { + userDefaults.bool(forKey: Keys.showThumbnails) + } + set { + userDefaults.set(newValue, forKey: Keys.showThumbnails) + } + } + @objc var stretchAudio: Bool { get { userDefaults.bool(forKey: Keys.stretchAudio) @@ -378,6 +388,7 @@ fileprivate enum Keys { static let restoreLastPlayedMedia = "RestoreLastPlayedMedia" static let seekGesture = "EnableSeekGesture" static let showRemainingTime = "show-remaining-time" + static let showThumbnails = "ShowThumbnails" static let stretchAudio = "audio-time-stretch" static let volumeGesture = "EnableVolumeGesture" diff --git a/Sources/Media Library/MediaLibraryModel/MediaLibraryBaseModel.swift b/Sources/Media Library/MediaLibraryModel/MediaLibraryBaseModel.swift index 34360210d..8e078d471 100644 --- a/Sources/Media Library/MediaLibraryModel/MediaLibraryBaseModel.swift +++ b/Sources/Media Library/MediaLibraryModel/MediaLibraryBaseModel.swift @@ -169,7 +169,7 @@ extension MediaCollectionModel { } } if image == nil - || (!UserDefaults.standard.bool(forKey: kVLCSettingShowThumbnails) && self is VLCMLMediaGroup) + || (!VLCDefaults.shared.showThumbnails && self is VLCMLMediaGroup) || (!UserDefaults.standard.bool(forKey: kVLCSettingShowArtworks) && !(self is VLCMLMediaGroup)) { let isDarktheme = PresentationTheme.current.isDark if self is VLCMLMediaGroup { diff --git a/Sources/Media Library/MediaLibraryModel/MediaModel.swift b/Sources/Media Library/MediaLibraryModel/MediaModel.swift index 892bcdf8a..31075ff63 100644 --- a/Sources/Media Library/MediaLibraryModel/MediaModel.swift +++ b/Sources/Media Library/MediaLibraryModel/MediaModel.swift @@ -58,7 +58,7 @@ extension VLCMLMedia { @objc func thumbnailImage() -> UIImage? { var image = VLCThumbnailsCache.thumbnail(for: thumbnail()) if image == nil - || (!UserDefaults.standard.bool(forKey: kVLCSettingShowThumbnails) && subtype() != .albumTrack) + || (!VLCDefaults.shared.showThumbnails && subtype() != .albumTrack) || (!UserDefaults.standard.bool(forKey: kVLCSettingShowArtworks) && subtype() == .albumTrack) { let isDarktheme = PresentationTheme.current.isDark if subtype() == .albumTrack { diff --git a/Sources/Settings/Model/SettingsSection.swift b/Sources/Settings/Model/SettingsSection.swift index a59f844ac..8e03ec441 100644 --- a/Sources/Settings/Model/SettingsSection.swift +++ b/Sources/Settings/Model/SettingsSection.swift @@ -673,7 +673,7 @@ enum MediaLibraryOptions { static var showVideoThumbnails: SettingsItem { .toggle(title: "SETTINGS_SHOW_THUMBNAILS", subtitle: nil, - preferenceKey: kVLCSettingShowThumbnails) + keyPath: \.showThumbnails) } static var showAudioArtworks: SettingsItem { -- GitLab From 4c183bb06b86522e98d0ee5e7506d5078effbaad Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Sun, 23 Feb 2025 21:29:59 -0500 Subject: [PATCH 25/97] Convert kVLCSettingShowArtworks --- Sources/App/iOS/VLCAppDelegate.m | 1 - Sources/Headers/VLCConstants.h | 2 -- Sources/Helpers/VLCDefaults.swift | 10 ++++++++++ .../MediaLibraryModel/MediaLibraryBaseModel.swift | 2 +- .../Media Library/MediaLibraryModel/MediaModel.swift | 2 +- Sources/Settings/Model/SettingsSection.swift | 2 +- 6 files changed, 13 insertions(+), 6 deletions(-) diff --git a/Sources/App/iOS/VLCAppDelegate.m b/Sources/App/iOS/VLCAppDelegate.m index 28608aa0f..757f33854 100644 --- a/Sources/App/iOS/VLCAppDelegate.m +++ b/Sources/App/iOS/VLCAppDelegate.m @@ -69,7 +69,6 @@ kVLCSettingPlaybackLockscreenSkip : @(NO), kVLCSettingPlaybackRemoteControlSkip : @(NO), kVLCSettingOpenAppForPlayback : kVLCSettingOpenAppForPlaybackDefaultValue, - kVLCSettingShowArtworks : kVLCSettingShowArtworksDefaultValue, kVLCSettingBackupMediaLibrary : kVLCSettingBackupMediaLibraryDefaultValue, kVLCSettingCastingAudioPassthrough : @(NO), kVLCSettingCastingConversionQuality : @(2), diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index 4a112cd76..37e72d9db 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -71,8 +71,6 @@ #define kVLCSettingPlaybackRemoteControlSkip @"playback-remote-control-skip" #define kVLCSettingOpenAppForPlayback @"open-app-for-playback" #define kVLCSettingOpenAppForPlaybackDefaultValue @YES -#define kVLCSettingShowArtworks @"ShowArtworks" -#define kVLCSettingShowArtworksDefaultValue @YES #define kVLCSettingsDisableGrouping @"MLDisableGrouping" #define kVLCkVLCSettingsDisableGroupingDefaultValue @NO #define kVLCSettingCastingAudioPassthrough @"sout-chromecast-audio-passthrough" diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index 0ba099797..a18ef875c 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -234,6 +234,15 @@ extension VLCDefaults { } } + @objc var showArtworks: Bool { + get { + userDefaults.bool(forKey: Keys.showArtworks) + } + set { + userDefaults.set(newValue, forKey: Keys.showArtworks) + } + } + @objc var showRemainingTime: Bool { get { userDefaults.bool(forKey: Keys.showRemainingTime) @@ -387,6 +396,7 @@ fileprivate enum Keys { static let playPauseGesture = "EnablePlayPauseGesture" static let restoreLastPlayedMedia = "RestoreLastPlayedMedia" static let seekGesture = "EnableSeekGesture" + static let showArtworks = "ShowArtworks" static let showRemainingTime = "show-remaining-time" static let showThumbnails = "ShowThumbnails" static let stretchAudio = "audio-time-stretch" diff --git a/Sources/Media Library/MediaLibraryModel/MediaLibraryBaseModel.swift b/Sources/Media Library/MediaLibraryModel/MediaLibraryBaseModel.swift index 8e078d471..c93e89dac 100644 --- a/Sources/Media Library/MediaLibraryModel/MediaLibraryBaseModel.swift +++ b/Sources/Media Library/MediaLibraryModel/MediaLibraryBaseModel.swift @@ -170,7 +170,7 @@ extension MediaCollectionModel { } if image == nil || (!VLCDefaults.shared.showThumbnails && self is VLCMLMediaGroup) - || (!UserDefaults.standard.bool(forKey: kVLCSettingShowArtworks) && !(self is VLCMLMediaGroup)) { + || (!VLCDefaults.shared.showArtworks && !(self is VLCMLMediaGroup)) { let isDarktheme = PresentationTheme.current.isDark if self is VLCMLMediaGroup { image = isDarktheme ? UIImage(named: "movie-placeholder-dark") : UIImage(named: "movie-placeholder-white") diff --git a/Sources/Media Library/MediaLibraryModel/MediaModel.swift b/Sources/Media Library/MediaLibraryModel/MediaModel.swift index 31075ff63..af56877fd 100644 --- a/Sources/Media Library/MediaLibraryModel/MediaModel.swift +++ b/Sources/Media Library/MediaLibraryModel/MediaModel.swift @@ -59,7 +59,7 @@ extension VLCMLMedia { var image = VLCThumbnailsCache.thumbnail(for: thumbnail()) if image == nil || (!VLCDefaults.shared.showThumbnails && subtype() != .albumTrack) - || (!UserDefaults.standard.bool(forKey: kVLCSettingShowArtworks) && subtype() == .albumTrack) { + || (!VLCDefaults.shared.showArtworks && subtype() == .albumTrack) { let isDarktheme = PresentationTheme.current.isDark if subtype() == .albumTrack { image = isDarktheme ? UIImage(named: "song-placeholder-dark") : UIImage(named: "song-placeholder-white") diff --git a/Sources/Settings/Model/SettingsSection.swift b/Sources/Settings/Model/SettingsSection.swift index 8e03ec441..91a538709 100644 --- a/Sources/Settings/Model/SettingsSection.swift +++ b/Sources/Settings/Model/SettingsSection.swift @@ -679,7 +679,7 @@ enum MediaLibraryOptions { static var showAudioArtworks: SettingsItem { .toggle(title: "SETTINGS_SHOW_ARTWORKS", subtitle: nil, - preferenceKey: kVLCSettingShowArtworks) + keyPath: \.showArtworks) } static var includeMediaLibInDeviceBackup: SettingsItem { -- GitLab From 7f3e8f87de11859ca8d2e1c7259508d5a0b9508d Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Sun, 23 Feb 2025 21:33:42 -0500 Subject: [PATCH 26/97] Convert kVLCSettingPlaybackLongTouchSpeedUp --- Sources/App/iOS/VLCAppDelegate.m | 1 - Sources/Headers/VLCConstants.h | 1 - Sources/Helpers/VLCDefaults.swift | 11 +++++++++++ .../Player/VideoPlayer-iOS/PlayerController.swift | 2 +- Sources/Settings/Model/SettingsSection.swift | 2 +- 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Sources/App/iOS/VLCAppDelegate.m b/Sources/App/iOS/VLCAppDelegate.m index 757f33854..f1d4380cc 100644 --- a/Sources/App/iOS/VLCAppDelegate.m +++ b/Sources/App/iOS/VLCAppDelegate.m @@ -51,7 +51,6 @@ kVLCSettingSubtitlesFontSize : kVLCSettingSubtitlesFontSizeDefaultValue, kVLCSettingSubtitlesBoldFont: kVLCSettingSubtitlesBoldFontDefaultValue, kVLCSettingDeinterlace : kVLCSettingDeinterlaceDefaultValue, - kVLCSettingPlaybackLongTouchSpeedUp : @(YES), kVLCSettingVideoFullscreenPlayback : @(YES), kVLCSettingContinuePlayback : @(1), kVLCSettingContinueAudioPlayback : @(1), diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index 37e72d9db..3616f1eb6 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -65,7 +65,6 @@ #define kVLCSettingPlaybackForwardSkipLengthSwipe @"playback-forward-skip-length-swipe" #define kVLCSettingPlaybackForwardSkipLengthSwipeDefaultValue @(10) #define kVLCSettingPlaybackBackwardSkipLengthSwipe @"playback-backward-skip-length-swipe" -#define kVLCSettingPlaybackLongTouchSpeedUp @"LongTouchSpeedUp" #define kVLCSettingPlaybackBackwardSkipLengthSwipeDefaultValue @(10) #define kVLCSettingPlaybackLockscreenSkip @"playback-lockscreen-skip" #define kVLCSettingPlaybackRemoteControlSkip @"playback-remote-control-skip" diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index a18ef875c..6beb38c98 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -31,6 +31,7 @@ Keys.hideLibraryInFilesApp: false, Keys.passcodeEnableBiometricAuth: true, Keys.pauseWhenShowingControls: false, + Keys.playbackLongTouchSpeedUp: true, Keys.playerShouldRememberBrightness: false, Keys.playerShouldRememberState: true, Keys.playerShowPlaybackSpeedShortcut: false, @@ -162,6 +163,15 @@ extension VLCDefaults { } } + @objc var playbackLongTouchSpeedUp: Bool { + get { + userDefaults.bool(forKey: Keys.playbackLongTouchSpeedUp) + } + set { + userDefaults.set(newValue, forKey: Keys.playbackLongTouchSpeedUp) + } + } + @objc var playerShouldRememberBrightness: Bool { get { userDefaults.bool(forKey: Keys.playerShouldRememberBrightness) @@ -389,6 +399,7 @@ fileprivate enum Keys { static let networkCaching = "network-caching" static let passcodeEnableBiometricAuth = "EnableBiometricAuth" static let pauseWhenShowingControls = "kVLCSettingPauseWhenShowingControls" + static let playbackLongTouchSpeedUp = "LongTouchSpeedUp" static let playerShouldRememberBrightness = "PlayerShouldRememberBrightness" static let playerShouldRememberState = "PlayerShouldRememberState" static let playerShowPlaybackSpeedShortcut = "kVLCPlayerShowPlaybackSpeedShortcut" diff --git a/Sources/Playback/Player/VideoPlayer-iOS/PlayerController.swift b/Sources/Playback/Player/VideoPlayer-iOS/PlayerController.swift index 84fd49bb2..1d8b348df 100644 --- a/Sources/Playback/Player/VideoPlayer-iOS/PlayerController.swift +++ b/Sources/Playback/Player/VideoPlayer-iOS/PlayerController.swift @@ -65,7 +65,7 @@ class PlayerController: NSObject { } var isSpeedUpGestureEnabled: Bool { - return UserDefaults.standard.bool(forKey: kVLCSettingPlaybackLongTouchSpeedUp) + return VLCDefaults.shared.playbackLongTouchSpeedUp } var isShuffleEnabled: Bool { diff --git a/Sources/Settings/Model/SettingsSection.swift b/Sources/Settings/Model/SettingsSection.swift index 91a538709..30420b29e 100644 --- a/Sources/Settings/Model/SettingsSection.swift +++ b/Sources/Settings/Model/SettingsSection.swift @@ -419,7 +419,7 @@ enum GestureControlOptions { static var longTouchToSpeedUp: SettingsItem { .toggle(title: "SETINGS_LONG_TOUCH_SPEED_UP", subtitle: nil, - preferenceKey: kVLCSettingPlaybackLongTouchSpeedUp) + keyPath: \.playbackLongTouchSpeedUp) } static var lockScreenSkip: SettingsItem { -- GitLab From 225b77d89d057a5a73ab37658afc43a3dddd34cb Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Sun, 23 Feb 2025 21:38:12 -0500 Subject: [PATCH 27/97] Convert kVLCSettingVideoFullscreenPlayback --- Sources/App/iOS/VLCAppDelegate.m | 1 - Sources/Headers/VLCConstants.h | 1 - Sources/Helpers/VLCDefaults.swift | 11 +++++++++++ Sources/Playback/Control/VLCPlayerDisplayController.m | 3 +-- Sources/Settings/Model/SettingsSection.swift | 2 +- 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Sources/App/iOS/VLCAppDelegate.m b/Sources/App/iOS/VLCAppDelegate.m index f1d4380cc..d5f6049ac 100644 --- a/Sources/App/iOS/VLCAppDelegate.m +++ b/Sources/App/iOS/VLCAppDelegate.m @@ -51,7 +51,6 @@ kVLCSettingSubtitlesFontSize : kVLCSettingSubtitlesFontSizeDefaultValue, kVLCSettingSubtitlesBoldFont: kVLCSettingSubtitlesBoldFontDefaultValue, kVLCSettingDeinterlace : kVLCSettingDeinterlaceDefaultValue, - kVLCSettingVideoFullscreenPlayback : @(YES), kVLCSettingContinuePlayback : @(1), kVLCSettingContinueAudioPlayback : @(1), kVLCSettingWiFiSharingIPv6 : kVLCSettingWiFiSharingIPv6DefaultValue, diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index 3616f1eb6..8454f2eb2 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -47,7 +47,6 @@ #define kVLCSettingNetworkSatIPChannelListCustom @"CustomList" #define kVLCSettingNetworkSatIPChannelListUrl @"satip-channellist-url" #define kVLCSettingsDecrapifyTitles @"MLDecrapifyTitles" -#define kVLCSettingVideoFullscreenPlayback @"AlwaysUseFullscreenForVideo" #define kVLCSettingContinuePlayback @"ContinuePlayback" #define kVLCSettingContinueAudioPlayback @"ContinueAudioPlayback" #define kVLCSettingPlaybackSpeedDefaultValue @"playback-speed" diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index 6beb38c98..743e2c90b 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -42,6 +42,7 @@ Keys.showRemainingTime: false, Keys.showThumbnails: true, Keys.stretchAudio: true, + Keys.videoFullscreenPlayback: true, Keys.volumeGesture: true, // numbers @@ -280,6 +281,15 @@ extension VLCDefaults { } } + @objc var videoFullscreenPlayback: Bool { + get { + userDefaults.bool(forKey: Keys.videoFullscreenPlayback) + } + set { + userDefaults.set(newValue, forKey: Keys.videoFullscreenPlayback) + } + } + @objc var volumeGesture: Bool { get { userDefaults.bool(forKey: Keys.volumeGesture) @@ -411,6 +421,7 @@ fileprivate enum Keys { static let showRemainingTime = "show-remaining-time" static let showThumbnails = "ShowThumbnails" static let stretchAudio = "audio-time-stretch" + static let videoFullscreenPlayback = "AlwaysUseFullscreenForVideo" static let volumeGesture = "EnableVolumeGesture" static func videoLibraryGridLayout(collectionModelName: String? = nil, name: String) -> String { diff --git a/Sources/Playback/Control/VLCPlayerDisplayController.m b/Sources/Playback/Control/VLCPlayerDisplayController.m index b614d2875..727806dcd 100644 --- a/Sources/Playback/Control/VLCPlayerDisplayController.m +++ b/Sources/Playback/Control/VLCPlayerDisplayController.m @@ -165,8 +165,7 @@ NSString *const VLCPlayerDisplayControllerHideMiniPlayer = @"VLCPlayerDisplayCon - (void)playbackDidStart:(NSNotification *)notification { - NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; - BOOL enforceFullscreen = [[defaults objectForKey:kVLCSettingVideoFullscreenPlayback] boolValue]; + BOOL enforceFullscreen = VLCDefaults.shared.videoFullscreenPlayback; VLCMedia *currentMedia = _playbackController.currentlyPlayingMedia; VLCMLMedia *media = [VLCMLMedia mediaForPlayingMedia:currentMedia]; diff --git a/Sources/Settings/Model/SettingsSection.swift b/Sources/Settings/Model/SettingsSection.swift index 30420b29e..50ab07989 100644 --- a/Sources/Settings/Model/SettingsSection.swift +++ b/Sources/Settings/Model/SettingsSection.swift @@ -243,7 +243,7 @@ enum GenericOptions { static var playVideoInFullScreen: SettingsItem { .toggle(title: "SETTINGS_VIDEO_FULLSCREEN", subtitle: nil, - preferenceKey: kVLCSettingVideoFullscreenPlayback) + keyPath: \.videoFullscreenPlayback) } static var continueVideoPlayback: SettingsItem { -- GitLab From b06395979ee579b64ddbc851a9118fb68d23bcd1 Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Sun, 23 Feb 2025 21:47:55 -0500 Subject: [PATCH 28/97] Convert kVLCSettingNetworkRTSPTCP --- Sources/About/AboutController.swift | 2 +- Sources/App/iOS/VLCAppDelegate.m | 1 - Sources/App/tvOS/AppleTVAppDelegate.m | 1 - Sources/Headers/VLCConstants.h | 1 - Sources/Headers/VLCTVConstants.h | 1 - Sources/Helpers/VLCDefaults.swift | 16 +++++++++++++--- Sources/Playback/Control/VLCPlaybackService.m | 9 +++------ Sources/Settings/Model/SettingsSection.swift | 2 +- 8 files changed, 18 insertions(+), 15 deletions(-) diff --git a/Sources/About/AboutController.swift b/Sources/About/AboutController.swift index 41c352cb8..b532d8873 100644 --- a/Sources/About/AboutController.swift +++ b/Sources/About/AboutController.swift @@ -195,7 +195,7 @@ class AboutController: UIViewController, MFMailComposeViewControllerDelegate, UI VLCDefaults.shared.hardwareDecoding == .hardware ? 0 : 1, // TODO: unsure VLCDefaults.shared.networkCaching.rawValue, defaults.integer(forKey: kVLCSettingSkipLoopFilter), - defaults.integer(forKey: kVLCSettingNetworkRTSPTCP), + VLCDefaults.shared.networkRTSPTCP ? 1 : 0, VLCDefaults.shared.stretchAudio ? 1 : 0) // TODO: unsure return prefilledFeedback } diff --git a/Sources/App/iOS/VLCAppDelegate.m b/Sources/App/iOS/VLCAppDelegate.m index d5f6049ac..14214d097 100644 --- a/Sources/App/iOS/VLCAppDelegate.m +++ b/Sources/App/iOS/VLCAppDelegate.m @@ -54,7 +54,6 @@ kVLCSettingContinuePlayback : @(1), kVLCSettingContinueAudioPlayback : @(1), kVLCSettingWiFiSharingIPv6 : kVLCSettingWiFiSharingIPv6DefaultValue, - kVLCSettingNetworkRTSPTCP : @(NO), kVLCSettingNetworkSatIPChannelListUrl : @"", kVLCSettingEqualizerProfile : kVLCSettingEqualizerProfileDefaultValue, kVLCSettingEqualizerProfileDisabled : @(YES), diff --git a/Sources/App/tvOS/AppleTVAppDelegate.m b/Sources/App/tvOS/AppleTVAppDelegate.m index dcc83b9b6..52fb1a38a 100644 --- a/Sources/App/tvOS/AppleTVAppDelegate.m +++ b/Sources/App/tvOS/AppleTVAppDelegate.m @@ -47,7 +47,6 @@ kVLCSettingSubtitlesFontSize : kVLCSettingSubtitlesFontSizeDefaultValue, kVLCSettingSubtitlesBoldFont: kVLCSettingSubtitlesBoldFontDefaultValue, kVLCSettingDeinterlace : kVLCSettingDeinterlaceDefaultValue, - kVLCSettingNetworkRTSPTCP : @(NO), kVLCSettingNetworkSatIPChannelListUrl : @"", kVLCSettingEqualizerProfileDisabled : @(YES), kVLCSettingEqualizerProfile : kVLCSettingEqualizerProfileDefaultValue, diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index 8454f2eb2..34511903b 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -41,7 +41,6 @@ #define kVLCSettingDeinterlace @"deinterlace" #define kVLCSettingDeinterlaceDefaultValue @(-1) #define kVLCSettingRotationLock @"kVLCSettingRotationLock" -#define kVLCSettingNetworkRTSPTCP @"rtsp-tcp" #define kVLCSaveDebugLogs @"kVLCSaveDebugLogs" #define kVLCSettingNetworkSatIPChannelList @"satip-channelist" #define kVLCSettingNetworkSatIPChannelListCustom @"CustomList" diff --git a/Sources/Headers/VLCTVConstants.h b/Sources/Headers/VLCTVConstants.h index 270c33e11..9a6505974 100644 --- a/Sources/Headers/VLCTVConstants.h +++ b/Sources/Headers/VLCTVConstants.h @@ -26,7 +26,6 @@ #define kSupportedProtocolSchemes @"(rtsp|mms|mmsh|udp|rtp|rtmp|sftp|ftp|smb)$" #define kVLCSettingPlaybackSpeedDefaultValue @"playback-speed" -#define kVLCSettingNetworkRTSPTCP @"rtsp-tcp" #define kVLCSaveDebugLogs @"kVLCSaveDebugLogs" #define kVLCSettingNetworkSatIPChannelList @"satip-channelist" #define kVLCSettingNetworkSatIPChannelListCustom @"CustomList" diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index 743e2c90b..17e28b7d3 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -29,6 +29,7 @@ Keys.enableMediaCellTextScrolling: false, Keys.forceSMBV1: true, Keys.hideLibraryInFilesApp: false, + Keys.networkRTSPTCP: false, Keys.passcodeEnableBiometricAuth: true, Keys.pauseWhenShowingControls: false, Keys.playbackLongTouchSpeedUp: true, @@ -155,6 +156,15 @@ extension VLCDefaults { } } + @objc var networkRTSPTCP: Bool { + get { + userDefaults.bool(forKey: Keys.networkRTSPTCP) + } + set { + userDefaults.set(newValue, forKey: Keys.networkRTSPTCP) + } + } + @objc var pauseWhenShowingControls: Bool { get { userDefaults.bool(forKey: Keys.pauseWhenShowingControls) @@ -360,10 +370,9 @@ extension VLCDefaults { final class Compat: NSObject { static let automaticallyPlayNextItemKey: String = Keys.automaticallyPlayNextItem static let defaultPreampLevelKey: String = Keys.defaultPreampLevel - @objc static let hardwareDecodingKey: String = Keys.hardwareDecoding + static let hardwareDecodingKey: String = Keys.hardwareDecoding static let hideLibraryInFilesAppKey: String = Keys.hideLibraryInFilesApp - @objc static let networkCachingKey: String = Keys.networkCaching - @objc static let stretchAudioKey: String = Keys.stretchAudio + static let networkCachingKey: String = Keys.networkCaching override init() { fatalError("compat struct not intended to be instantiated") @@ -407,6 +416,7 @@ fileprivate enum Keys { static let hardwareDecoding = "codec" static let hideLibraryInFilesApp = "HideLibraryInFilesApp" static let networkCaching = "network-caching" + static let networkRTSPTCP = "rtsp-tcp" static let passcodeEnableBiometricAuth = "EnableBiometricAuth" static let pauseWhenShowingControls = "kVLCSettingPauseWhenShowingControls" static let playbackLongTouchSpeedUp = "LongTouchSpeedUp" diff --git a/Sources/Playback/Control/VLCPlaybackService.m b/Sources/Playback/Control/VLCPlaybackService.m index 4f4658d01..ac2204c8b 100644 --- a/Sources/Playback/Control/VLCPlaybackService.m +++ b/Sources/Playback/Control/VLCPlaybackService.m @@ -1778,14 +1778,11 @@ NSString *const VLCLastPlaylistPlayedMedia = @"LastPlaylistPlayedMedia"; { NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; - NSString *codecKey = VLCDefaultsCompat.hardwareDecodingKey; - NSString *networkCachingKey = VLCDefaultsCompat.networkCachingKey; - - return @{ networkCachingKey : [NSNumber numberWithInteger: VLCDefaults.shared.networkCachingObjC], + return @{ @"network-caching" : [NSNumber numberWithInteger:VLCDefaults.shared.networkCachingObjC], kVLCSettingTextEncoding : [defaults objectForKey:kVLCSettingTextEncoding], kVLCSettingSkipLoopFilter : [defaults objectForKey:kVLCSettingSkipLoopFilter], - codecKey : VLCDefaults.shared.hardwareDecodingObjC, - kVLCSettingNetworkRTSPTCP : [defaults objectForKey:kVLCSettingNetworkRTSPTCP] + @"codec" : VLCDefaults.shared.hardwareDecodingObjC, + @"rtsp-tcp" : [NSNumber numberWithBool:VLCDefaults.shared.networkRTSPTCP] }; } diff --git a/Sources/Settings/Model/SettingsSection.swift b/Sources/Settings/Model/SettingsSection.swift index 50ab07989..0caa299d7 100644 --- a/Sources/Settings/Model/SettingsSection.swift +++ b/Sources/Settings/Model/SettingsSection.swift @@ -736,7 +736,7 @@ enum NetworkOptions { static var rtspctp: SettingsItem { .toggle(title: "SETTINGS_RTSP_TCP", subtitle: nil, - preferenceKey: kVLCSettingNetworkRTSPTCP) + keyPath: \.networkRTSPTCP) } static func section() -> SettingsSection? { -- GitLab From 34a1be120e180a082b0e0c46eee397280b274d38 Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Sun, 23 Feb 2025 22:06:56 -0500 Subject: [PATCH 29/97] Convert kVLCSettingTextEncoding --- Sources/App/iOS/VLCAppDelegate.m | 1 - Sources/App/tvOS/AppleTVAppDelegate.m | 3 +-- Sources/Headers/VLCConstants.h | 2 -- Sources/Headers/VLCTVConstants.h | 2 -- Sources/Helpers/VLCDefaults.swift | 18 ++++++++++++++++++ Sources/Playback/Control/VLCPlaybackService.m | 4 ++-- Sources/Settings/Model/SettingsSection.swift | 2 +- 7 files changed, 22 insertions(+), 10 deletions(-) diff --git a/Sources/App/iOS/VLCAppDelegate.m b/Sources/App/iOS/VLCAppDelegate.m index 14214d097..d34e1e6d9 100644 --- a/Sources/App/iOS/VLCAppDelegate.m +++ b/Sources/App/iOS/VLCAppDelegate.m @@ -44,7 +44,6 @@ [VLCDefaults.shared registerDefaults]; NSDictionary *appDefaults = @{kVLCSettingAppTheme : @(appThemeIndex), - kVLCSettingTextEncoding : kVLCSettingTextEncodingDefaultValue, kVLCSettingSkipLoopFilter : kVLCSettingSkipLoopFilterNonRef, kVLCSettingSubtitlesFont : kVLCSettingSubtitlesFontDefaultValue, kVLCSettingSubtitlesFontColor : kVLCSettingSubtitlesFontColorDefaultValue, diff --git a/Sources/App/tvOS/AppleTVAppDelegate.m b/Sources/App/tvOS/AppleTVAppDelegate.m index 52fb1a38a..85e94ed0d 100644 --- a/Sources/App/tvOS/AppleTVAppDelegate.m +++ b/Sources/App/tvOS/AppleTVAppDelegate.m @@ -40,8 +40,7 @@ { NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; - NSDictionary *appDefaults = @{kVLCSettingTextEncoding : kVLCSettingTextEncodingDefaultValue, - kVLCSettingSkipLoopFilter : kVLCSettingSkipLoopFilterNonRef, + NSDictionary *appDefaults = @{kVLCSettingSkipLoopFilter : kVLCSettingSkipLoopFilterNonRef, kVLCSettingSubtitlesFont : kVLCSettingSubtitlesFontDefaultValue, kVLCSettingSubtitlesFontColor : kVLCSettingSubtitlesFontColorDefaultValue, kVLCSettingSubtitlesFontSize : kVLCSettingSubtitlesFontSizeDefaultValue, diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index 34511903b..ffc261681 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -22,8 +22,6 @@ #define kVLCLastPlayedPlaylist @"LastPlayedPlaylist" #define kVLCIsCurrentlyPlayingPlaylist @"isPlaylistCurrentlyPlaying" #define kVLCCurrentPlaylistMediasQueue @"currentPlaylistMediasQueue" -#define kVLCSettingTextEncoding @"subsdec-encoding" -#define kVLCSettingTextEncodingDefaultValue @"Windows-1252" #define kVLCSettingSkipLoopFilter @"avcodec-skiploopfilter" #define kVLCSettingSkipLoopFilterNone @(0) #define kVLCSettingSkipLoopFilterNonRef @(1) diff --git a/Sources/Headers/VLCTVConstants.h b/Sources/Headers/VLCTVConstants.h index 9a6505974..790c5d540 100644 --- a/Sources/Headers/VLCTVConstants.h +++ b/Sources/Headers/VLCTVConstants.h @@ -45,8 +45,6 @@ #define kVLCSettingSubtitlesFontColor @"quartztext-color" #define kVLCSettingSubtitlesFontColorDefaultValue @"16777215" #define kVLCSubtitlesCacheFolderName @"cached-subtitles" -#define kVLCSettingTextEncoding @"subsdec-encoding" -#define kVLCSettingTextEncodingDefaultValue @"Windows-1252" #define kVLCSettingSubtitlesFilePath @"sub-file" #define kVLCSettingEqualizerProfile @"EqualizerProfile" #define kVLCSettingEqualizerProfileDisabled @"EqualizerDisabled" diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index 17e28b7d3..547b98324 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -52,6 +52,7 @@ // other Keys.hardwareDecoding: HardwareDecoding.hardware.rawValue, Keys.networkCaching: NetworkCaching.normal.rawValue, + Keys.textEncoding: DefaultValues.textEncoding, ] [ @@ -353,6 +354,15 @@ extension VLCDefaults { networkCaching.rawValue } + @objc var textEncoding: String { + get { + userDefaults.string(forKey: Keys.textEncoding) ?? DefaultValues.textEncoding + } + set { + userDefaults.set(newValue, forKey: Keys.textEncoding) + } + } + func videoLibraryGridLayout(collectionModelName: String? = nil, name: String) -> Bool { userDefaults.bool(forKey: Keys.videoLibraryGridLayout(collectionModelName: collectionModelName, name: name)) } @@ -373,6 +383,7 @@ extension VLCDefaults { static let hardwareDecodingKey: String = Keys.hardwareDecoding static let hideLibraryInFilesAppKey: String = Keys.hideLibraryInFilesApp static let networkCachingKey: String = Keys.networkCaching + static let textEncodingKey: String = Keys.textEncoding override init() { fatalError("compat struct not intended to be instantiated") @@ -431,6 +442,7 @@ fileprivate enum Keys { static let showRemainingTime = "show-remaining-time" static let showThumbnails = "ShowThumbnails" static let stretchAudio = "audio-time-stretch" + static let textEncoding = "subsdec-encoding" static let videoFullscreenPlayback = "AlwaysUseFullscreenForVideo" static let volumeGesture = "EnableVolumeGesture" @@ -440,3 +452,9 @@ fileprivate enum Keys { ].compactMap { $0 }.joined() } } + +// MARK: - Default Values + +fileprivate enum DefaultValues { + static let textEncoding = "Windows-1252" +} diff --git a/Sources/Playback/Control/VLCPlaybackService.m b/Sources/Playback/Control/VLCPlaybackService.m index ac2204c8b..42881c742 100644 --- a/Sources/Playback/Control/VLCPlaybackService.m +++ b/Sources/Playback/Control/VLCPlaybackService.m @@ -1779,8 +1779,8 @@ NSString *const VLCLastPlaylistPlayedMedia = @"LastPlaylistPlayedMedia"; NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; return @{ @"network-caching" : [NSNumber numberWithInteger:VLCDefaults.shared.networkCachingObjC], - kVLCSettingTextEncoding : [defaults objectForKey:kVLCSettingTextEncoding], - kVLCSettingSkipLoopFilter : [defaults objectForKey:kVLCSettingSkipLoopFilter], + @"subsdec-encoding" : VLCDefaults.shared.textEncoding, + @"avcodec-skiploopfilter" : [defaults objectForKey:kVLCSettingSkipLoopFilter], @"codec" : VLCDefaults.shared.hardwareDecodingObjC, @"rtsp-tcp" : [NSNumber numberWithBool:VLCDefaults.shared.networkRTSPTCP] }; diff --git a/Sources/Settings/Model/SettingsSection.swift b/Sources/Settings/Model/SettingsSection.swift index 0caa299d7..c0d0073a3 100644 --- a/Sources/Settings/Model/SettingsSection.swift +++ b/Sources/Settings/Model/SettingsSection.swift @@ -575,7 +575,7 @@ enum SubtitlesOptions { } static var textEncoding: SettingsItem { - let k = kVLCSettingTextEncoding + let k = VLCDefaults.Compat.textEncodingKey return .init(title: "SETTINGS_SUBTITLES_TEXT_ENCODING", subtitle: Localizer.getSubtitle(for: k), action: .showActionSheet(title: "SETTINGS_SUBTITLES_TEXT_ENCODING", preferenceKey: k, hasInfo: true)) -- GitLab From 69539e80e74745424fd6f6d54250f78933c6a48f Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Mon, 24 Feb 2025 21:18:29 -0500 Subject: [PATCH 30/97] Convert kVLCSettingEqualizerProfileDisabled --- Sources/App/iOS/VLCAppDelegate.m | 1 - Sources/App/tvOS/AppleTVAppDelegate.m | 1 - Sources/Headers/VLCConstants.h | 1 - Sources/Headers/VLCTVConstants.h | 1 - Sources/Helpers/VLCDefaults.swift | 11 +++++++++++ Sources/Playback/Control/VLCPlaybackService.m | 8 ++++---- .../VideoPlayer-iOS/Subviews/EqualizerView.swift | 6 +++--- 7 files changed, 18 insertions(+), 11 deletions(-) diff --git a/Sources/App/iOS/VLCAppDelegate.m b/Sources/App/iOS/VLCAppDelegate.m index d34e1e6d9..d634b0ab6 100644 --- a/Sources/App/iOS/VLCAppDelegate.m +++ b/Sources/App/iOS/VLCAppDelegate.m @@ -55,7 +55,6 @@ kVLCSettingWiFiSharingIPv6 : kVLCSettingWiFiSharingIPv6DefaultValue, kVLCSettingNetworkSatIPChannelListUrl : @"", kVLCSettingEqualizerProfile : kVLCSettingEqualizerProfileDefaultValue, - kVLCSettingEqualizerProfileDisabled : @(YES), kVLCSettingPlaybackForwardBackwardEqual: @(YES), kVLCSettingPlaybackTapSwipeEqual: @(YES), kVLCSettingPlaybackForwardSkipLength : kVLCSettingPlaybackForwardSkipLengthDefaultValue, diff --git a/Sources/App/tvOS/AppleTVAppDelegate.m b/Sources/App/tvOS/AppleTVAppDelegate.m index 85e94ed0d..a2ad50189 100644 --- a/Sources/App/tvOS/AppleTVAppDelegate.m +++ b/Sources/App/tvOS/AppleTVAppDelegate.m @@ -47,7 +47,6 @@ kVLCSettingSubtitlesBoldFont: kVLCSettingSubtitlesBoldFontDefaultValue, kVLCSettingDeinterlace : kVLCSettingDeinterlaceDefaultValue, kVLCSettingNetworkSatIPChannelListUrl : @"", - kVLCSettingEqualizerProfileDisabled : @(YES), kVLCSettingEqualizerProfile : kVLCSettingEqualizerProfileDefaultValue, kVLCSettingPlaybackForwardSkipLength : kVLCSettingPlaybackForwardSkipLengthDefaultValue, kVLCSettingPlaybackBackwardSkipLength : kVLCSettingPlaybackBackwardSkipLengthDefaultValue, diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index ffc261681..0da9b7053 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -50,7 +50,6 @@ #define kVLCSettingWiFiSharingIPv6 @"wifi-sharing-ipv6" #define kVLCSettingWiFiSharingIPv6DefaultValue @(NO) #define kVLCSettingEqualizerProfile @"EqualizerProfile" -#define kVLCSettingEqualizerProfileDisabled @"EqualizerDisabled" #define kVLCSettingEqualizerProfileDefaultValue @(0) #define kVLCSettingPlaybackForwardBackwardEqual @"playback-forward-backward-equal" #define kVLCSettingPlaybackTapSwipeEqual @"playback-tap-swipe-equal" diff --git a/Sources/Headers/VLCTVConstants.h b/Sources/Headers/VLCTVConstants.h index 790c5d540..e6cd14525 100644 --- a/Sources/Headers/VLCTVConstants.h +++ b/Sources/Headers/VLCTVConstants.h @@ -47,7 +47,6 @@ #define kVLCSubtitlesCacheFolderName @"cached-subtitles" #define kVLCSettingSubtitlesFilePath @"sub-file" #define kVLCSettingEqualizerProfile @"EqualizerProfile" -#define kVLCSettingEqualizerProfileDisabled @"EqualizerDisabled" #define kVLCSettingEqualizerProfileDefaultValue @(0) #define kVLCSettingPlaybackForwardSkipLength @"playback-forward-skip-length" #define kVLCSettingPlaybackForwardSkipLengthDefaultValue @(10) diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index 547b98324..ffe3b14ab 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -27,6 +27,7 @@ Keys.continueAudioInBackground: true, Keys.downloadArtwork: true, Keys.enableMediaCellTextScrolling: false, + Keys.equalizerProfileDisabled: true, Keys.forceSMBV1: true, Keys.hideLibraryInFilesApp: false, Keys.networkRTSPTCP: false, @@ -139,6 +140,15 @@ extension VLCDefaults { } } + @objc var equalizerProfileDisabled: Bool { + get { + userDefaults.bool(forKey: Keys.equalizerProfileDisabled) + } + set { + userDefaults.set(newValue, forKey: Keys.equalizerProfileDisabled) + } + } + @objc var forceSMBV1: Bool { get { userDefaults.bool(forKey: Keys.forceSMBV1) @@ -423,6 +433,7 @@ fileprivate enum Keys { static let defaultPreampLevel = "pre-amp-level" static let downloadArtwork = "download-artwork" static let enableMediaCellTextScrolling = "EnableMediaCellTextScrolling" + static let equalizerProfileDisabled = "EqualizerDisabled" static let forceSMBV1 = "smb-force-v1" static let hardwareDecoding = "codec" static let hideLibraryInFilesApp = "HideLibraryInFilesApp" diff --git a/Sources/Playback/Control/VLCPlaybackService.m b/Sources/Playback/Control/VLCPlaybackService.m index 42881c742..16856ac99 100644 --- a/Sources/Playback/Control/VLCPlaybackService.m +++ b/Sources/Playback/Control/VLCPlaybackService.m @@ -341,7 +341,7 @@ NSString *const VLCLastPlaylistPlayedMedia = @"LastPlaylistPlayedMedia"; } NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults]; - BOOL equalizerEnabled = ![userDefaults boolForKey:kVLCSettingEqualizerProfileDisabled]; + BOOL equalizerEnabled = !VLCDefaults.shared.equalizerProfileDisabled; VLCAudioEqualizer *equalizer; @@ -1403,7 +1403,7 @@ NSString *const VLCLastPlaylistPlayedMedia = @"LastPlaylistPlayedMedia"; NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults]; if (profile == 0) { _mediaPlayer.equalizer = nil; - [userDefaults setBool:YES forKey:kVLCSettingEqualizerProfileDisabled]; + VLCDefaults.shared.equalizerProfileDisabled = YES; float preampValue = VLCDefaults.shared.defaultPreampLevel; if (preampValue != 6.0) { @@ -1415,7 +1415,7 @@ NSString *const VLCLastPlaylistPlayedMedia = @"LastPlaylistPlayedMedia"; return; } - [userDefaults setBool:NO forKey:kVLCSettingEqualizerProfileDisabled]; + VLCDefaults.shared.equalizerProfileDisabled = NO; unsigned int actualProfile = profile - 1; [userDefaults setInteger:actualProfile forKey:kVLCSettingEqualizerProfile]; @@ -1472,7 +1472,7 @@ NSString *const VLCLastPlaylistPlayedMedia = @"LastPlaylistPlayedMedia"; /* this is a bit complex, if the eq is off, we need to return 0 * if it is on, we need to provide the profile + 1 as the UI fakes a "Off" profile in its list */ NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults]; - if ([userDefaults boolForKey:kVLCSettingEqualizerProfileDisabled]) { + if (VLCDefaults.shared.equalizerProfileDisabled) { return [NSIndexPath indexPathForRow:0 inSection:0]; } diff --git a/Sources/Playback/Player/VideoPlayer-iOS/Subviews/EqualizerView.swift b/Sources/Playback/Player/VideoPlayer-iOS/Subviews/EqualizerView.swift index 21eed831a..f05bbef26 100644 --- a/Sources/Playback/Player/VideoPlayer-iOS/Subviews/EqualizerView.swift +++ b/Sources/Playback/Player/VideoPlayer-iOS/Subviews/EqualizerView.swift @@ -462,7 +462,7 @@ extension EqualizerView { let userDefaults = UserDefaults.standard userDefaults.setValue(NSKeyedArchiver.archivedData(withRootObject: customProfiles), forKey: kVLCCustomEqualizerProfiles) userDefaults.setValue(true, forKey: kVLCCustomProfileEnabled) - userDefaults.setValue(false, forKey: kVLCSettingEqualizerProfileDisabled) + VLCDefaults.shared.equalizerProfileDisabled = false userDefaults.setValue(index, forKey: kVLCSettingEqualizerProfile) self.presetSelectorView?.presetsTableView.reloadData() @@ -480,7 +480,7 @@ extension EqualizerView { @objc func resetEqualizer() { let userDefaults = UserDefaults.standard - let isEqualizerDisabled = userDefaults.bool(forKey: kVLCSettingEqualizerProfileDisabled) + let isEqualizerDisabled = VLCDefaults.shared.equalizerProfileDisabled let isCustomProfile = userDefaults.bool(forKey: kVLCCustomProfileEnabled) let profile: Int @@ -519,7 +519,7 @@ extension EqualizerView { } userDefaults.setValue(index, forKey: kVLCSettingEqualizerProfile) - userDefaults.setValue(false, forKey: kVLCSettingEqualizerProfileDisabled) + VLCDefaults.shared.equalizerProfileDisabled = false userDefaults.setValue(true, forKey: kVLCCustomProfileEnabled) } -- GitLab From 5a5cffd0eaafb0f6aedcee472b58d0616e27b640 Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Mon, 24 Feb 2025 21:25:05 -0500 Subject: [PATCH 31/97] Convert kVLCSettingContinuePlayback --- Sources/App/iOS/VLCAppDelegate.m | 1 - Sources/Headers/VLCConstants.h | 1 - Sources/Helpers/VLCDefaults.swift | 12 ++++++++++++ .../MediaCategoryCells/MovieCollectionViewCell.swift | 4 +--- Sources/Playback/Control/VLCPlaybackService.m | 2 +- Sources/Settings/Model/SettingsSection.swift | 2 +- 6 files changed, 15 insertions(+), 7 deletions(-) diff --git a/Sources/App/iOS/VLCAppDelegate.m b/Sources/App/iOS/VLCAppDelegate.m index d634b0ab6..11ec4af54 100644 --- a/Sources/App/iOS/VLCAppDelegate.m +++ b/Sources/App/iOS/VLCAppDelegate.m @@ -50,7 +50,6 @@ kVLCSettingSubtitlesFontSize : kVLCSettingSubtitlesFontSizeDefaultValue, kVLCSettingSubtitlesBoldFont: kVLCSettingSubtitlesBoldFontDefaultValue, kVLCSettingDeinterlace : kVLCSettingDeinterlaceDefaultValue, - kVLCSettingContinuePlayback : @(1), kVLCSettingContinueAudioPlayback : @(1), kVLCSettingWiFiSharingIPv6 : kVLCSettingWiFiSharingIPv6DefaultValue, kVLCSettingNetworkSatIPChannelListUrl : @"", diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index 0da9b7053..a230ca75b 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -44,7 +44,6 @@ #define kVLCSettingNetworkSatIPChannelListCustom @"CustomList" #define kVLCSettingNetworkSatIPChannelListUrl @"satip-channellist-url" #define kVLCSettingsDecrapifyTitles @"MLDecrapifyTitles" -#define kVLCSettingContinuePlayback @"ContinuePlayback" #define kVLCSettingContinueAudioPlayback @"ContinueAudioPlayback" #define kVLCSettingPlaybackSpeedDefaultValue @"playback-speed" #define kVLCSettingWiFiSharingIPv6 @"wifi-sharing-ipv6" diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index ffe3b14ab..b7c66dfa7 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -48,6 +48,7 @@ Keys.volumeGesture: true, // numbers + Keys.continuePlayback: 1, Keys.defaultPreampLevel: Float(6), // other @@ -322,6 +323,15 @@ extension VLCDefaults { // Numbers + @objc var continuePlayback: Int { + get { + userDefaults.integer(forKey: Keys.continuePlayback) + } + set { + userDefaults.set(newValue, forKey: Keys.continuePlayback) + } + } + @objc var defaultPreampLevel: Float { get { userDefaults.float(forKey: Keys.defaultPreampLevel) @@ -389,6 +399,7 @@ extension VLCDefaults { @objc(VLCDefaultsCompat) final class Compat: NSObject { static let automaticallyPlayNextItemKey: String = Keys.automaticallyPlayNextItem + static let continuePlaybackKey: String = Keys.continuePlayback static let defaultPreampLevelKey: String = Keys.defaultPreampLevel static let hardwareDecodingKey: String = Keys.hardwareDecoding static let hideLibraryInFilesAppKey: String = Keys.hideLibraryInFilesApp @@ -430,6 +441,7 @@ fileprivate enum Keys { static let brightnessGesture = "EnableBrightnessGesture" static let closeGesture = "EnableCloseGesture" static let continueAudioInBackground = "BackgroundAudioPlayback" + static let continuePlayback = "ContinuePlayback" static let defaultPreampLevel = "pre-amp-level" static let downloadArtwork = "download-artwork" static let enableMediaCellTextScrolling = "EnableMediaCellTextScrolling" diff --git a/Sources/Media Library/MediaCategoryCells/MovieCollectionViewCell.swift b/Sources/Media Library/MediaCategoryCells/MovieCollectionViewCell.swift index f51f579c0..d4cb9b393 100644 --- a/Sources/Media Library/MediaCategoryCells/MovieCollectionViewCell.swift +++ b/Sources/Media Library/MediaCategoryCells/MovieCollectionViewCell.swift @@ -169,9 +169,7 @@ class MovieCollectionViewCell: BaseCollectionViewCell { descriptionLabel.text = movie.mediaDuration() thumbnailView.image = movie.thumbnailImage() let progress = movie.progress - guard let value = UserDefaults.standard.value(forKey: kVLCSettingContinuePlayback) as? Int else { - return - } + let value = VLCDefaults.shared.continuePlayback if value <= 0 { progressView.isHidden = true } else { diff --git a/Sources/Playback/Control/VLCPlaybackService.m b/Sources/Playback/Control/VLCPlaybackService.m index 16856ac99..035cd22b8 100644 --- a/Sources/Playback/Control/VLCPlaybackService.m +++ b/Sources/Playback/Control/VLCPlaybackService.m @@ -1602,7 +1602,7 @@ NSString *const VLCLastPlaylistPlayedMedia = @"LastPlaylistPlayedMedia"; } continuePlayback = [[[NSUserDefaults standardUserDefaults] objectForKey:kVLCSettingContinueAudioPlayback] integerValue]; } else { - continuePlayback = [[[NSUserDefaults standardUserDefaults] objectForKey:kVLCSettingContinuePlayback] integerValue]; + continuePlayback = VLCDefaults.shared.continuePlayback; } if (continuePlayback == 1) { diff --git a/Sources/Settings/Model/SettingsSection.swift b/Sources/Settings/Model/SettingsSection.swift index c0d0073a3..04892e171 100644 --- a/Sources/Settings/Model/SettingsSection.swift +++ b/Sources/Settings/Model/SettingsSection.swift @@ -247,7 +247,7 @@ enum GenericOptions { } static var continueVideoPlayback: SettingsItem { - let k = kVLCSettingContinuePlayback + let k = VLCDefaults.Compat.continuePlaybackKey return .init(title: "SETTINGS_CONTINUE_VIDEO_PLAYBACK", subtitle: Localizer.getSubtitle(for: k), action: .showActionSheet(title: "SETTINGS_CONTINUE_VIDEO_PLAYBACK", preferenceKey: k, hasInfo: true)) -- GitLab From 616db44dae0308669e0db93fe07def9600528cc9 Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Mon, 24 Feb 2025 21:30:11 -0500 Subject: [PATCH 32/97] Convert kVLCSettingContinueAudioPlayback --- Sources/App/iOS/VLCAppDelegate.m | 1 - Sources/Headers/VLCConstants.h | 1 - Sources/Helpers/VLCDefaults.swift | 12 ++++++++++++ Sources/Playback/Control/VLCPlaybackService.m | 2 +- Sources/Settings/Model/SettingsSection.swift | 2 +- 5 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Sources/App/iOS/VLCAppDelegate.m b/Sources/App/iOS/VLCAppDelegate.m index 11ec4af54..7859b6454 100644 --- a/Sources/App/iOS/VLCAppDelegate.m +++ b/Sources/App/iOS/VLCAppDelegate.m @@ -50,7 +50,6 @@ kVLCSettingSubtitlesFontSize : kVLCSettingSubtitlesFontSizeDefaultValue, kVLCSettingSubtitlesBoldFont: kVLCSettingSubtitlesBoldFontDefaultValue, kVLCSettingDeinterlace : kVLCSettingDeinterlaceDefaultValue, - kVLCSettingContinueAudioPlayback : @(1), kVLCSettingWiFiSharingIPv6 : kVLCSettingWiFiSharingIPv6DefaultValue, kVLCSettingNetworkSatIPChannelListUrl : @"", kVLCSettingEqualizerProfile : kVLCSettingEqualizerProfileDefaultValue, diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index a230ca75b..06dc933c9 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -44,7 +44,6 @@ #define kVLCSettingNetworkSatIPChannelListCustom @"CustomList" #define kVLCSettingNetworkSatIPChannelListUrl @"satip-channellist-url" #define kVLCSettingsDecrapifyTitles @"MLDecrapifyTitles" -#define kVLCSettingContinueAudioPlayback @"ContinueAudioPlayback" #define kVLCSettingPlaybackSpeedDefaultValue @"playback-speed" #define kVLCSettingWiFiSharingIPv6 @"wifi-sharing-ipv6" #define kVLCSettingWiFiSharingIPv6DefaultValue @(NO) diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index b7c66dfa7..b0fc5fb50 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -48,6 +48,7 @@ Keys.volumeGesture: true, // numbers + Keys.continueAudioPlayback: 1, Keys.continuePlayback: 1, Keys.defaultPreampLevel: Float(6), @@ -323,6 +324,15 @@ extension VLCDefaults { // Numbers + @objc var continueAudioPlayback: Int { + get { + userDefaults.integer(forKey: Keys.continueAudioPlayback) + } + set { + userDefaults.set(newValue, forKey: Keys.continueAudioPlayback) + } + } + @objc var continuePlayback: Int { get { userDefaults.integer(forKey: Keys.continuePlayback) @@ -399,6 +409,7 @@ extension VLCDefaults { @objc(VLCDefaultsCompat) final class Compat: NSObject { static let automaticallyPlayNextItemKey: String = Keys.automaticallyPlayNextItem + static let continueAudioPlaybackKey: String = Keys.continueAudioPlayback static let continuePlaybackKey: String = Keys.continuePlayback static let defaultPreampLevelKey: String = Keys.defaultPreampLevel static let hardwareDecodingKey: String = Keys.hardwareDecoding @@ -441,6 +452,7 @@ fileprivate enum Keys { static let brightnessGesture = "EnableBrightnessGesture" static let closeGesture = "EnableCloseGesture" static let continueAudioInBackground = "BackgroundAudioPlayback" + static let continueAudioPlayback = "ContinueAudioPlayback" static let continuePlayback = "ContinuePlayback" static let defaultPreampLevel = "pre-amp-level" static let downloadArtwork = "download-artwork" diff --git a/Sources/Playback/Control/VLCPlaybackService.m b/Sources/Playback/Control/VLCPlaybackService.m index 035cd22b8..3cf970aa4 100644 --- a/Sources/Playback/Control/VLCPlaybackService.m +++ b/Sources/Playback/Control/VLCPlaybackService.m @@ -1600,7 +1600,7 @@ NSString *const VLCLastPlaylistPlayedMedia = @"LastPlaylistPlayedMedia"; if (!libraryMedia.isPodcast) { return; } - continuePlayback = [[[NSUserDefaults standardUserDefaults] objectForKey:kVLCSettingContinueAudioPlayback] integerValue]; + continuePlayback = VLCDefaults.shared.continueAudioPlayback; } else { continuePlayback = VLCDefaults.shared.continuePlayback; } diff --git a/Sources/Settings/Model/SettingsSection.swift b/Sources/Settings/Model/SettingsSection.swift index 04892e171..ec432e772 100644 --- a/Sources/Settings/Model/SettingsSection.swift +++ b/Sources/Settings/Model/SettingsSection.swift @@ -234,7 +234,7 @@ enum GenericOptions { } static var continueAudioPlayback: SettingsItem { - let k = kVLCSettingContinueAudioPlayback + let k = VLCDefaults.Compat.continueAudioPlaybackKey return .init(title: "SETTINGS_CONTINUE_AUDIO_PLAYBACK", subtitle: Localizer.getSubtitle(for: k), action: .showActionSheet(title: "SETTINGS_CONTINUE_AUDIO_PLAYBACK", preferenceKey: k, hasInfo: true)) -- GitLab From b0c55424326c4a55354c8fb38533612ae2bfcc8a Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Mon, 24 Feb 2025 21:35:53 -0500 Subject: [PATCH 33/97] Convert kVLCSettingCastingAudioPassthrough --- Sources/App/iOS/VLCAppDelegate.m | 1 - Sources/Headers/VLCConstants.h | 1 - Sources/Headers/VLCTVConstants.h | 1 - Sources/Helpers/VLCDefaults.swift | 11 +++++++++++ Sources/Playback/Control/VLCPlaybackService.m | 4 ++-- Sources/Settings/Model/SettingsSection.swift | 2 +- 6 files changed, 14 insertions(+), 6 deletions(-) diff --git a/Sources/App/iOS/VLCAppDelegate.m b/Sources/App/iOS/VLCAppDelegate.m index 7859b6454..1904a7f82 100644 --- a/Sources/App/iOS/VLCAppDelegate.m +++ b/Sources/App/iOS/VLCAppDelegate.m @@ -63,7 +63,6 @@ kVLCSettingPlaybackRemoteControlSkip : @(NO), kVLCSettingOpenAppForPlayback : kVLCSettingOpenAppForPlaybackDefaultValue, kVLCSettingBackupMediaLibrary : kVLCSettingBackupMediaLibraryDefaultValue, - kVLCSettingCastingAudioPassthrough : @(NO), kVLCSettingCastingConversionQuality : @(2), kVLCPlayerIsShuffleEnabled: kVLCPlayerIsShuffleEnabledDefaultValue, kVLCPlayerIsRepeatEnabled: kVLCPlayerIsRepeatEnabledDefaultValue, diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index 06dc933c9..88a72f85f 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -65,7 +65,6 @@ #define kVLCSettingOpenAppForPlaybackDefaultValue @YES #define kVLCSettingsDisableGrouping @"MLDisableGrouping" #define kVLCkVLCSettingsDisableGroupingDefaultValue @NO -#define kVLCSettingCastingAudioPassthrough @"sout-chromecast-audio-passthrough" #define kVLCSettingCastingConversionQuality @"sout-chromecast-conversion-quality" #define kVLCSettingBackupMediaLibrary @"BackupMediaLibrary" #define kVLCSettingBackupMediaLibraryDefaultValue @NO diff --git a/Sources/Headers/VLCTVConstants.h b/Sources/Headers/VLCTVConstants.h index e6cd14525..ee799b315 100644 --- a/Sources/Headers/VLCTVConstants.h +++ b/Sources/Headers/VLCTVConstants.h @@ -81,7 +81,6 @@ #define kVLCHTTPUploadDirectory @"Upload" -#define kVLCSettingCastingAudioPassthrough @"sout-chromecast-audio-passthrough" #define kVLCSettingCastingConversionQuality @"sout-chromecast-conversion-quality" #define kVLCSettingReset @"kVLCSettingReset" diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index b0fc5fb50..3de86ff5c 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -23,6 +23,7 @@ Keys.appThemeBlack: false, Keys.automaticallyPlayNextItem: true, Keys.brightnessGesture: true, + Keys.castingAudioPassthrough: false, Keys.closeGesture: true, Keys.continueAudioInBackground: true, Keys.downloadArtwork: true, @@ -106,6 +107,15 @@ extension VLCDefaults { } } + @objc var castingAudioPassthrough: Bool { + get { + userDefaults.bool(forKey: Keys.castingAudioPassthrough) + } + set { + userDefaults.set(newValue, forKey: Keys.castingAudioPassthrough) + } + } + @objc var closeGesture: Bool { get { userDefaults.bool(forKey: Keys.closeGesture) @@ -450,6 +460,7 @@ fileprivate enum Keys { static let appThemeBlack = "blackTheme" static let automaticallyPlayNextItem = "AutomaticallyPlayNextItem" static let brightnessGesture = "EnableBrightnessGesture" + static let castingAudioPassthrough = "sout-chromecast-audio-passthrough" static let closeGesture = "EnableCloseGesture" static let continueAudioInBackground = "BackgroundAudioPlayback" static let continueAudioPlayback = "ContinueAudioPlayback" diff --git a/Sources/Playback/Control/VLCPlaybackService.m b/Sources/Playback/Control/VLCPlaybackService.m index 3cf970aa4..0ec8122eb 100644 --- a/Sources/Playback/Control/VLCPlaybackService.m +++ b/Sources/Playback/Control/VLCPlaybackService.m @@ -249,10 +249,10 @@ NSString *const VLCLastPlaylistPlayedMedia = @"LastPlaylistPlayedMedia"; BOOL audioTimeStretch = VLCDefaults.shared.stretchAudio; NSMutableArray *libVLCOptions = [NSMutableArray array]; #if TARGET_OS_IOS - BOOL chromecastPassthrough = [[userDefaults objectForKey:kVLCSettingCastingAudioPassthrough] boolValue]; + BOOL chromecastPassthrough = VLCDefaults.shared.castingAudioPassthrough; int chromecastQuality = [[userDefaults objectForKey:kVLCSettingCastingConversionQuality] intValue]; if (chromecastPassthrough) { - [libVLCOptions addObject:[@"--" stringByAppendingString:kVLCSettingCastingAudioPassthrough]]; + [libVLCOptions addObject:@"--sout-chromecast-audio-passthrough"]; } if (chromecastQuality != 2) { [libVLCOptions addObject:[NSString stringWithFormat:@"--%@=%i", kVLCSettingCastingConversionQuality, chromecastQuality]]; diff --git a/Sources/Settings/Model/SettingsSection.swift b/Sources/Settings/Model/SettingsSection.swift index ec432e772..1de8762a1 100644 --- a/Sources/Settings/Model/SettingsSection.swift +++ b/Sources/Settings/Model/SettingsSection.swift @@ -599,7 +599,7 @@ enum CastingOptions { static var audioPassThrough: SettingsItem { .toggle(title: "SETTINGS_PTCASTING", subtitle: "SETTINGS_PTCASTINGLONG", - preferenceKey: kVLCSettingCastingAudioPassthrough) + keyPath: \.castingAudioPassthrough) } static var conversionQuality: SettingsItem { -- GitLab From f32fced5959b5db6ff2caf190dc08f77628ff794 Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Mon, 24 Feb 2025 22:02:04 -0500 Subject: [PATCH 34/97] Convert kVLCPlayerIsRepeatEnabled --- Sources/App/iOS/VLCAppDelegate.m | 1 - Sources/Headers/VLCConstants.h | 2 -- Sources/Headers/VLCTVConstants.h | 2 -- Sources/Helpers/VLCDefaults.swift | 13 +++++++++++++ Sources/Playback/Control/VLCPlaybackService.m | 4 ++-- .../Playback/Control/VLCPlayerDisplayController.m | 3 +-- .../Player/VideoPlayer-iOS/PlayerController.swift | 4 +--- .../VLCFullscreenMovieTVViewController.m | 2 +- 8 files changed, 18 insertions(+), 13 deletions(-) diff --git a/Sources/App/iOS/VLCAppDelegate.m b/Sources/App/iOS/VLCAppDelegate.m index 1904a7f82..2589dc32d 100644 --- a/Sources/App/iOS/VLCAppDelegate.m +++ b/Sources/App/iOS/VLCAppDelegate.m @@ -65,7 +65,6 @@ kVLCSettingBackupMediaLibrary : kVLCSettingBackupMediaLibraryDefaultValue, kVLCSettingCastingConversionQuality : @(2), kVLCPlayerIsShuffleEnabled: kVLCPlayerIsShuffleEnabledDefaultValue, - kVLCPlayerIsRepeatEnabled: kVLCPlayerIsRepeatEnabledDefaultValue, kVLCSettingPlaybackSpeedDefaultValue: @(1.0), kVLCSettingAlwaysPlayURLs: @(NO), kVLCSettingPlayerControlDuration: kVLCSettingPlayerControlDurationDefaultValue diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index 88a72f85f..b0a148e0f 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -90,8 +90,6 @@ #define KVLCPlayerBrightness @"playerbrightness" #define kVLCPlayerIsShuffleEnabled @"PlayerIsShuffleEnabled" #define kVLCPlayerIsShuffleEnabledDefaultValue @NO -#define kVLCPlayerIsRepeatEnabled @"PlayerIsRepeatEnabled" -#define kVLCPlayerIsRepeatEnabledDefaultValue @(0) #define kVLCCustomProfileEnabled @"kVLCCustomProfileEnabled" #define kVLCCustomEqualizerProfiles @"kVLCCustomEqualizerProfiles" diff --git a/Sources/Headers/VLCTVConstants.h b/Sources/Headers/VLCTVConstants.h index ee799b315..799df62ef 100644 --- a/Sources/Headers/VLCTVConstants.h +++ b/Sources/Headers/VLCTVConstants.h @@ -68,8 +68,6 @@ #define kVLCPlayerOpenInMiniPlayer @"OpenInMiniPlayer" #define kVLCPlayerIsShuffleEnabled @"PlayerIsShuffleEnabled" #define kVLCPlayerIsShuffleEnabledDefaultValue @NO -#define kVLCPlayerIsRepeatEnabled @"PlayerIsRepeatEnabled" -#define kVLCPlayerIsRepeatEnabledDefaultValue @(0) #define kVLCSettingLastUsedSubtitlesSearchLanguage @"kVLCSettingLastUsedSubtitlesSearchLanguage" #define kVLCSettingWiFiSharingIPv6 @"wifi-sharing-ipv6" diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index 3de86ff5c..2dc831a51 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -56,6 +56,7 @@ // other Keys.hardwareDecoding: HardwareDecoding.hardware.rawValue, Keys.networkCaching: NetworkCaching.normal.rawValue, + Keys.playerIsRepeatEnabled: DefaultValues.playerRepeatMode, Keys.textEncoding: DefaultValues.textEncoding, ] @@ -394,6 +395,16 @@ extension VLCDefaults { networkCaching.rawValue } + @objc var playerIsRepeatEnabled: VLCRepeatMode { + get { + let v = userDefaults.integer(forKey: Keys.playerIsRepeatEnabled) + return VLCRepeatMode(rawValue: v) ?? DefaultValues.playerRepeatMode + } + set { + userDefaults.set(newValue, forKey: Keys.playerIsRepeatEnabled) + } + } + @objc var textEncoding: String { get { userDefaults.string(forKey: Keys.textEncoding) ?? DefaultValues.textEncoding @@ -477,6 +488,7 @@ fileprivate enum Keys { static let passcodeEnableBiometricAuth = "EnableBiometricAuth" static let pauseWhenShowingControls = "kVLCSettingPauseWhenShowingControls" static let playbackLongTouchSpeedUp = "LongTouchSpeedUp" + static let playerIsRepeatEnabled = "PlayerIsRepeatEnabled" static let playerShouldRememberBrightness = "PlayerShouldRememberBrightness" static let playerShouldRememberState = "PlayerShouldRememberState" static let playerShowPlaybackSpeedShortcut = "kVLCPlayerShowPlaybackSpeedShortcut" @@ -503,4 +515,5 @@ fileprivate enum Keys { fileprivate enum DefaultValues { static let textEncoding = "Windows-1252" + static let playerRepeatMode = VLCRepeatMode.doNotRepeat } diff --git a/Sources/Playback/Control/VLCPlaybackService.m b/Sources/Playback/Control/VLCPlaybackService.m index 0ec8122eb..849b6856f 100644 --- a/Sources/Playback/Control/VLCPlaybackService.m +++ b/Sources/Playback/Control/VLCPlaybackService.m @@ -323,7 +323,7 @@ NSString *const VLCLastPlaylistPlayedMedia = @"LastPlaylistPlayedMedia"; [_listPlayer setMediaList:self.mediaList]; if (VLCDefaults.shared.playerShouldRememberState) { - VLCRepeatMode repeatMode = [defaults integerForKey:kVLCPlayerIsRepeatEnabled]; + VLCRepeatMode repeatMode = VLCDefaults.shared.playerIsRepeatEnabled; [_listPlayer setRepeatMode:repeatMode]; } @@ -582,7 +582,7 @@ NSString *const VLCLastPlaylistPlayedMedia = @"LastPlaylistPlayedMedia"; NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; if (VLCDefaults.shared.playerShouldRememberState) { - [defaults setInteger:repeatMode forKey:kVLCPlayerIsRepeatEnabled]; + VLCDefaults.shared.playerIsRepeatEnabled = repeatMode; } } diff --git a/Sources/Playback/Control/VLCPlayerDisplayController.m b/Sources/Playback/Control/VLCPlayerDisplayController.m index 727806dcd..9ef98029f 100644 --- a/Sources/Playback/Control/VLCPlayerDisplayController.m +++ b/Sources/Playback/Control/VLCPlayerDisplayController.m @@ -486,8 +486,7 @@ NSString *const VLCPlayerDisplayControllerHideMiniPlayer = @"VLCPlayerDisplayCon NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults]; if (VLCDefaults.shared.playerShouldRememberState) { _playbackController.shuffleMode = [userDefaults boolForKey:kVLCPlayerIsShuffleEnabled]; - NSInteger repeatMode = [userDefaults integerForKey:kVLCPlayerIsRepeatEnabled]; - _playbackController.repeatMode = repeatMode; + _playbackController.repeatMode = VLCDefaults.shared.playerIsRepeatEnabled; } [self addPlayqueueToMiniPlayer]; diff --git a/Sources/Playback/Player/VideoPlayer-iOS/PlayerController.swift b/Sources/Playback/Player/VideoPlayer-iOS/PlayerController.swift index 1d8b348df..4af067797 100644 --- a/Sources/Playback/Player/VideoPlayer-iOS/PlayerController.swift +++ b/Sources/Playback/Player/VideoPlayer-iOS/PlayerController.swift @@ -73,9 +73,7 @@ class PlayerController: NSObject { } var isRepeatEnabled: VLCRepeatMode { - let storedValue = UserDefaults.standard.integer(forKey: kVLCPlayerIsRepeatEnabled) - - return VLCRepeatMode(rawValue: storedValue) ?? .doNotRepeat + return VLCDefaults.shared.playerIsRepeatEnabled } var isRememberStateEnabled: Bool { diff --git a/Sources/Playback/Player/VideoPlayer-tvOS/VLCFullscreenMovieTVViewController.m b/Sources/Playback/Player/VideoPlayer-tvOS/VLCFullscreenMovieTVViewController.m index aa77adb90..02856464f 100644 --- a/Sources/Playback/Player/VideoPlayer-tvOS/VLCFullscreenMovieTVViewController.m +++ b/Sources/Playback/Player/VideoPlayer-tvOS/VLCFullscreenMovieTVViewController.m @@ -175,7 +175,7 @@ typedef NS_ENUM(NSInteger, VLCPlayerScanState) NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; if (VLCDefaults.shared.playerShouldRememberState) { vpc.shuffleMode = [defaults boolForKey:kVLCPlayerIsShuffleEnabled]; - vpc.repeatMode = [defaults integerForKey:kVLCPlayerIsRepeatEnabled]; + vpc.repeatMode = VLCDefaults.shared.playerIsRepeatEnabled; } self.playbackUIShouldHide = [defaults boolForKey:kVLCPlayerUIShouldHide]; -- GitLab From 20753c501c47ba7f31582bf511aa2f016fbc2a41 Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Mon, 24 Feb 2025 22:08:22 -0500 Subject: [PATCH 35/97] Convert kVLCPlayerIsShuffleEnabled --- Sources/App/iOS/VLCAppDelegate.m | 1 - Sources/Headers/VLCConstants.h | 2 -- Sources/Headers/VLCTVConstants.h | 2 -- Sources/Helpers/VLCDefaults.swift | 11 +++++++++++ Sources/Playback/Control/VLCPlaybackService.m | 2 +- Sources/Playback/Control/VLCPlayerDisplayController.m | 2 +- .../Player/VideoPlayer-iOS/PlayerController.swift | 2 +- .../VLCFullscreenMovieTVViewController.m | 2 +- 8 files changed, 15 insertions(+), 9 deletions(-) diff --git a/Sources/App/iOS/VLCAppDelegate.m b/Sources/App/iOS/VLCAppDelegate.m index 2589dc32d..5b4142461 100644 --- a/Sources/App/iOS/VLCAppDelegate.m +++ b/Sources/App/iOS/VLCAppDelegate.m @@ -64,7 +64,6 @@ kVLCSettingOpenAppForPlayback : kVLCSettingOpenAppForPlaybackDefaultValue, kVLCSettingBackupMediaLibrary : kVLCSettingBackupMediaLibraryDefaultValue, kVLCSettingCastingConversionQuality : @(2), - kVLCPlayerIsShuffleEnabled: kVLCPlayerIsShuffleEnabledDefaultValue, kVLCSettingPlaybackSpeedDefaultValue: @(1.0), kVLCSettingAlwaysPlayURLs: @(NO), kVLCSettingPlayerControlDuration: kVLCSettingPlayerControlDurationDefaultValue diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index b0a148e0f..b2d544472 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -88,8 +88,6 @@ #define kVLCPlayerOpenInMiniPlayer @"OpenInMiniPlayer" #define KVLCPlayerBrightness @"playerbrightness" -#define kVLCPlayerIsShuffleEnabled @"PlayerIsShuffleEnabled" -#define kVLCPlayerIsShuffleEnabledDefaultValue @NO #define kVLCCustomProfileEnabled @"kVLCCustomProfileEnabled" #define kVLCCustomEqualizerProfiles @"kVLCCustomEqualizerProfiles" diff --git a/Sources/Headers/VLCTVConstants.h b/Sources/Headers/VLCTVConstants.h index 799df62ef..613adfffd 100644 --- a/Sources/Headers/VLCTVConstants.h +++ b/Sources/Headers/VLCTVConstants.h @@ -66,8 +66,6 @@ #define kVLCLastPlayedMediaIdentifier @"LastPlayedMediaIdentifier" #define kVLCPlayerOpenInMiniPlayer @"OpenInMiniPlayer" -#define kVLCPlayerIsShuffleEnabled @"PlayerIsShuffleEnabled" -#define kVLCPlayerIsShuffleEnabledDefaultValue @NO #define kVLCSettingLastUsedSubtitlesSearchLanguage @"kVLCSettingLastUsedSubtitlesSearchLanguage" #define kVLCSettingWiFiSharingIPv6 @"wifi-sharing-ipv6" diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index 2dc831a51..07d805b04 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -35,6 +35,7 @@ Keys.passcodeEnableBiometricAuth: true, Keys.pauseWhenShowingControls: false, Keys.playbackLongTouchSpeedUp: true, + Keys.playerIsShuffleEnabled: false, Keys.playerShouldRememberBrightness: false, Keys.playerShouldRememberState: true, Keys.playerShowPlaybackSpeedShortcut: false, @@ -207,6 +208,15 @@ extension VLCDefaults { } } + @objc var playerIsShuffleEnabled: Bool { + get { + userDefaults.bool(forKey: Keys.playerIsShuffleEnabled) + } + set { + userDefaults.set(newValue, forKey: Keys.playerIsShuffleEnabled) + } + } + @objc var playerShouldRememberBrightness: Bool { get { userDefaults.bool(forKey: Keys.playerShouldRememberBrightness) @@ -489,6 +499,7 @@ fileprivate enum Keys { static let pauseWhenShowingControls = "kVLCSettingPauseWhenShowingControls" static let playbackLongTouchSpeedUp = "LongTouchSpeedUp" static let playerIsRepeatEnabled = "PlayerIsRepeatEnabled" + static let playerIsShuffleEnabled = "PlayerIsShuffleEnabled" static let playerShouldRememberBrightness = "PlayerShouldRememberBrightness" static let playerShouldRememberState = "PlayerShouldRememberState" static let playerShowPlaybackSpeedShortcut = "kVLCPlayerShowPlaybackSpeedShortcut" diff --git a/Sources/Playback/Control/VLCPlaybackService.m b/Sources/Playback/Control/VLCPlaybackService.m index 849b6856f..7669accbe 100644 --- a/Sources/Playback/Control/VLCPlaybackService.m +++ b/Sources/Playback/Control/VLCPlaybackService.m @@ -1020,7 +1020,7 @@ NSString *const VLCLastPlaylistPlayedMedia = @"LastPlaylistPlayedMedia"; NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; if (VLCDefaults.shared.playerShouldRememberState) { - [defaults setBool:shuffleMode forKey:kVLCPlayerIsShuffleEnabled]; + VLCDefaults.shared.playerIsShuffleEnabled = shuffleMode; } } diff --git a/Sources/Playback/Control/VLCPlayerDisplayController.m b/Sources/Playback/Control/VLCPlayerDisplayController.m index 9ef98029f..869f321ce 100644 --- a/Sources/Playback/Control/VLCPlayerDisplayController.m +++ b/Sources/Playback/Control/VLCPlayerDisplayController.m @@ -485,7 +485,7 @@ NSString *const VLCPlayerDisplayControllerHideMiniPlayer = @"VLCPlayerDisplayCon // Properly set the shuffle and repeat mode NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults]; if (VLCDefaults.shared.playerShouldRememberState) { - _playbackController.shuffleMode = [userDefaults boolForKey:kVLCPlayerIsShuffleEnabled]; + _playbackController.shuffleMode = VLCDefaults.shared.playerIsShuffleEnabled; _playbackController.repeatMode = VLCDefaults.shared.playerIsRepeatEnabled; } diff --git a/Sources/Playback/Player/VideoPlayer-iOS/PlayerController.swift b/Sources/Playback/Player/VideoPlayer-iOS/PlayerController.swift index 4af067797..efcddd114 100644 --- a/Sources/Playback/Player/VideoPlayer-iOS/PlayerController.swift +++ b/Sources/Playback/Player/VideoPlayer-iOS/PlayerController.swift @@ -69,7 +69,7 @@ class PlayerController: NSObject { } var isShuffleEnabled: Bool { - return UserDefaults.standard.bool(forKey: kVLCPlayerIsShuffleEnabled) + return VLCDefaults.shared.playerIsShuffleEnabled } var isRepeatEnabled: VLCRepeatMode { diff --git a/Sources/Playback/Player/VideoPlayer-tvOS/VLCFullscreenMovieTVViewController.m b/Sources/Playback/Player/VideoPlayer-tvOS/VLCFullscreenMovieTVViewController.m index 02856464f..fddbe7516 100644 --- a/Sources/Playback/Player/VideoPlayer-tvOS/VLCFullscreenMovieTVViewController.m +++ b/Sources/Playback/Player/VideoPlayer-tvOS/VLCFullscreenMovieTVViewController.m @@ -174,7 +174,7 @@ typedef NS_ENUM(NSInteger, VLCPlayerScanState) NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; if (VLCDefaults.shared.playerShouldRememberState) { - vpc.shuffleMode = [defaults boolForKey:kVLCPlayerIsShuffleEnabled]; + vpc.shuffleMode = VLCDefaults.shared.playerIsShuffleEnabled; vpc.repeatMode = VLCDefaults.shared.playerIsRepeatEnabled; } -- GitLab From bd09207b6e2b36247519038ebaddaaab4593a82f Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Tue, 25 Feb 2025 13:59:49 -0500 Subject: [PATCH 36/97] Remove unused definitions --- Sources/Headers/VLCConstants.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index b2d544472..31e97a131 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -15,13 +15,10 @@ #define kVLCThemeDidChangeNotification @"themeDidChangeNotfication" #define kVLCSettingAppTheme @"darkMode" #define kVLCSettingAppThemeBright 0 -#define kVLCSettingAppThemeDark 1 #define kVLCSettingAppThemeSystem 2 #define kVLCOptimizeItemNamesForDisplay @"MLDecrapifyTitles" -#define kVLCSettingAbout @"about" #define kVLCLastPlayedPlaylist @"LastPlayedPlaylist" #define kVLCIsCurrentlyPlayingPlaylist @"isPlaylistCurrentlyPlaying" -#define kVLCCurrentPlaylistMediasQueue @"currentPlaylistMediasQueue" #define kVLCSettingSkipLoopFilter @"avcodec-skiploopfilter" #define kVLCSettingSkipLoopFilterNone @(0) #define kVLCSettingSkipLoopFilterNonRef @(1) @@ -69,7 +66,6 @@ #define kVLCSettingBackupMediaLibrary @"BackupMediaLibrary" #define kVLCSettingBackupMediaLibraryDefaultValue @NO #define kVLCSettingLastUsedSubtitlesSearchLanguage @"kVLCSettingLastUsedSubtitlesSearchLanguage" -#define kVLCResetSettings @"kVLCResetSettings" #define kVLCSettingAlwaysPlayURLs @"kVLCSettingAlwaysPlayURLs" #define kVLCSettingDisableSubtitles @"kVLCSettingDisableSubtitles" #define kVLCSettingPlayerControlDuration @"kVLCSettingPlayerControlDuration" -- GitLab From b7d3503d20b45e8fb9f0549a94e91b8c89c31c50 Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Tue, 25 Feb 2025 16:11:41 -0500 Subject: [PATCH 37/97] Convert kVLCSettingNetworkSatIPChannelListUrl --- Sources/App/iOS/VLCAppDelegate.m | 1 - Sources/App/tvOS/AppleTVAppDelegate.m | 1 - Sources/Headers/VLCConstants.h | 1 - Sources/Headers/VLCTVConstants.h | 3 +++ Sources/Helpers/VLCDefaults.swift | 12 ++++++++++++ .../VLCLocalNetworkServiceBrowserMediaDiscoverer.m | 6 +++--- 6 files changed, 18 insertions(+), 6 deletions(-) diff --git a/Sources/App/iOS/VLCAppDelegate.m b/Sources/App/iOS/VLCAppDelegate.m index 5b4142461..5a6aec1a2 100644 --- a/Sources/App/iOS/VLCAppDelegate.m +++ b/Sources/App/iOS/VLCAppDelegate.m @@ -51,7 +51,6 @@ kVLCSettingSubtitlesBoldFont: kVLCSettingSubtitlesBoldFontDefaultValue, kVLCSettingDeinterlace : kVLCSettingDeinterlaceDefaultValue, kVLCSettingWiFiSharingIPv6 : kVLCSettingWiFiSharingIPv6DefaultValue, - kVLCSettingNetworkSatIPChannelListUrl : @"", kVLCSettingEqualizerProfile : kVLCSettingEqualizerProfileDefaultValue, kVLCSettingPlaybackForwardBackwardEqual: @(YES), kVLCSettingPlaybackTapSwipeEqual: @(YES), diff --git a/Sources/App/tvOS/AppleTVAppDelegate.m b/Sources/App/tvOS/AppleTVAppDelegate.m index a2ad50189..cff5f6cf2 100644 --- a/Sources/App/tvOS/AppleTVAppDelegate.m +++ b/Sources/App/tvOS/AppleTVAppDelegate.m @@ -46,7 +46,6 @@ kVLCSettingSubtitlesFontSize : kVLCSettingSubtitlesFontSizeDefaultValue, kVLCSettingSubtitlesBoldFont: kVLCSettingSubtitlesBoldFontDefaultValue, kVLCSettingDeinterlace : kVLCSettingDeinterlaceDefaultValue, - kVLCSettingNetworkSatIPChannelListUrl : @"", kVLCSettingEqualizerProfile : kVLCSettingEqualizerProfileDefaultValue, kVLCSettingPlaybackForwardSkipLength : kVLCSettingPlaybackForwardSkipLengthDefaultValue, kVLCSettingPlaybackBackwardSkipLength : kVLCSettingPlaybackBackwardSkipLengthDefaultValue, diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index 31e97a131..2938e4602 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -39,7 +39,6 @@ #define kVLCSaveDebugLogs @"kVLCSaveDebugLogs" #define kVLCSettingNetworkSatIPChannelList @"satip-channelist" #define kVLCSettingNetworkSatIPChannelListCustom @"CustomList" -#define kVLCSettingNetworkSatIPChannelListUrl @"satip-channellist-url" #define kVLCSettingsDecrapifyTitles @"MLDecrapifyTitles" #define kVLCSettingPlaybackSpeedDefaultValue @"playback-speed" #define kVLCSettingWiFiSharingIPv6 @"wifi-sharing-ipv6" diff --git a/Sources/Headers/VLCTVConstants.h b/Sources/Headers/VLCTVConstants.h index 613adfffd..5bbaa7b8e 100644 --- a/Sources/Headers/VLCTVConstants.h +++ b/Sources/Headers/VLCTVConstants.h @@ -29,7 +29,10 @@ #define kVLCSaveDebugLogs @"kVLCSaveDebugLogs" #define kVLCSettingNetworkSatIPChannelList @"satip-channelist" #define kVLCSettingNetworkSatIPChannelListCustom @"CustomList" + +/* deprecated */ #define kVLCSettingNetworkSatIPChannelListUrl @"satip-channellist-url" + #define kVLCSettingSkipLoopFilter @"avcodec-skiploopfilter" #define kVLCSettingSkipLoopFilterNone @(0) #define kVLCSettingSkipLoopFilterNonRef @(1) diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index 07d805b04..3055f7e68 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -57,6 +57,7 @@ // other Keys.hardwareDecoding: HardwareDecoding.hardware.rawValue, Keys.networkCaching: NetworkCaching.normal.rawValue, + Keys.networkSatIPChannelListUrl: DefaultValues.networkSatIPChannelListUrl, Keys.playerIsRepeatEnabled: DefaultValues.playerRepeatMode, Keys.textEncoding: DefaultValues.textEncoding, ] @@ -405,6 +406,15 @@ extension VLCDefaults { networkCaching.rawValue } + @objc var networkSatIPChannelListUrl: String { + get { + userDefaults.string(forKey: Keys.networkSatIPChannelListUrl) ?? DefaultValues.networkSatIPChannelListUrl + } + set { + userDefaults.set(newValue, forKey: Keys.networkSatIPChannelListUrl) + } + } + @objc var playerIsRepeatEnabled: VLCRepeatMode { get { let v = userDefaults.integer(forKey: Keys.playerIsRepeatEnabled) @@ -495,6 +505,7 @@ fileprivate enum Keys { static let hideLibraryInFilesApp = "HideLibraryInFilesApp" static let networkCaching = "network-caching" static let networkRTSPTCP = "rtsp-tcp" + static let networkSatIPChannelListUrl = "satip-channellist-url" static let passcodeEnableBiometricAuth = "EnableBiometricAuth" static let pauseWhenShowingControls = "kVLCSettingPauseWhenShowingControls" static let playbackLongTouchSpeedUp = "LongTouchSpeedUp" @@ -526,5 +537,6 @@ fileprivate enum Keys { fileprivate enum DefaultValues { static let textEncoding = "Windows-1252" + static let networkSatIPChannelListUrl = "" static let playerRepeatMode = VLCRepeatMode.doNotRepeat } diff --git a/Sources/Network/Server Browsing/Data/Protocols/General/VLCLocalNetworkServiceBrowserMediaDiscoverer.m b/Sources/Network/Server Browsing/Data/Protocols/General/VLCLocalNetworkServiceBrowserMediaDiscoverer.m index 20b779a47..3aa41d261 100644 --- a/Sources/Network/Server Browsing/Data/Protocols/General/VLCLocalNetworkServiceBrowserMediaDiscoverer.m +++ b/Sources/Network/Server Browsing/Data/Protocols/General/VLCLocalNetworkServiceBrowserMediaDiscoverer.m @@ -16,6 +16,7 @@ #import "VLCLocalNetworkServiceBrowserUPnP.h" #import "VLCAppCoordinator.h" #import "VLCHTTPUploaderController.h" +#import "VLC-Swift.h" @interface VLCLocalNetworkServiceBrowserMediaDiscoverer () <VLCMediaListDelegate> { @@ -42,11 +43,10 @@ * so it should be only if explicitly demanded by the user */ _isUPnPdiscoverer = [serviceName isEqualToString:@"upnp"]; if (_isUPnPdiscoverer) { - NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; - NSString *satipURLstring = [defaults stringForKey:kVLCSettingNetworkSatIPChannelListUrl]; + NSString *satipURLstring = VLCDefaults.shared.networkSatIPChannelListUrl; NSMutableArray *libVLCOptions = [NSMutableArray array]; if (satipURLstring.length > 0) { - [libVLCOptions addObject:[NSString stringWithFormat:@"--%@=%@", kVLCSettingNetworkSatIPChannelListUrl, satipURLstring]]; + [libVLCOptions addObject:[NSString stringWithFormat:@"--satip-channellist-url=%@", satipURLstring]]; [libVLCOptions addObject:[NSString stringWithFormat:@"--%@=%@", kVLCSettingNetworkSatIPChannelList, kVLCSettingNetworkSatIPChannelListCustom]]; } NSString *multicastInterfaceName = [[[VLCAppCoordinator sharedInstance] httpUploaderController] nameOfUsedNetworkInterface]; -- GitLab From 135875140f1fde6d971fcf9a2789a159e1271c51 Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Tue, 25 Feb 2025 16:20:58 -0500 Subject: [PATCH 38/97] Convert kVLCSettingPlaybackForwardBackwardEqual --- Sources/App/iOS/VLCAppDelegate.m | 1 - Sources/Headers/VLCConstants.h | 1 - Sources/Helpers/VLCDefaults.swift | 11 +++++++++++ Sources/Playback/Player/PlayerViewController.swift | 2 +- .../VideoPlayer-iOS/VideoPlayerViewController.swift | 2 +- Sources/Settings/Controller/SettingsController.swift | 2 +- Sources/Settings/Model/SettingsSection.swift | 6 +++--- 7 files changed, 17 insertions(+), 8 deletions(-) diff --git a/Sources/App/iOS/VLCAppDelegate.m b/Sources/App/iOS/VLCAppDelegate.m index 5a6aec1a2..df7442277 100644 --- a/Sources/App/iOS/VLCAppDelegate.m +++ b/Sources/App/iOS/VLCAppDelegate.m @@ -52,7 +52,6 @@ kVLCSettingDeinterlace : kVLCSettingDeinterlaceDefaultValue, kVLCSettingWiFiSharingIPv6 : kVLCSettingWiFiSharingIPv6DefaultValue, kVLCSettingEqualizerProfile : kVLCSettingEqualizerProfileDefaultValue, - kVLCSettingPlaybackForwardBackwardEqual: @(YES), kVLCSettingPlaybackTapSwipeEqual: @(YES), kVLCSettingPlaybackForwardSkipLength : kVLCSettingPlaybackForwardSkipLengthDefaultValue, kVLCSettingPlaybackBackwardSkipLength : kVLCSettingPlaybackBackwardSkipLengthDefaultValue, diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index 2938e4602..be8376c6d 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -45,7 +45,6 @@ #define kVLCSettingWiFiSharingIPv6DefaultValue @(NO) #define kVLCSettingEqualizerProfile @"EqualizerProfile" #define kVLCSettingEqualizerProfileDefaultValue @(0) -#define kVLCSettingPlaybackForwardBackwardEqual @"playback-forward-backward-equal" #define kVLCSettingPlaybackTapSwipeEqual @"playback-tap-swipe-equal" #define kVLCSettingPlaybackForwardSkipLength @"playback-forward-skip-length" #define kVLCSettingPlaybackForwardSkipLengthDefaultValue @(10) diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index 3055f7e68..0188b3bb2 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -34,6 +34,7 @@ Keys.networkRTSPTCP: false, Keys.passcodeEnableBiometricAuth: true, Keys.pauseWhenShowingControls: false, + Keys.playbackForwardBackwardEqual: true, Keys.playbackLongTouchSpeedUp: true, Keys.playerIsShuffleEnabled: false, Keys.playerShouldRememberBrightness: false, @@ -200,6 +201,15 @@ extension VLCDefaults { } } + var playbackForwardBackwardEqual: Bool { + get { + userDefaults.bool(forKey: Keys.playbackForwardBackwardEqual) + } + set { + userDefaults.set(newValue, forKey: Keys.playbackForwardBackwardEqual) + } + } + @objc var playbackLongTouchSpeedUp: Bool { get { userDefaults.bool(forKey: Keys.playbackLongTouchSpeedUp) @@ -508,6 +518,7 @@ fileprivate enum Keys { static let networkSatIPChannelListUrl = "satip-channellist-url" static let passcodeEnableBiometricAuth = "EnableBiometricAuth" static let pauseWhenShowingControls = "kVLCSettingPauseWhenShowingControls" + static let playbackForwardBackwardEqual = "playback-forward-backward-equal" static let playbackLongTouchSpeedUp = "LongTouchSpeedUp" static let playerIsRepeatEnabled = "PlayerIsRepeatEnabled" static let playerIsShuffleEnabled = "PlayerIsShuffleEnabled" diff --git a/Sources/Playback/Player/PlayerViewController.swift b/Sources/Playback/Player/PlayerViewController.swift index 092f048a3..aaa9717db 100644 --- a/Sources/Playback/Player/PlayerViewController.swift +++ b/Sources/Playback/Player/PlayerViewController.swift @@ -739,7 +739,7 @@ class PlayerViewController: UIViewController { let defaults = UserDefaults.standard tapSwipeEqual = defaults.bool(forKey: kVLCSettingPlaybackTapSwipeEqual) - forwardBackwardEqual = defaults.bool(forKey: kVLCSettingPlaybackForwardBackwardEqual) + forwardBackwardEqual = VLCDefaults.shared.playbackForwardBackwardEqual seekForwardBy = defaults.integer(forKey: kVLCSettingPlaybackForwardSkipLength) seekBackwardBy = forwardBackwardEqual ? seekForwardBy : defaults.integer(forKey: kVLCSettingPlaybackBackwardSkipLength) seekForwardBySwipe = tapSwipeEqual ? seekForwardBy : defaults.integer(forKey: kVLCSettingPlaybackForwardSkipLengthSwipe) diff --git a/Sources/Playback/Player/VideoPlayer-iOS/VideoPlayerViewController.swift b/Sources/Playback/Player/VideoPlayer-iOS/VideoPlayerViewController.swift index e99c878c4..c0ad3ef95 100644 --- a/Sources/Playback/Player/VideoPlayer-iOS/VideoPlayerViewController.swift +++ b/Sources/Playback/Player/VideoPlayer-iOS/VideoPlayerViewController.swift @@ -868,7 +868,7 @@ class VideoPlayerViewController: PlayerViewController { let defaults = UserDefaults.standard tapSwipeEqual = defaults.bool(forKey: kVLCSettingPlaybackTapSwipeEqual) - forwardBackwardEqual = defaults.bool(forKey: kVLCSettingPlaybackForwardBackwardEqual) + forwardBackwardEqual = VLCDefaults.shared.playbackForwardBackwardEqual seekForwardBy = defaults.integer(forKey: kVLCSettingPlaybackForwardSkipLength) seekBackwardBy = forwardBackwardEqual ? seekForwardBy : defaults.integer(forKey: kVLCSettingPlaybackBackwardSkipLength) seekForwardBySwipe = tapSwipeEqual ? seekForwardBy : defaults.integer(forKey: kVLCSettingPlaybackForwardSkipLengthSwipe) diff --git a/Sources/Settings/Controller/SettingsController.swift b/Sources/Settings/Controller/SettingsController.swift index 6c275775f..3cdd3408a 100644 --- a/Sources/Settings/Controller/SettingsController.swift +++ b/Sources/Settings/Controller/SettingsController.swift @@ -307,7 +307,7 @@ extension SettingsController { settingsSections = SettingsSection .sections(isLabActivated: isLabActivated, isBackingUp: isBackingUp, - isForwardBackwardEqual: userDefaults.bool(forKey: kVLCSettingPlaybackForwardBackwardEqual), + isForwardBackwardEqual: VLCDefaults.shared.playbackForwardBackwardEqual, isTapSwipeEqual: userDefaults.bool(forKey: kVLCSettingPlaybackTapSwipeEqual)) } diff --git a/Sources/Settings/Model/SettingsSection.swift b/Sources/Settings/Model/SettingsSection.swift index 1de8762a1..f95066e02 100644 --- a/Sources/Settings/Model/SettingsSection.swift +++ b/Sources/Settings/Model/SettingsSection.swift @@ -379,7 +379,7 @@ enum GestureControlOptions { static var forwardBackwardEqual: SettingsItem { .toggle(title: "SETTINGS_GESTURES_FORWARD_BACKWARD_EQUAL", subtitle: nil, - preferenceKey: kVLCSettingPlaybackForwardBackwardEqual) + keyPath: \.playbackForwardBackwardEqual) } static var tapSwipeEqual: SettingsItem { @@ -456,7 +456,7 @@ enum GestureControlOptions { } private static func dynamicForwardSkipDescription() -> String { - let forwardBackwardEqual = UserDefaults.standard.bool(forKey: kVLCSettingPlaybackForwardBackwardEqual) + let forwardBackwardEqual = VLCDefaults.shared.playbackForwardBackwardEqual let tapSwipeEqual = UserDefaults.standard.bool(forKey: kVLCSettingPlaybackTapSwipeEqual) if forwardBackwardEqual && tapSwipeEqual { @@ -481,7 +481,7 @@ enum GestureControlOptions { } private static func dynamicForwardSwipeDescription() -> String { - let forwardBackwardEqual = UserDefaults.standard.bool(forKey: kVLCSettingPlaybackForwardBackwardEqual) + let forwardBackwardEqual = VLCDefaults.shared.playbackForwardBackwardEqual if forwardBackwardEqual { return "SETTINGS_PLAYBACK_SKIP_SWIPE" -- GitLab From 9fa591aeda06136c28d4f6b4297491eae3ef564a Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Tue, 25 Feb 2025 16:26:02 -0500 Subject: [PATCH 39/97] Convert kVLCSettingPlaybackTapSwipeEqual --- Sources/App/iOS/VLCAppDelegate.m | 1 - Sources/Headers/VLCConstants.h | 1 - Sources/Helpers/VLCDefaults.swift | 11 +++++++++++ Sources/Playback/Player/PlayerViewController.swift | 2 +- .../VideoPlayer-iOS/VideoPlayerViewController.swift | 2 +- Sources/Settings/Controller/SettingsController.swift | 2 +- Sources/Settings/Model/SettingsSection.swift | 6 +++--- 7 files changed, 17 insertions(+), 8 deletions(-) diff --git a/Sources/App/iOS/VLCAppDelegate.m b/Sources/App/iOS/VLCAppDelegate.m index df7442277..9166ca8cb 100644 --- a/Sources/App/iOS/VLCAppDelegate.m +++ b/Sources/App/iOS/VLCAppDelegate.m @@ -52,7 +52,6 @@ kVLCSettingDeinterlace : kVLCSettingDeinterlaceDefaultValue, kVLCSettingWiFiSharingIPv6 : kVLCSettingWiFiSharingIPv6DefaultValue, kVLCSettingEqualizerProfile : kVLCSettingEqualizerProfileDefaultValue, - kVLCSettingPlaybackTapSwipeEqual: @(YES), kVLCSettingPlaybackForwardSkipLength : kVLCSettingPlaybackForwardSkipLengthDefaultValue, kVLCSettingPlaybackBackwardSkipLength : kVLCSettingPlaybackBackwardSkipLengthDefaultValue, kVLCSettingPlaybackForwardSkipLengthSwipe : kVLCSettingPlaybackForwardSkipLengthSwipeDefaultValue, diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index be8376c6d..a435acb1c 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -45,7 +45,6 @@ #define kVLCSettingWiFiSharingIPv6DefaultValue @(NO) #define kVLCSettingEqualizerProfile @"EqualizerProfile" #define kVLCSettingEqualizerProfileDefaultValue @(0) -#define kVLCSettingPlaybackTapSwipeEqual @"playback-tap-swipe-equal" #define kVLCSettingPlaybackForwardSkipLength @"playback-forward-skip-length" #define kVLCSettingPlaybackForwardSkipLengthDefaultValue @(10) #define kVLCSettingPlaybackBackwardSkipLength @"playback-backward-skip-length" diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index 0188b3bb2..63e82191b 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -36,6 +36,7 @@ Keys.pauseWhenShowingControls: false, Keys.playbackForwardBackwardEqual: true, Keys.playbackLongTouchSpeedUp: true, + Keys.playbackTapSwipeEqual: true, Keys.playerIsShuffleEnabled: false, Keys.playerShouldRememberBrightness: false, Keys.playerShouldRememberState: true, @@ -219,6 +220,15 @@ extension VLCDefaults { } } + @objc var playbackTapSwipeEqual: Bool { + get { + userDefaults.bool(forKey: Keys.playbackTapSwipeEqual) + } + set { + userDefaults.set(newValue, forKey: Keys.playbackTapSwipeEqual) + } + } + @objc var playerIsShuffleEnabled: Bool { get { userDefaults.bool(forKey: Keys.playerIsShuffleEnabled) @@ -520,6 +530,7 @@ fileprivate enum Keys { static let pauseWhenShowingControls = "kVLCSettingPauseWhenShowingControls" static let playbackForwardBackwardEqual = "playback-forward-backward-equal" static let playbackLongTouchSpeedUp = "LongTouchSpeedUp" + static let playbackTapSwipeEqual = "playback-tap-swipe-equal" static let playerIsRepeatEnabled = "PlayerIsRepeatEnabled" static let playerIsShuffleEnabled = "PlayerIsShuffleEnabled" static let playerShouldRememberBrightness = "PlayerShouldRememberBrightness" diff --git a/Sources/Playback/Player/PlayerViewController.swift b/Sources/Playback/Player/PlayerViewController.swift index aaa9717db..e4eba2a88 100644 --- a/Sources/Playback/Player/PlayerViewController.swift +++ b/Sources/Playback/Player/PlayerViewController.swift @@ -738,7 +738,7 @@ class PlayerViewController: UIViewController { private func setupSeekDurations() { let defaults = UserDefaults.standard - tapSwipeEqual = defaults.bool(forKey: kVLCSettingPlaybackTapSwipeEqual) + tapSwipeEqual = VLCDefaults.shared.playbackTapSwipeEqual forwardBackwardEqual = VLCDefaults.shared.playbackForwardBackwardEqual seekForwardBy = defaults.integer(forKey: kVLCSettingPlaybackForwardSkipLength) seekBackwardBy = forwardBackwardEqual ? seekForwardBy : defaults.integer(forKey: kVLCSettingPlaybackBackwardSkipLength) diff --git a/Sources/Playback/Player/VideoPlayer-iOS/VideoPlayerViewController.swift b/Sources/Playback/Player/VideoPlayer-iOS/VideoPlayerViewController.swift index c0ad3ef95..887b24625 100644 --- a/Sources/Playback/Player/VideoPlayer-iOS/VideoPlayerViewController.swift +++ b/Sources/Playback/Player/VideoPlayer-iOS/VideoPlayerViewController.swift @@ -867,7 +867,7 @@ class VideoPlayerViewController: PlayerViewController { private func setupSeekDurations() { let defaults = UserDefaults.standard - tapSwipeEqual = defaults.bool(forKey: kVLCSettingPlaybackTapSwipeEqual) + tapSwipeEqual = VLCDefaults.shared.playbackTapSwipeEqual forwardBackwardEqual = VLCDefaults.shared.playbackForwardBackwardEqual seekForwardBy = defaults.integer(forKey: kVLCSettingPlaybackForwardSkipLength) seekBackwardBy = forwardBackwardEqual ? seekForwardBy : defaults.integer(forKey: kVLCSettingPlaybackBackwardSkipLength) diff --git a/Sources/Settings/Controller/SettingsController.swift b/Sources/Settings/Controller/SettingsController.swift index 3cdd3408a..9fe29188d 100644 --- a/Sources/Settings/Controller/SettingsController.swift +++ b/Sources/Settings/Controller/SettingsController.swift @@ -308,7 +308,7 @@ extension SettingsController { .sections(isLabActivated: isLabActivated, isBackingUp: isBackingUp, isForwardBackwardEqual: VLCDefaults.shared.playbackForwardBackwardEqual, - isTapSwipeEqual: userDefaults.bool(forKey: kVLCSettingPlaybackTapSwipeEqual)) + isTapSwipeEqual: VLCDefaults.shared.playbackTapSwipeEqual) } override func numberOfSections(in _: UITableView) -> Int { diff --git a/Sources/Settings/Model/SettingsSection.swift b/Sources/Settings/Model/SettingsSection.swift index f95066e02..20a7be336 100644 --- a/Sources/Settings/Model/SettingsSection.swift +++ b/Sources/Settings/Model/SettingsSection.swift @@ -385,7 +385,7 @@ enum GestureControlOptions { static var tapSwipeEqual: SettingsItem { .toggle(title: "SETTINGS_GESTURES_TAP_SWIPE_EQUAL", subtitle: nil, - preferenceKey: kVLCSettingPlaybackTapSwipeEqual) + keyPath: \.playbackTapSwipeEqual) } static var forwardSkipLength: SettingsItem { @@ -457,7 +457,7 @@ enum GestureControlOptions { private static func dynamicForwardSkipDescription() -> String { let forwardBackwardEqual = VLCDefaults.shared.playbackForwardBackwardEqual - let tapSwipeEqual = UserDefaults.standard.bool(forKey: kVLCSettingPlaybackTapSwipeEqual) + let tapSwipeEqual = VLCDefaults.shared.playbackTapSwipeEqual if forwardBackwardEqual && tapSwipeEqual { return "SETTINGS_PLAYBACK_SKIP_GENERIC" @@ -471,7 +471,7 @@ enum GestureControlOptions { } private static func dynamicBackwardSkipDescription() -> String { - let tapSwipeEqual = UserDefaults.standard.bool(forKey: kVLCSettingPlaybackTapSwipeEqual) + let tapSwipeEqual = VLCDefaults.shared.playbackTapSwipeEqual if tapSwipeEqual { return "SETTINGS_PLAYBACK_SKIP_BACKWARD" -- GitLab From 4959776a6073387ad00a34a05e0c7d0d0dc2cfb2 Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Tue, 25 Feb 2025 16:30:19 -0500 Subject: [PATCH 40/97] Convert kVLCSettingAlwaysPlayURLs --- Sources/App/iOS/VLCAppDelegate.m | 1 - Sources/Headers/VLCConstants.h | 1 - Sources/Helpers/Network/URLHandler.swift | 6 +++--- Sources/Helpers/VLCDefaults.swift | 11 +++++++++++ 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Sources/App/iOS/VLCAppDelegate.m b/Sources/App/iOS/VLCAppDelegate.m index 9166ca8cb..4a498c452 100644 --- a/Sources/App/iOS/VLCAppDelegate.m +++ b/Sources/App/iOS/VLCAppDelegate.m @@ -62,7 +62,6 @@ kVLCSettingBackupMediaLibrary : kVLCSettingBackupMediaLibraryDefaultValue, kVLCSettingCastingConversionQuality : @(2), kVLCSettingPlaybackSpeedDefaultValue: @(1.0), - kVLCSettingAlwaysPlayURLs: @(NO), kVLCSettingPlayerControlDuration: kVLCSettingPlayerControlDurationDefaultValue }; [defaults registerDefaults:appDefaults]; diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index a435acb1c..4c345abb8 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -63,7 +63,6 @@ #define kVLCSettingBackupMediaLibrary @"BackupMediaLibrary" #define kVLCSettingBackupMediaLibraryDefaultValue @NO #define kVLCSettingLastUsedSubtitlesSearchLanguage @"kVLCSettingLastUsedSubtitlesSearchLanguage" -#define kVLCSettingAlwaysPlayURLs @"kVLCSettingAlwaysPlayURLs" #define kVLCSettingDisableSubtitles @"kVLCSettingDisableSubtitles" #define kVLCSettingPlayerControlDuration @"kVLCSettingPlayerControlDuration" #define kVLCSettingPlayerControlDurationDefaultValue @(4) diff --git a/Sources/Helpers/Network/URLHandler.swift b/Sources/Helpers/Network/URLHandler.swift index 9ff0e7388..d0a6e375a 100644 --- a/Sources/Helpers/Network/URLHandler.swift +++ b/Sources/Helpers/Network/URLHandler.swift @@ -173,7 +173,7 @@ extension VLCURLHandler { let alwaysPlayAction = UIAlertAction(title: NSLocalizedString("ALWAYS_STREAM_URL", comment: ""), style: .default) { _ in - UserDefaults.standard.set(true, forKey: kVLCSettingAlwaysPlayURLs) + VLCDefaults.shared.alwaysPlayURLs = true self.handlePlay() } @@ -363,7 +363,7 @@ class XCallbackURLHandler: NSObject, VLCURLHandler { return true default: #if os(iOS) - if UserDefaults.standard.bool(forKey: kVLCSettingAlwaysPlayURLs) { + if VLCDefaults.shared.alwaysPlayURLs { self.handlePlay() } else { self.createAlert() @@ -410,7 +410,7 @@ public class VLCCallbackURLHandler: NSObject, VLCURLHandler { #if os(iOS) let scheme = transformedURL.scheme if scheme == "http" || scheme == "https" || scheme == "ftp" { - if UserDefaults.standard.bool(forKey: kVLCSettingAlwaysPlayURLs) { + if VLCDefaults.shared.alwaysPlayURLs { handlePlay() } else { self.createAlert() diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index 63e82191b..5ea94df10 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -20,6 +20,7 @@ @objc func registerDefaults() { var dict: [String: Any] = [ // bools + Keys.alwaysPlayURLs: false, Keys.appThemeBlack: false, Keys.automaticallyPlayNextItem: true, Keys.brightnessGesture: true, @@ -85,6 +86,15 @@ extension VLCDefaults { // Bools + @objc var alwaysPlayURLs: Bool { + get { + userDefaults.bool(forKey: Keys.alwaysPlayURLs) + } + set { + userDefaults.set(newValue, forKey: Keys.alwaysPlayURLs) + } + } + @objc var appThemeBlack: Bool { get { userDefaults.bool(forKey: Keys.appThemeBlack) @@ -508,6 +518,7 @@ extension VLCDefaults { fileprivate enum Keys { // Avoid ever changing these values. Some are used as parameters in functions. // Changing a value also causes the locally stored value to become unreachable. + static let alwaysPlayURLs = "kVLCSettingAlwaysPlayURLs" static let appThemeBlack = "blackTheme" static let automaticallyPlayNextItem = "AutomaticallyPlayNextItem" static let brightnessGesture = "EnableBrightnessGesture" -- GitLab From 8462a98ae2b26499755b5028f027d4eb44b8a53b Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Tue, 25 Feb 2025 16:37:55 -0500 Subject: [PATCH 41/97] Convert kVLCSettingPlaybackForwardSkipLengthSwipe --- Sources/App/iOS/VLCAppDelegate.m | 1 - Sources/Headers/VLCConstants.h | 2 -- Sources/Helpers/VLCDefaults.swift | 13 +++++++++++++ Sources/Playback/Player/PlayerViewController.swift | 2 +- .../VideoPlayer-iOS/VideoPlayerViewController.swift | 2 +- Sources/Settings/Model/SettingsSection.swift | 2 +- 6 files changed, 16 insertions(+), 6 deletions(-) diff --git a/Sources/App/iOS/VLCAppDelegate.m b/Sources/App/iOS/VLCAppDelegate.m index 4a498c452..6e9ad532e 100644 --- a/Sources/App/iOS/VLCAppDelegate.m +++ b/Sources/App/iOS/VLCAppDelegate.m @@ -54,7 +54,6 @@ kVLCSettingEqualizerProfile : kVLCSettingEqualizerProfileDefaultValue, kVLCSettingPlaybackForwardSkipLength : kVLCSettingPlaybackForwardSkipLengthDefaultValue, kVLCSettingPlaybackBackwardSkipLength : kVLCSettingPlaybackBackwardSkipLengthDefaultValue, - kVLCSettingPlaybackForwardSkipLengthSwipe : kVLCSettingPlaybackForwardSkipLengthSwipeDefaultValue, kVLCSettingPlaybackBackwardSkipLengthSwipe : kVLCSettingPlaybackBackwardSkipLengthSwipeDefaultValue, kVLCSettingPlaybackLockscreenSkip : @(NO), kVLCSettingPlaybackRemoteControlSkip : @(NO), diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index 4c345abb8..4b4e4b1e6 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -49,8 +49,6 @@ #define kVLCSettingPlaybackForwardSkipLengthDefaultValue @(10) #define kVLCSettingPlaybackBackwardSkipLength @"playback-backward-skip-length" #define kVLCSettingPlaybackBackwardSkipLengthDefaultValue @(10) -#define kVLCSettingPlaybackForwardSkipLengthSwipe @"playback-forward-skip-length-swipe" -#define kVLCSettingPlaybackForwardSkipLengthSwipeDefaultValue @(10) #define kVLCSettingPlaybackBackwardSkipLengthSwipe @"playback-backward-skip-length-swipe" #define kVLCSettingPlaybackBackwardSkipLengthSwipeDefaultValue @(10) #define kVLCSettingPlaybackLockscreenSkip @"playback-lockscreen-skip" diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index 5ea94df10..d37a3ace7 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -56,6 +56,7 @@ Keys.continueAudioPlayback: 1, Keys.continuePlayback: 1, Keys.defaultPreampLevel: Float(6), + Keys.playbackForwardSkipLengthSwipe: 10, // other Keys.hardwareDecoding: HardwareDecoding.hardware.rawValue, @@ -403,6 +404,15 @@ extension VLCDefaults { } } + @objc var playbackForwardSkipLengthSwipe: Int { + get { + userDefaults.integer(forKey: Keys.playbackForwardSkipLengthSwipe) + } + set { + userDefaults.set(newValue, forKey: Keys.playbackForwardSkipLengthSwipe) + } + } + // Other var hardwareDecoding: HardwareDecoding { @@ -486,6 +496,7 @@ extension VLCDefaults { static let hardwareDecodingKey: String = Keys.hardwareDecoding static let hideLibraryInFilesAppKey: String = Keys.hideLibraryInFilesApp static let networkCachingKey: String = Keys.networkCaching + static let playbackForwardSkipLengthSwipeKey: String = Keys.playbackForwardSkipLengthSwipe static let textEncodingKey: String = Keys.textEncoding override init() { @@ -540,6 +551,7 @@ fileprivate enum Keys { static let passcodeEnableBiometricAuth = "EnableBiometricAuth" static let pauseWhenShowingControls = "kVLCSettingPauseWhenShowingControls" static let playbackForwardBackwardEqual = "playback-forward-backward-equal" + static let playbackForwardSkipLengthSwipe = "playback-forward-skip-length-swipe" static let playbackLongTouchSpeedUp = "LongTouchSpeedUp" static let playbackTapSwipeEqual = "playback-tap-swipe-equal" static let playerIsRepeatEnabled = "PlayerIsRepeatEnabled" @@ -571,5 +583,6 @@ fileprivate enum Keys { fileprivate enum DefaultValues { static let textEncoding = "Windows-1252" static let networkSatIPChannelListUrl = "" + static let playbackForwardSkipLengthSwipe = 10 static let playerRepeatMode = VLCRepeatMode.doNotRepeat } diff --git a/Sources/Playback/Player/PlayerViewController.swift b/Sources/Playback/Player/PlayerViewController.swift index e4eba2a88..f4b9ba054 100644 --- a/Sources/Playback/Player/PlayerViewController.swift +++ b/Sources/Playback/Player/PlayerViewController.swift @@ -742,7 +742,7 @@ class PlayerViewController: UIViewController { forwardBackwardEqual = VLCDefaults.shared.playbackForwardBackwardEqual seekForwardBy = defaults.integer(forKey: kVLCSettingPlaybackForwardSkipLength) seekBackwardBy = forwardBackwardEqual ? seekForwardBy : defaults.integer(forKey: kVLCSettingPlaybackBackwardSkipLength) - seekForwardBySwipe = tapSwipeEqual ? seekForwardBy : defaults.integer(forKey: kVLCSettingPlaybackForwardSkipLengthSwipe) + seekForwardBySwipe = tapSwipeEqual ? seekForwardBy : VLCDefaults.shared.playbackForwardSkipLengthSwipe if tapSwipeEqual, forwardBackwardEqual { // if tap = swipe, and backward = forward, then backward swipe = forward tap diff --git a/Sources/Playback/Player/VideoPlayer-iOS/VideoPlayerViewController.swift b/Sources/Playback/Player/VideoPlayer-iOS/VideoPlayerViewController.swift index 887b24625..c224d25e6 100644 --- a/Sources/Playback/Player/VideoPlayer-iOS/VideoPlayerViewController.swift +++ b/Sources/Playback/Player/VideoPlayer-iOS/VideoPlayerViewController.swift @@ -871,7 +871,7 @@ class VideoPlayerViewController: PlayerViewController { forwardBackwardEqual = VLCDefaults.shared.playbackForwardBackwardEqual seekForwardBy = defaults.integer(forKey: kVLCSettingPlaybackForwardSkipLength) seekBackwardBy = forwardBackwardEqual ? seekForwardBy : defaults.integer(forKey: kVLCSettingPlaybackBackwardSkipLength) - seekForwardBySwipe = tapSwipeEqual ? seekForwardBy : defaults.integer(forKey: kVLCSettingPlaybackForwardSkipLengthSwipe) + seekForwardBySwipe = tapSwipeEqual ? seekForwardBy : VLCDefaults.shared.playbackForwardSkipLengthSwipe if tapSwipeEqual, forwardBackwardEqual { // if tap = swipe, and backward = forward, then backward swipe = forward tap diff --git a/Sources/Settings/Model/SettingsSection.swift b/Sources/Settings/Model/SettingsSection.swift index 20a7be336..50cc4597e 100644 --- a/Sources/Settings/Model/SettingsSection.swift +++ b/Sources/Settings/Model/SettingsSection.swift @@ -403,7 +403,7 @@ enum GestureControlOptions { } static var forwardSkipLengthSwipe: SettingsItem { - let k = kVLCSettingPlaybackForwardSkipLengthSwipe + let k = VLCDefaults.Compat.playbackForwardSkipLengthSwipeKey return .init(title: dynamicForwardSwipeDescription(), subtitle: Localizer.getSubtitle(for: k), action: .showActionSheet(title: dynamicForwardSwipeDescription(), preferenceKey: k, hasInfo: false)) -- GitLab From 813619ad82ade275969bf30ded94a9ed264deb9a Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Tue, 25 Feb 2025 16:46:22 -0500 Subject: [PATCH 42/97] Convert kVLCSettingPlaybackBackwardSkipLengthSwipe --- Sources/App/iOS/VLCAppDelegate.m | 3 --- Sources/Headers/VLCConstants.h | 4 ---- Sources/Helpers/VLCDefaults.swift | 13 +++++++++++++ Sources/Playback/Player/PlayerViewController.swift | 2 +- .../VideoPlayer-iOS/VideoPlayerViewController.swift | 2 +- Sources/Settings/Model/SettingsSection.swift | 2 +- 6 files changed, 16 insertions(+), 10 deletions(-) diff --git a/Sources/App/iOS/VLCAppDelegate.m b/Sources/App/iOS/VLCAppDelegate.m index 6e9ad532e..c52c66cc1 100644 --- a/Sources/App/iOS/VLCAppDelegate.m +++ b/Sources/App/iOS/VLCAppDelegate.m @@ -54,9 +54,6 @@ kVLCSettingEqualizerProfile : kVLCSettingEqualizerProfileDefaultValue, kVLCSettingPlaybackForwardSkipLength : kVLCSettingPlaybackForwardSkipLengthDefaultValue, kVLCSettingPlaybackBackwardSkipLength : kVLCSettingPlaybackBackwardSkipLengthDefaultValue, - kVLCSettingPlaybackBackwardSkipLengthSwipe : kVLCSettingPlaybackBackwardSkipLengthSwipeDefaultValue, - kVLCSettingPlaybackLockscreenSkip : @(NO), - kVLCSettingPlaybackRemoteControlSkip : @(NO), kVLCSettingOpenAppForPlayback : kVLCSettingOpenAppForPlaybackDefaultValue, kVLCSettingBackupMediaLibrary : kVLCSettingBackupMediaLibraryDefaultValue, kVLCSettingCastingConversionQuality : @(2), diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index 4b4e4b1e6..abe788b25 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -49,10 +49,6 @@ #define kVLCSettingPlaybackForwardSkipLengthDefaultValue @(10) #define kVLCSettingPlaybackBackwardSkipLength @"playback-backward-skip-length" #define kVLCSettingPlaybackBackwardSkipLengthDefaultValue @(10) -#define kVLCSettingPlaybackBackwardSkipLengthSwipe @"playback-backward-skip-length-swipe" -#define kVLCSettingPlaybackBackwardSkipLengthSwipeDefaultValue @(10) -#define kVLCSettingPlaybackLockscreenSkip @"playback-lockscreen-skip" -#define kVLCSettingPlaybackRemoteControlSkip @"playback-remote-control-skip" #define kVLCSettingOpenAppForPlayback @"open-app-for-playback" #define kVLCSettingOpenAppForPlaybackDefaultValue @YES #define kVLCSettingsDisableGrouping @"MLDisableGrouping" diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index d37a3ace7..4e953b045 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -56,6 +56,7 @@ Keys.continueAudioPlayback: 1, Keys.continuePlayback: 1, Keys.defaultPreampLevel: Float(6), + Keys.playbackBackwardSkipLengthSwipe: 10, Keys.playbackForwardSkipLengthSwipe: 10, // other @@ -404,6 +405,15 @@ extension VLCDefaults { } } + @objc var playbackBackwardSkipLengthSwipe: Int { + get { + userDefaults.integer(forKey: Keys.playbackBackwardSkipLengthSwipe) + } + set { + userDefaults.set(newValue, forKey: Keys.playbackBackwardSkipLengthSwipe) + } + } + @objc var playbackForwardSkipLengthSwipe: Int { get { userDefaults.integer(forKey: Keys.playbackForwardSkipLengthSwipe) @@ -496,6 +506,7 @@ extension VLCDefaults { static let hardwareDecodingKey: String = Keys.hardwareDecoding static let hideLibraryInFilesAppKey: String = Keys.hideLibraryInFilesApp static let networkCachingKey: String = Keys.networkCaching + static let playbackBackwardSkipLengthSwipeKey: String = Keys.playbackBackwardSkipLengthSwipe static let playbackForwardSkipLengthSwipeKey: String = Keys.playbackForwardSkipLengthSwipe static let textEncodingKey: String = Keys.textEncoding @@ -551,6 +562,7 @@ fileprivate enum Keys { static let passcodeEnableBiometricAuth = "EnableBiometricAuth" static let pauseWhenShowingControls = "kVLCSettingPauseWhenShowingControls" static let playbackForwardBackwardEqual = "playback-forward-backward-equal" + static let playbackBackwardSkipLengthSwipe = "playback-backward-skip-length-swipe" static let playbackForwardSkipLengthSwipe = "playback-forward-skip-length-swipe" static let playbackLongTouchSpeedUp = "LongTouchSpeedUp" static let playbackTapSwipeEqual = "playback-tap-swipe-equal" @@ -583,6 +595,7 @@ fileprivate enum Keys { fileprivate enum DefaultValues { static let textEncoding = "Windows-1252" static let networkSatIPChannelListUrl = "" + static let playbackBackwardSkipLengthSwipe = 10 static let playbackForwardSkipLengthSwipe = 10 static let playerRepeatMode = VLCRepeatMode.doNotRepeat } diff --git a/Sources/Playback/Player/PlayerViewController.swift b/Sources/Playback/Player/PlayerViewController.swift index f4b9ba054..47a9d1c3e 100644 --- a/Sources/Playback/Player/PlayerViewController.swift +++ b/Sources/Playback/Player/PlayerViewController.swift @@ -755,7 +755,7 @@ class PlayerViewController: UIViewController { seekBackwardBySwipe = seekForwardBySwipe } else { // otherwise backward swipe = backward swipe - seekBackwardBySwipe = defaults.integer(forKey: kVLCSettingPlaybackBackwardSkipLengthSwipe) + seekBackwardBySwipe = VLCDefaults.shared.playbackBackwardSkipLengthSwipe } } diff --git a/Sources/Playback/Player/VideoPlayer-iOS/VideoPlayerViewController.swift b/Sources/Playback/Player/VideoPlayer-iOS/VideoPlayerViewController.swift index c224d25e6..41365fd8a 100644 --- a/Sources/Playback/Player/VideoPlayer-iOS/VideoPlayerViewController.swift +++ b/Sources/Playback/Player/VideoPlayer-iOS/VideoPlayerViewController.swift @@ -884,7 +884,7 @@ class VideoPlayerViewController: PlayerViewController { seekBackwardBySwipe = seekForwardBySwipe } else { // otherwise backward swipe = backward swipe - seekBackwardBySwipe = defaults.integer(forKey: kVLCSettingPlaybackBackwardSkipLengthSwipe) + seekBackwardBySwipe = VLCDefaults.shared.playbackBackwardSkipLengthSwipe } } diff --git a/Sources/Settings/Model/SettingsSection.swift b/Sources/Settings/Model/SettingsSection.swift index 50cc4597e..576a6cdc5 100644 --- a/Sources/Settings/Model/SettingsSection.swift +++ b/Sources/Settings/Model/SettingsSection.swift @@ -410,7 +410,7 @@ enum GestureControlOptions { } static var backwardSkipLengthSwipe: SettingsItem { - let k = kVLCSettingPlaybackBackwardSkipLengthSwipe + let k = VLCDefaults.Compat.playbackBackwardSkipLengthSwipeKey return .init(title: "SETTINGS_PLAYBACK_SKIP_BACKWARD_SWIPE", subtitle: Localizer.getSubtitle(for: k), action: .showActionSheet(title: "SETTINGS_PLAYBACK_SKIP_BACKWARD_SWIPE", preferenceKey: k, hasInfo: false)) -- GitLab From 5fcb1be98a3e9fa8f8fc178f4a015006823cd2c3 Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Tue, 25 Feb 2025 16:54:05 -0500 Subject: [PATCH 43/97] Convert kVLCSettingPlayerControlDuration --- Sources/App/iOS/VLCAppDelegate.m | 3 +-- Sources/Headers/VLCConstants.h | 2 -- Sources/Headers/VLCTVConstants.h | 2 -- Sources/Helpers/VLCDefaults.swift | 17 +++++++++++++++-- .../VideoPlayerViewController.swift | 3 +-- Sources/Settings/Model/SettingsSection.swift | 4 ++-- 6 files changed, 19 insertions(+), 12 deletions(-) diff --git a/Sources/App/iOS/VLCAppDelegate.m b/Sources/App/iOS/VLCAppDelegate.m index c52c66cc1..4151c19a9 100644 --- a/Sources/App/iOS/VLCAppDelegate.m +++ b/Sources/App/iOS/VLCAppDelegate.m @@ -57,8 +57,7 @@ kVLCSettingOpenAppForPlayback : kVLCSettingOpenAppForPlaybackDefaultValue, kVLCSettingBackupMediaLibrary : kVLCSettingBackupMediaLibraryDefaultValue, kVLCSettingCastingConversionQuality : @(2), - kVLCSettingPlaybackSpeedDefaultValue: @(1.0), - kVLCSettingPlayerControlDuration: kVLCSettingPlayerControlDurationDefaultValue + kVLCSettingPlaybackSpeedDefaultValue: @(1.0) }; [defaults registerDefaults:appDefaults]; } diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index abe788b25..d1da3e0c1 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -58,8 +58,6 @@ #define kVLCSettingBackupMediaLibraryDefaultValue @NO #define kVLCSettingLastUsedSubtitlesSearchLanguage @"kVLCSettingLastUsedSubtitlesSearchLanguage" #define kVLCSettingDisableSubtitles @"kVLCSettingDisableSubtitles" -#define kVLCSettingPlayerControlDuration @"kVLCSettingPlayerControlDuration" -#define kVLCSettingPlayerControlDurationDefaultValue @(4) #define kVLCRecentURLs @"recent-urls" #define kVLCRecentURLTitles @"recent-url-titles" diff --git a/Sources/Headers/VLCTVConstants.h b/Sources/Headers/VLCTVConstants.h index 5bbaa7b8e..81c00f15c 100644 --- a/Sources/Headers/VLCTVConstants.h +++ b/Sources/Headers/VLCTVConstants.h @@ -63,8 +63,6 @@ #define kVLCSettingBackupMediaLibrary @"BackupMediaLibrary" #define kVLCSettingBackupMediaLibraryDefaultValue @NO #define kVLCSettingDisableSubtitles @"kVLCSettingDisableSubtitles" -#define kVLCSettingPlayerControlDuration @"kVLCSettingPlayerControlDuration" -#define kVLCSettingPlayerControlDurationDefaultValue @(4) #define kVLCLastPlayedMediaIdentifier @"LastPlayedMediaIdentifier" diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index 4e953b045..882c11808 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -56,8 +56,9 @@ Keys.continueAudioPlayback: 1, Keys.continuePlayback: 1, Keys.defaultPreampLevel: Float(6), - Keys.playbackBackwardSkipLengthSwipe: 10, - Keys.playbackForwardSkipLengthSwipe: 10, + Keys.playbackBackwardSkipLengthSwipe: DefaultValues.playbackBackwardSkipLengthSwipe, + Keys.playbackForwardSkipLengthSwipe: DefaultValues.playbackForwardSkipLengthSwipe, + Keys.playerControlDuration: DefaultValues.playerControlDuration, // other Keys.hardwareDecoding: HardwareDecoding.hardware.rawValue, @@ -423,6 +424,15 @@ extension VLCDefaults { } } + @objc var playerControlDuration: Int { + get { + userDefaults.integer(forKey: Keys.playerControlDuration) + } + set { + userDefaults.set(newValue, forKey: Keys.playerControlDuration) + } + } + // Other var hardwareDecoding: HardwareDecoding { @@ -508,6 +518,7 @@ extension VLCDefaults { static let networkCachingKey: String = Keys.networkCaching static let playbackBackwardSkipLengthSwipeKey: String = Keys.playbackBackwardSkipLengthSwipe static let playbackForwardSkipLengthSwipeKey: String = Keys.playbackForwardSkipLengthSwipe + static let playerControlDurationKey: String = Keys.playerControlDuration static let textEncodingKey: String = Keys.textEncoding override init() { @@ -566,6 +577,7 @@ fileprivate enum Keys { static let playbackForwardSkipLengthSwipe = "playback-forward-skip-length-swipe" static let playbackLongTouchSpeedUp = "LongTouchSpeedUp" static let playbackTapSwipeEqual = "playback-tap-swipe-equal" + static let playerControlDuration = "kVLCSettingPlayerControlDuration" static let playerIsRepeatEnabled = "PlayerIsRepeatEnabled" static let playerIsShuffleEnabled = "PlayerIsShuffleEnabled" static let playerShouldRememberBrightness = "PlayerShouldRememberBrightness" @@ -597,5 +609,6 @@ fileprivate enum DefaultValues { static let networkSatIPChannelListUrl = "" static let playbackBackwardSkipLengthSwipe = 10 static let playbackForwardSkipLengthSwipe = 10 + static let playerControlDuration = 4 static let playerRepeatMode = VLCRepeatMode.doNotRepeat } diff --git a/Sources/Playback/Player/VideoPlayer-iOS/VideoPlayerViewController.swift b/Sources/Playback/Player/VideoPlayer-iOS/VideoPlayerViewController.swift index 41365fd8a..93764335b 100644 --- a/Sources/Playback/Player/VideoPlayer-iOS/VideoPlayerViewController.swift +++ b/Sources/Playback/Player/VideoPlayer-iOS/VideoPlayerViewController.swift @@ -1349,8 +1349,7 @@ class VideoPlayerViewController: PlayerViewController { } private func resetIdleTimer() { - let intervalSetting = UserDefaults.standard - .integer(forKey: kVLCSettingPlayerControlDuration) + let intervalSetting = VLCDefaults.shared.playerControlDuration let interval = TimeInterval(max(intervalSetting, 4)) diff --git a/Sources/Settings/Model/SettingsSection.swift b/Sources/Settings/Model/SettingsSection.swift index 576a6cdc5..1b62b6796 100644 --- a/Sources/Settings/Model/SettingsSection.swift +++ b/Sources/Settings/Model/SettingsSection.swift @@ -753,10 +753,10 @@ enum NetworkOptions { enum Accessibility { static var playerControlDuration: SettingsItem { - let k = kVLCSettingPlayerControlDuration + let k = VLCDefaults.Compat.playerControlDurationKey return .init(title: "SETTINGS_PLAYER_CONTROL_DURATION", subtitle: Localizer.getSubtitle(for: k), - action: .showActionSheet(title: "SETTINGS_PLAYER_CONTROL_DURATION", preferenceKey: kVLCSettingPlayerControlDuration, hasInfo: false)) + action: .showActionSheet(title: "SETTINGS_PLAYER_CONTROL_DURATION", preferenceKey: k, hasInfo: false)) } static var pauseWhenShowingControls: SettingsItem { -- GitLab From a7cab8b75e354fa5e69ebda993092fa78fc482a7 Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Tue, 25 Feb 2025 17:03:01 -0500 Subject: [PATCH 44/97] Convert kVLCSettingPlaybackSpeedDefaultValue --- Sources/App/iOS/VLCAppDelegate.m | 1 - Sources/App/tvOS/AppleTVAppDelegate.m | 4 ++-- Sources/Headers/VLCConstants.h | 1 - Sources/Headers/VLCTVConstants.h | 1 - Sources/Helpers/VLCDefaults.swift | 12 ++++++++++++ Sources/Playback/Control/VLCPlaybackService.m | 2 +- .../VideoPlayer-iOS/Subviews/PlaybackSpeedView.swift | 4 ++-- .../VLCPlaybackInfoPlaybackTVViewController.m | 3 ++- Sources/Settings/Model/SettingsSection.swift | 2 +- 9 files changed, 20 insertions(+), 10 deletions(-) diff --git a/Sources/App/iOS/VLCAppDelegate.m b/Sources/App/iOS/VLCAppDelegate.m index 4151c19a9..9d72e2909 100644 --- a/Sources/App/iOS/VLCAppDelegate.m +++ b/Sources/App/iOS/VLCAppDelegate.m @@ -57,7 +57,6 @@ kVLCSettingOpenAppForPlayback : kVLCSettingOpenAppForPlaybackDefaultValue, kVLCSettingBackupMediaLibrary : kVLCSettingBackupMediaLibraryDefaultValue, kVLCSettingCastingConversionQuality : @(2), - kVLCSettingPlaybackSpeedDefaultValue: @(1.0) }; [defaults registerDefaults:appDefaults]; } diff --git a/Sources/App/tvOS/AppleTVAppDelegate.m b/Sources/App/tvOS/AppleTVAppDelegate.m index cff5f6cf2..4db6faa89 100644 --- a/Sources/App/tvOS/AppleTVAppDelegate.m +++ b/Sources/App/tvOS/AppleTVAppDelegate.m @@ -53,8 +53,8 @@ kVLCSettingPlaybackRemoteControlSkip : @(NO), kVLCSettingWiFiSharingIPv6 : kVLCSettingWiFiSharingIPv6DefaultValue, kVLCPlayerUIShouldHide : @(NO), - kVLCSettingBackupMediaLibrary : kVLCSettingBackupMediaLibraryDefaultValue, - kVLCSettingPlaybackSpeedDefaultValue: @(1.0)}; + kVLCSettingBackupMediaLibrary : kVLCSettingBackupMediaLibraryDefaultValue + }; [defaults registerDefaults:appDefaults]; } diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index d1da3e0c1..4a1cea9cf 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -40,7 +40,6 @@ #define kVLCSettingNetworkSatIPChannelList @"satip-channelist" #define kVLCSettingNetworkSatIPChannelListCustom @"CustomList" #define kVLCSettingsDecrapifyTitles @"MLDecrapifyTitles" -#define kVLCSettingPlaybackSpeedDefaultValue @"playback-speed" #define kVLCSettingWiFiSharingIPv6 @"wifi-sharing-ipv6" #define kVLCSettingWiFiSharingIPv6DefaultValue @(NO) #define kVLCSettingEqualizerProfile @"EqualizerProfile" diff --git a/Sources/Headers/VLCTVConstants.h b/Sources/Headers/VLCTVConstants.h index 81c00f15c..51d3a3c00 100644 --- a/Sources/Headers/VLCTVConstants.h +++ b/Sources/Headers/VLCTVConstants.h @@ -25,7 +25,6 @@ #define kSupportedProtocolSchemes @"(rtsp|mms|mmsh|udp|rtp|rtmp|sftp|ftp|smb)$" -#define kVLCSettingPlaybackSpeedDefaultValue @"playback-speed" #define kVLCSaveDebugLogs @"kVLCSaveDebugLogs" #define kVLCSettingNetworkSatIPChannelList @"satip-channelist" #define kVLCSettingNetworkSatIPChannelListCustom @"CustomList" diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index 882c11808..8bc97d586 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -424,6 +424,15 @@ extension VLCDefaults { } } + @objc var playbackSpeedDefaultValue: Float { + get { + userDefaults.float(forKey: Keys.playbackSpeedDefaultValue) + } + set { + userDefaults.set(newValue, forKey: Keys.playbackSpeedDefaultValue) + } + } + @objc var playerControlDuration: Int { get { userDefaults.integer(forKey: Keys.playerControlDuration) @@ -518,6 +527,7 @@ extension VLCDefaults { static let networkCachingKey: String = Keys.networkCaching static let playbackBackwardSkipLengthSwipeKey: String = Keys.playbackBackwardSkipLengthSwipe static let playbackForwardSkipLengthSwipeKey: String = Keys.playbackForwardSkipLengthSwipe + static let playbackSpeedDefaultValueKey: String = Keys.playbackSpeedDefaultValue static let playerControlDurationKey: String = Keys.playerControlDuration static let textEncodingKey: String = Keys.textEncoding @@ -576,6 +586,7 @@ fileprivate enum Keys { static let playbackBackwardSkipLengthSwipe = "playback-backward-skip-length-swipe" static let playbackForwardSkipLengthSwipe = "playback-forward-skip-length-swipe" static let playbackLongTouchSpeedUp = "LongTouchSpeedUp" + static let playbackSpeedDefaultValue = "playback-speed" static let playbackTapSwipeEqual = "playback-tap-swipe-equal" static let playerControlDuration = "kVLCSettingPlayerControlDuration" static let playerIsRepeatEnabled = "PlayerIsRepeatEnabled" @@ -609,6 +620,7 @@ fileprivate enum DefaultValues { static let networkSatIPChannelListUrl = "" static let playbackBackwardSkipLengthSwipe = 10 static let playbackForwardSkipLengthSwipe = 10 + static let playbackSpeedDefaultValue = Float(1) static let playerControlDuration = 4 static let playerRepeatMode = VLCRepeatMode.doNotRepeat } diff --git a/Sources/Playback/Control/VLCPlaybackService.m b/Sources/Playback/Control/VLCPlaybackService.m index 7669accbe..3e517f567 100644 --- a/Sources/Playback/Control/VLCPlaybackService.m +++ b/Sources/Playback/Control/VLCPlaybackService.m @@ -315,7 +315,7 @@ NSString *const VLCLastPlaylistPlayedMedia = @"LastPlaylistPlayedMedia"; #endif [_mediaPlayer setDelegate:self]; - CGFloat defaultPlaybackSpeed = [[defaults objectForKey:kVLCSettingPlaybackSpeedDefaultValue] floatValue]; + CGFloat defaultPlaybackSpeed = VLCDefaults.shared.playbackSpeedDefaultValue; if (defaultPlaybackSpeed != 0.) [_mediaPlayer setRate: defaultPlaybackSpeed]; int deinterlace = [[defaults objectForKey:kVLCSettingDeinterlace] intValue]; diff --git a/Sources/Playback/Player/VideoPlayer-iOS/Subviews/PlaybackSpeedView.swift b/Sources/Playback/Player/VideoPlayer-iOS/Subviews/PlaybackSpeedView.swift index 0c5cf9f98..d53050b29 100644 --- a/Sources/Playback/Player/VideoPlayer-iOS/Subviews/PlaybackSpeedView.swift +++ b/Sources/Playback/Player/VideoPlayer-iOS/Subviews/PlaybackSpeedView.swift @@ -50,7 +50,7 @@ class PlaybackSpeedView: UIView { private var currentSpeed: Float = 1.0 private let defaultDelay: Float = 0.0 - private var defaultSpeed: Float = UserDefaults.standard.float(forKey: kVLCSettingPlaybackSpeedDefaultValue) + private var defaultSpeed: Float = VLCDefaults.shared.playbackSpeedDefaultValue let vpc = PlaybackService.sharedInstance() let notificationCenter = NotificationCenter.default @@ -264,7 +264,7 @@ class PlaybackSpeedView: UIView { } func reset() { - defaultSpeed = UserDefaults.standard.float(forKey: kVLCSettingPlaybackSpeedDefaultValue) + defaultSpeed = VLCDefaults.shared.playbackSpeedDefaultValue currentSpeed = defaultSpeed vpc.playbackRate = currentSpeed notificationCenter.post(name: Notification.Name("ChangePlaybackSpeed"), object: nil) diff --git a/Sources/Playback/Player/VideoPlayer-tvOS/Playback Info/VLCPlaybackInfoPlaybackTVViewController.m b/Sources/Playback/Player/VideoPlayer-tvOS/Playback Info/VLCPlaybackInfoPlaybackTVViewController.m index 51f2fa49c..201fc1410 100644 --- a/Sources/Playback/Player/VideoPlayer-tvOS/Playback Info/VLCPlaybackInfoPlaybackTVViewController.m +++ b/Sources/Playback/Player/VideoPlayer-tvOS/Playback Info/VLCPlaybackInfoPlaybackTVViewController.m @@ -12,6 +12,7 @@ *****************************************************************************/ #import "VLCPlaybackInfoPlaybackTVViewController.h" +#import "VLC-Swift.h" @interface VLCPlaybackInfoPlaybackTVViewController () @property (nonatomic) VLCPlaybackService *playbackService; @@ -93,7 +94,7 @@ _decreaseSpeed = -0.05; _defaultDelay = 0.0; - _defaultSpeed = [[[NSUserDefaults standardUserDefaults] valueForKey:kVLCSettingPlaybackSpeedDefaultValue] doubleValue]; + _defaultSpeed = (double)VLCDefaults.shared.playbackSpeedDefaultValue; _titleLabel.textColor = UIColor.VLCLightTextColor; _valueLabel.textColor = UIColor.VLCLightTextColor; diff --git a/Sources/Settings/Model/SettingsSection.swift b/Sources/Settings/Model/SettingsSection.swift index 1b62b6796..4dacd9718 100644 --- a/Sources/Settings/Model/SettingsSection.swift +++ b/Sources/Settings/Model/SettingsSection.swift @@ -227,7 +227,7 @@ enum DonationOptions { enum GenericOptions { static var defaultPlaybackSpeed: SettingsItem { - let k = kVLCSettingPlaybackSpeedDefaultValue + let k = VLCDefaults.Compat.playbackSpeedDefaultValueKey return .init(title: "SETTINGS_PLAYBACK_SPEED_DEFAULT", subtitle: Localizer.getSubtitle(for: k), action: .showActionSheet(title: "SETTINGS_PLAYBACK_SPEED_DEFAULT", preferenceKey: k, hasInfo: false)) -- GitLab From a8e1431f72191ab8b537eec5fe37eb6feea8a942 Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Tue, 25 Feb 2025 17:09:10 -0500 Subject: [PATCH 45/97] Convert kVLCSettingBackupMediaLibrary --- Sources/App/iOS/VLCAppDelegate.m | 1 - Sources/App/tvOS/AppleTVAppDelegate.m | 1 - Sources/Headers/VLCConstants.h | 2 -- Sources/Headers/VLCTVConstants.h | 2 -- Sources/Helpers/VLCDefaults.swift | 12 ++++++++++++ .../Media Library/Discovery/VLCMediaFileDiscoverer.m | 2 +- Sources/Media Library/MediaLibraryService.swift | 2 +- Sources/Settings/Controller/SettingsController.swift | 2 +- Sources/Settings/Model/SettingsSection.swift | 2 +- 9 files changed, 16 insertions(+), 10 deletions(-) diff --git a/Sources/App/iOS/VLCAppDelegate.m b/Sources/App/iOS/VLCAppDelegate.m index 9d72e2909..ce20457da 100644 --- a/Sources/App/iOS/VLCAppDelegate.m +++ b/Sources/App/iOS/VLCAppDelegate.m @@ -55,7 +55,6 @@ kVLCSettingPlaybackForwardSkipLength : kVLCSettingPlaybackForwardSkipLengthDefaultValue, kVLCSettingPlaybackBackwardSkipLength : kVLCSettingPlaybackBackwardSkipLengthDefaultValue, kVLCSettingOpenAppForPlayback : kVLCSettingOpenAppForPlaybackDefaultValue, - kVLCSettingBackupMediaLibrary : kVLCSettingBackupMediaLibraryDefaultValue, kVLCSettingCastingConversionQuality : @(2), }; [defaults registerDefaults:appDefaults]; diff --git a/Sources/App/tvOS/AppleTVAppDelegate.m b/Sources/App/tvOS/AppleTVAppDelegate.m index 4db6faa89..a20dc44b3 100644 --- a/Sources/App/tvOS/AppleTVAppDelegate.m +++ b/Sources/App/tvOS/AppleTVAppDelegate.m @@ -53,7 +53,6 @@ kVLCSettingPlaybackRemoteControlSkip : @(NO), kVLCSettingWiFiSharingIPv6 : kVLCSettingWiFiSharingIPv6DefaultValue, kVLCPlayerUIShouldHide : @(NO), - kVLCSettingBackupMediaLibrary : kVLCSettingBackupMediaLibraryDefaultValue }; [defaults registerDefaults:appDefaults]; } diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index 4a1cea9cf..91e4913a3 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -53,8 +53,6 @@ #define kVLCSettingsDisableGrouping @"MLDisableGrouping" #define kVLCkVLCSettingsDisableGroupingDefaultValue @NO #define kVLCSettingCastingConversionQuality @"sout-chromecast-conversion-quality" -#define kVLCSettingBackupMediaLibrary @"BackupMediaLibrary" -#define kVLCSettingBackupMediaLibraryDefaultValue @NO #define kVLCSettingLastUsedSubtitlesSearchLanguage @"kVLCSettingLastUsedSubtitlesSearchLanguage" #define kVLCSettingDisableSubtitles @"kVLCSettingDisableSubtitles" diff --git a/Sources/Headers/VLCTVConstants.h b/Sources/Headers/VLCTVConstants.h index 51d3a3c00..025dbb89e 100644 --- a/Sources/Headers/VLCTVConstants.h +++ b/Sources/Headers/VLCTVConstants.h @@ -59,8 +59,6 @@ #define kVLCSettingSaveHTTPUploadServerStatus @"isHTTPServerOn" #define kVLCPlayerUIShouldHide @"PlayerUIShouldHide" #define kVLCSettingUseSPDIF @"kVLCSettingUseSPDIF" -#define kVLCSettingBackupMediaLibrary @"BackupMediaLibrary" -#define kVLCSettingBackupMediaLibraryDefaultValue @NO #define kVLCSettingDisableSubtitles @"kVLCSettingDisableSubtitles" #define kVLCLastPlayedMediaIdentifier @"LastPlayedMediaIdentifier" diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index 8bc97d586..29270ecd1 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -23,6 +23,7 @@ Keys.alwaysPlayURLs: false, Keys.appThemeBlack: false, Keys.automaticallyPlayNextItem: true, + Keys.backupMediaLibrary: false, Keys.brightnessGesture: true, Keys.castingAudioPassthrough: false, Keys.closeGesture: true, @@ -116,6 +117,15 @@ extension VLCDefaults { } } + @objc var backupMediaLibrary: Bool { + get { + userDefaults.bool(forKey: Keys.backupMediaLibrary) + } + set { + userDefaults.set(newValue, forKey: Keys.backupMediaLibrary) + } + } + @objc var brightnessGesture: Bool { get { userDefaults.bool(forKey: Keys.brightnessGesture) @@ -519,6 +529,7 @@ extension VLCDefaults { @objc(VLCDefaultsCompat) final class Compat: NSObject { static let automaticallyPlayNextItemKey: String = Keys.automaticallyPlayNextItem + static let backupMediaLibraryKey: String = Keys.backupMediaLibrary static let continueAudioPlaybackKey: String = Keys.continueAudioPlayback static let continuePlaybackKey: String = Keys.continuePlayback static let defaultPreampLevelKey: String = Keys.defaultPreampLevel @@ -564,6 +575,7 @@ fileprivate enum Keys { static let alwaysPlayURLs = "kVLCSettingAlwaysPlayURLs" static let appThemeBlack = "blackTheme" static let automaticallyPlayNextItem = "AutomaticallyPlayNextItem" + static let backupMediaLibrary = "BackupMediaLibrary" static let brightnessGesture = "EnableBrightnessGesture" static let castingAudioPassthrough = "sout-chromecast-audio-passthrough" static let closeGesture = "EnableCloseGesture" diff --git a/Sources/Media Library/Discovery/VLCMediaFileDiscoverer.m b/Sources/Media Library/Discovery/VLCMediaFileDiscoverer.m index c51e3f6f3..abac80737 100644 --- a/Sources/Media Library/Discovery/VLCMediaFileDiscoverer.m +++ b/Sources/Media Library/Discovery/VLCMediaFileDiscoverer.m @@ -200,7 +200,7 @@ const float MediaTimerInterval = 2.f; } } } - BOOL backupMediaLibrary = [NSUserDefaults.standardUserDefaults boolForKey:kVLCSettingBackupMediaLibrary]; + BOOL backupMediaLibrary = VLCDefaults.shared.backupMediaLibrary; NSURL *fileURL = [NSURL fileURLWithPath:filePath]; [fileURL setExcludedFromBackup:!backupMediaLibrary recursive:NO onlyFirstLevel:NO :nil]; diff --git a/Sources/Media Library/MediaLibraryService.swift b/Sources/Media Library/MediaLibraryService.swift index 1771acbf6..012f32f21 100644 --- a/Sources/Media Library/MediaLibraryService.swift +++ b/Sources/Media Library/MediaLibraryService.swift @@ -189,7 +189,7 @@ private extension MediaLibraryService { } private func startMediaLibrary(on path: String) { - let excludeMediaLibrary = !UserDefaults.standard.bool(forKey: kVLCSettingBackupMediaLibrary) + let excludeMediaLibrary = !VLCDefaults.shared.backupMediaLibrary let hideML = VLCDefaults.shared.hideLibraryInFilesApp excludeFromDeviceBackup(excludeMediaLibrary) hideMediaLibrary(hideML) diff --git a/Sources/Settings/Controller/SettingsController.swift b/Sources/Settings/Controller/SettingsController.swift index 9fe29188d..c40bbda0b 100644 --- a/Sources/Settings/Controller/SettingsController.swift +++ b/Sources/Settings/Controller/SettingsController.swift @@ -434,7 +434,7 @@ extension SettingsController: SettingsCellDelegate { passcodeLockSwitchOn(state: isOn) case VLCDefaults.Compat.hideLibraryInFilesAppKey: medialibraryHidingLockSwitchOn(state: isOn) - case kVLCSettingBackupMediaLibrary: + case VLCDefaults.Compat.backupMediaLibraryKey: mediaLibraryBackupActivateSwitchOn(state: isOn) case kVLCSettingsDisableGrouping: medialibraryDisableGroupingSwitchOn(state: isOn) diff --git a/Sources/Settings/Model/SettingsSection.swift b/Sources/Settings/Model/SettingsSection.swift index 4dacd9718..41de6616f 100644 --- a/Sources/Settings/Model/SettingsSection.swift +++ b/Sources/Settings/Model/SettingsSection.swift @@ -685,7 +685,7 @@ enum MediaLibraryOptions { static var includeMediaLibInDeviceBackup: SettingsItem { .toggle(title: "SETTINGS_BACKUP_MEDIA_LIBRARY", subtitle: nil, - preferenceKey: kVLCSettingBackupMediaLibrary) + keyPath: \.backupMediaLibrary) } static var includeMediaLibInDeviceBackupWhenBackingUp: SettingsItem { -- GitLab From 5f33d08d3f3eca409623ae02fdda699b3c76d74e Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Tue, 25 Feb 2025 17:11:31 -0500 Subject: [PATCH 46/97] Remove unused kVLCSettingOpenAppForPlayback --- Sources/App/iOS/VLCAppDelegate.m | 1 - Sources/Headers/VLCConstants.h | 2 -- 2 files changed, 3 deletions(-) diff --git a/Sources/App/iOS/VLCAppDelegate.m b/Sources/App/iOS/VLCAppDelegate.m index ce20457da..83139f23f 100644 --- a/Sources/App/iOS/VLCAppDelegate.m +++ b/Sources/App/iOS/VLCAppDelegate.m @@ -54,7 +54,6 @@ kVLCSettingEqualizerProfile : kVLCSettingEqualizerProfileDefaultValue, kVLCSettingPlaybackForwardSkipLength : kVLCSettingPlaybackForwardSkipLengthDefaultValue, kVLCSettingPlaybackBackwardSkipLength : kVLCSettingPlaybackBackwardSkipLengthDefaultValue, - kVLCSettingOpenAppForPlayback : kVLCSettingOpenAppForPlaybackDefaultValue, kVLCSettingCastingConversionQuality : @(2), }; [defaults registerDefaults:appDefaults]; diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index 91e4913a3..a35f81810 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -48,8 +48,6 @@ #define kVLCSettingPlaybackForwardSkipLengthDefaultValue @(10) #define kVLCSettingPlaybackBackwardSkipLength @"playback-backward-skip-length" #define kVLCSettingPlaybackBackwardSkipLengthDefaultValue @(10) -#define kVLCSettingOpenAppForPlayback @"open-app-for-playback" -#define kVLCSettingOpenAppForPlaybackDefaultValue @YES #define kVLCSettingsDisableGrouping @"MLDisableGrouping" #define kVLCkVLCSettingsDisableGroupingDefaultValue @NO #define kVLCSettingCastingConversionQuality @"sout-chromecast-conversion-quality" -- GitLab From bc4ea3b463230393e08bed57f402ae77c8c38236 Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Tue, 25 Feb 2025 17:52:07 -0500 Subject: [PATCH 47/97] Convert kVLCSettingDeinterlace --- Sources/App/iOS/VLCAppDelegate.m | 1 - Sources/App/tvOS/AppleTVAppDelegate.m | 1 - Sources/Headers/VLCConstants.h | 2 -- Sources/Headers/VLCTVConstants.h | 2 -- Sources/Helpers/VLCDefaults.swift | 13 +++++++++++++ Sources/Playback/Control/VLCPlaybackService.m | 2 +- Sources/Settings/Model/SettingsSection.swift | 2 +- 7 files changed, 15 insertions(+), 8 deletions(-) diff --git a/Sources/App/iOS/VLCAppDelegate.m b/Sources/App/iOS/VLCAppDelegate.m index 83139f23f..12e49637e 100644 --- a/Sources/App/iOS/VLCAppDelegate.m +++ b/Sources/App/iOS/VLCAppDelegate.m @@ -49,7 +49,6 @@ kVLCSettingSubtitlesFontColor : kVLCSettingSubtitlesFontColorDefaultValue, kVLCSettingSubtitlesFontSize : kVLCSettingSubtitlesFontSizeDefaultValue, kVLCSettingSubtitlesBoldFont: kVLCSettingSubtitlesBoldFontDefaultValue, - kVLCSettingDeinterlace : kVLCSettingDeinterlaceDefaultValue, kVLCSettingWiFiSharingIPv6 : kVLCSettingWiFiSharingIPv6DefaultValue, kVLCSettingEqualizerProfile : kVLCSettingEqualizerProfileDefaultValue, kVLCSettingPlaybackForwardSkipLength : kVLCSettingPlaybackForwardSkipLengthDefaultValue, diff --git a/Sources/App/tvOS/AppleTVAppDelegate.m b/Sources/App/tvOS/AppleTVAppDelegate.m index a20dc44b3..aa9434b64 100644 --- a/Sources/App/tvOS/AppleTVAppDelegate.m +++ b/Sources/App/tvOS/AppleTVAppDelegate.m @@ -45,7 +45,6 @@ kVLCSettingSubtitlesFontColor : kVLCSettingSubtitlesFontColorDefaultValue, kVLCSettingSubtitlesFontSize : kVLCSettingSubtitlesFontSizeDefaultValue, kVLCSettingSubtitlesBoldFont: kVLCSettingSubtitlesBoldFontDefaultValue, - kVLCSettingDeinterlace : kVLCSettingDeinterlaceDefaultValue, kVLCSettingEqualizerProfile : kVLCSettingEqualizerProfileDefaultValue, kVLCSettingPlaybackForwardSkipLength : kVLCSettingPlaybackForwardSkipLengthDefaultValue, kVLCSettingPlaybackBackwardSkipLength : kVLCSettingPlaybackBackwardSkipLengthDefaultValue, diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index a35f81810..6cef4161e 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -33,8 +33,6 @@ #define kVLCSettingSubtitlesFontColorDefaultValue @"16777215" #define kVLCSettingSubtitlesFilePath @"sub-file" #define kVLCSubtitlesCacheFolderName @"cached-subtitles" -#define kVLCSettingDeinterlace @"deinterlace" -#define kVLCSettingDeinterlaceDefaultValue @(-1) #define kVLCSettingRotationLock @"kVLCSettingRotationLock" #define kVLCSaveDebugLogs @"kVLCSaveDebugLogs" #define kVLCSettingNetworkSatIPChannelList @"satip-channelist" diff --git a/Sources/Headers/VLCTVConstants.h b/Sources/Headers/VLCTVConstants.h index 025dbb89e..eaa9e667e 100644 --- a/Sources/Headers/VLCTVConstants.h +++ b/Sources/Headers/VLCTVConstants.h @@ -36,8 +36,6 @@ #define kVLCSettingSkipLoopFilterNone @(0) #define kVLCSettingSkipLoopFilterNonRef @(1) #define kVLCSettingSkipLoopFilterNonKey @(3) -#define kVLCSettingDeinterlace @"deinterlace" -#define kVLCSettingDeinterlaceDefaultValue @(-1) #define kVLCSettingSubtitlesFont @"quartztext-font" #define kVLCSettingSubtitlesFontDefaultValue @"HelveticaNeue" #define kVLCSettingSubtitlesFontSize @"quartztext-rel-fontsize" diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index 29270ecd1..acd77916e 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -57,6 +57,7 @@ Keys.continueAudioPlayback: 1, Keys.continuePlayback: 1, Keys.defaultPreampLevel: Float(6), + Keys.deinterlace: DefaultValues.deinterlace, Keys.playbackBackwardSkipLengthSwipe: DefaultValues.playbackBackwardSkipLengthSwipe, Keys.playbackForwardSkipLengthSwipe: DefaultValues.playbackForwardSkipLengthSwipe, Keys.playerControlDuration: DefaultValues.playerControlDuration, @@ -416,6 +417,15 @@ extension VLCDefaults { } } + @objc var deinterlace: Int { + get { + userDefaults.integer(forKey: Keys.deinterlace) + } + set { + userDefaults.set(newValue, forKey: Keys.deinterlace) + } + } + @objc var playbackBackwardSkipLengthSwipe: Int { get { userDefaults.integer(forKey: Keys.playbackBackwardSkipLengthSwipe) @@ -533,6 +543,7 @@ extension VLCDefaults { static let continueAudioPlaybackKey: String = Keys.continueAudioPlayback static let continuePlaybackKey: String = Keys.continuePlayback static let defaultPreampLevelKey: String = Keys.defaultPreampLevel + static let deinterlaceKey: String = Keys.deinterlace static let hardwareDecodingKey: String = Keys.hardwareDecoding static let hideLibraryInFilesAppKey: String = Keys.hideLibraryInFilesApp static let networkCachingKey: String = Keys.networkCaching @@ -583,6 +594,7 @@ fileprivate enum Keys { static let continueAudioPlayback = "ContinueAudioPlayback" static let continuePlayback = "ContinuePlayback" static let defaultPreampLevel = "pre-amp-level" + static let deinterlace = "deinterlace" static let downloadArtwork = "download-artwork" static let enableMediaCellTextScrolling = "EnableMediaCellTextScrolling" static let equalizerProfileDisabled = "EqualizerDisabled" @@ -628,6 +640,7 @@ fileprivate enum Keys { // MARK: - Default Values fileprivate enum DefaultValues { + static let deinterlace = Int(-1) static let textEncoding = "Windows-1252" static let networkSatIPChannelListUrl = "" static let playbackBackwardSkipLengthSwipe = 10 diff --git a/Sources/Playback/Control/VLCPlaybackService.m b/Sources/Playback/Control/VLCPlaybackService.m index 3e517f567..190cb9cb0 100644 --- a/Sources/Playback/Control/VLCPlaybackService.m +++ b/Sources/Playback/Control/VLCPlaybackService.m @@ -318,7 +318,7 @@ NSString *const VLCLastPlaylistPlayedMedia = @"LastPlaylistPlayedMedia"; CGFloat defaultPlaybackSpeed = VLCDefaults.shared.playbackSpeedDefaultValue; if (defaultPlaybackSpeed != 0.) [_mediaPlayer setRate: defaultPlaybackSpeed]; - int deinterlace = [[defaults objectForKey:kVLCSettingDeinterlace] intValue]; + int deinterlace = VLCDefaults.shared.deinterlace; [_mediaPlayer setDeinterlace:deinterlace withFilter:@"blend"]; [_listPlayer setMediaList:self.mediaList]; diff --git a/Sources/Settings/Model/SettingsSection.swift b/Sources/Settings/Model/SettingsSection.swift index 41de6616f..63c1869c2 100644 --- a/Sources/Settings/Model/SettingsSection.swift +++ b/Sources/Settings/Model/SettingsSection.swift @@ -502,7 +502,7 @@ enum VideoOptions { } static var deInterlace: SettingsItem { - let k = kVLCSettingDeinterlace + let k = VLCDefaults.Compat.deinterlaceKey return .init(title: "SETTINGS_DEINTERLACE", subtitle: Localizer.getSubtitle(for: k), action: .showActionSheet(title: "SETTINGS_DEINTERLACE", preferenceKey: k, hasInfo: true)) -- GitLab From d64f00bef2af404efad8decdb7bbda100470bb88 Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Tue, 25 Feb 2025 18:00:05 -0500 Subject: [PATCH 48/97] Convert kVLCSettingEqualizerProfile --- Sources/App/iOS/VLCAppDelegate.m | 1 - Sources/App/tvOS/AppleTVAppDelegate.m | 1 - Sources/Headers/VLCConstants.h | 2 -- Sources/Headers/VLCTVConstants.h | 2 -- Sources/Helpers/VLCDefaults.swift | 12 ++++++++++++ Sources/Playback/Control/VLCPlaybackService.m | 6 +++--- .../Player/MiniPlayer-iOS/AudioMiniPlayer.swift | 2 +- Sources/Playback/Player/PlayerViewController.swift | 2 +- .../Subviews/CustomEqualizerProfiles.swift | 12 ++++++------ .../VideoPlayer-iOS/Subviews/EqualizerView.swift | 8 ++++---- .../VideoPlayer-iOS/VideoPlayerViewController.swift | 2 +- 11 files changed, 28 insertions(+), 22 deletions(-) diff --git a/Sources/App/iOS/VLCAppDelegate.m b/Sources/App/iOS/VLCAppDelegate.m index 12e49637e..1ca4d1959 100644 --- a/Sources/App/iOS/VLCAppDelegate.m +++ b/Sources/App/iOS/VLCAppDelegate.m @@ -50,7 +50,6 @@ kVLCSettingSubtitlesFontSize : kVLCSettingSubtitlesFontSizeDefaultValue, kVLCSettingSubtitlesBoldFont: kVLCSettingSubtitlesBoldFontDefaultValue, kVLCSettingWiFiSharingIPv6 : kVLCSettingWiFiSharingIPv6DefaultValue, - kVLCSettingEqualizerProfile : kVLCSettingEqualizerProfileDefaultValue, kVLCSettingPlaybackForwardSkipLength : kVLCSettingPlaybackForwardSkipLengthDefaultValue, kVLCSettingPlaybackBackwardSkipLength : kVLCSettingPlaybackBackwardSkipLengthDefaultValue, kVLCSettingCastingConversionQuality : @(2), diff --git a/Sources/App/tvOS/AppleTVAppDelegate.m b/Sources/App/tvOS/AppleTVAppDelegate.m index aa9434b64..87f68dcdb 100644 --- a/Sources/App/tvOS/AppleTVAppDelegate.m +++ b/Sources/App/tvOS/AppleTVAppDelegate.m @@ -45,7 +45,6 @@ kVLCSettingSubtitlesFontColor : kVLCSettingSubtitlesFontColorDefaultValue, kVLCSettingSubtitlesFontSize : kVLCSettingSubtitlesFontSizeDefaultValue, kVLCSettingSubtitlesBoldFont: kVLCSettingSubtitlesBoldFontDefaultValue, - kVLCSettingEqualizerProfile : kVLCSettingEqualizerProfileDefaultValue, kVLCSettingPlaybackForwardSkipLength : kVLCSettingPlaybackForwardSkipLengthDefaultValue, kVLCSettingPlaybackBackwardSkipLength : kVLCSettingPlaybackBackwardSkipLengthDefaultValue, kVLCSettingPlaybackLockscreenSkip : @(NO), diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index 6cef4161e..844c93820 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -40,8 +40,6 @@ #define kVLCSettingsDecrapifyTitles @"MLDecrapifyTitles" #define kVLCSettingWiFiSharingIPv6 @"wifi-sharing-ipv6" #define kVLCSettingWiFiSharingIPv6DefaultValue @(NO) -#define kVLCSettingEqualizerProfile @"EqualizerProfile" -#define kVLCSettingEqualizerProfileDefaultValue @(0) #define kVLCSettingPlaybackForwardSkipLength @"playback-forward-skip-length" #define kVLCSettingPlaybackForwardSkipLengthDefaultValue @(10) #define kVLCSettingPlaybackBackwardSkipLength @"playback-backward-skip-length" diff --git a/Sources/Headers/VLCTVConstants.h b/Sources/Headers/VLCTVConstants.h index eaa9e667e..8502a17d8 100644 --- a/Sources/Headers/VLCTVConstants.h +++ b/Sources/Headers/VLCTVConstants.h @@ -46,8 +46,6 @@ #define kVLCSettingSubtitlesFontColorDefaultValue @"16777215" #define kVLCSubtitlesCacheFolderName @"cached-subtitles" #define kVLCSettingSubtitlesFilePath @"sub-file" -#define kVLCSettingEqualizerProfile @"EqualizerProfile" -#define kVLCSettingEqualizerProfileDefaultValue @(0) #define kVLCSettingPlaybackForwardSkipLength @"playback-forward-skip-length" #define kVLCSettingPlaybackForwardSkipLengthDefaultValue @(10) #define kVLCSettingPlaybackBackwardSkipLength @"playback-backward-skip-length" diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index acd77916e..a876aa07d 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -58,6 +58,7 @@ Keys.continuePlayback: 1, Keys.defaultPreampLevel: Float(6), Keys.deinterlace: DefaultValues.deinterlace, + Keys.equalizerProfile: DefaultValues.equalizerProfile, Keys.playbackBackwardSkipLengthSwipe: DefaultValues.playbackBackwardSkipLengthSwipe, Keys.playbackForwardSkipLengthSwipe: DefaultValues.playbackForwardSkipLengthSwipe, Keys.playerControlDuration: DefaultValues.playerControlDuration, @@ -426,6 +427,15 @@ extension VLCDefaults { } } + @objc var equalizerProfile: Int { + get { + userDefaults.integer(forKey: Keys.equalizerProfile) + } + set { + userDefaults.set(newValue, forKey: Keys.equalizerProfile) + } + } + @objc var playbackBackwardSkipLengthSwipe: Int { get { userDefaults.integer(forKey: Keys.playbackBackwardSkipLengthSwipe) @@ -597,6 +607,7 @@ fileprivate enum Keys { static let deinterlace = "deinterlace" static let downloadArtwork = "download-artwork" static let enableMediaCellTextScrolling = "EnableMediaCellTextScrolling" + static let equalizerProfile = "EqualizerProfile" static let equalizerProfileDisabled = "EqualizerDisabled" static let forceSMBV1 = "smb-force-v1" static let hardwareDecoding = "codec" @@ -641,6 +652,7 @@ fileprivate enum Keys { fileprivate enum DefaultValues { static let deinterlace = Int(-1) + static let equalizerProfile = Int(0) static let textEncoding = "Windows-1252" static let networkSatIPChannelListUrl = "" static let playbackBackwardSkipLengthSwipe = 10 diff --git a/Sources/Playback/Control/VLCPlaybackService.m b/Sources/Playback/Control/VLCPlaybackService.m index 190cb9cb0..2826aaf63 100644 --- a/Sources/Playback/Control/VLCPlaybackService.m +++ b/Sources/Playback/Control/VLCPlaybackService.m @@ -347,7 +347,7 @@ NSString *const VLCLastPlaylistPlayedMedia = @"LastPlaylistPlayedMedia"; if (equalizerEnabled) { NSArray *presets = [VLCAudioEqualizer presets]; - unsigned int profile = (unsigned int)[userDefaults integerForKey:kVLCSettingEqualizerProfile]; + unsigned int profile = (unsigned int)VLCDefaults.shared.equalizerProfile; equalizer = [[VLCAudioEqualizer alloc] initWithPreset:presets[profile]]; } else { float preampValue = VLCDefaults.shared.defaultPreampLevel; @@ -1418,7 +1418,7 @@ NSString *const VLCLastPlaylistPlayedMedia = @"LastPlaylistPlayedMedia"; VLCDefaults.shared.equalizerProfileDisabled = NO; unsigned int actualProfile = profile - 1; - [userDefaults setInteger:actualProfile forKey:kVLCSettingEqualizerProfile]; + VLCDefaults.shared.equalizerProfile = actualProfile; NSArray *presets = [VLCAudioEqualizer presets]; VLCAudioEqualizer *equalizer = [[VLCAudioEqualizer alloc] initWithPreset:presets[actualProfile]]; @@ -1476,7 +1476,7 @@ NSString *const VLCLastPlaylistPlayedMedia = @"LastPlaylistPlayedMedia"; return [NSIndexPath indexPathForRow:0 inSection:0]; } - unsigned int actualProfile = (unsigned int)[userDefaults integerForKey:kVLCSettingEqualizerProfile]; + unsigned int actualProfile = (unsigned int)VLCDefaults.shared.equalizerProfile; if (![userDefaults boolForKey:kVLCCustomProfileEnabled]) { return [NSIndexPath indexPathForRow:actualProfile + 1 inSection:0]; } else { diff --git a/Sources/Playback/Player/MiniPlayer-iOS/AudioMiniPlayer.swift b/Sources/Playback/Player/MiniPlayer-iOS/AudioMiniPlayer.swift index 961431cc9..87a0304f7 100644 --- a/Sources/Playback/Player/MiniPlayer-iOS/AudioMiniPlayer.swift +++ b/Sources/Playback/Player/MiniPlayer-iOS/AudioMiniPlayer.swift @@ -170,7 +170,7 @@ private extension AudioMiniPlayer { return } - let profileIndex = userDefaults.integer(forKey: kVLCSettingEqualizerProfile) + let profileIndex = VLCDefaults.shared.equalizerProfile let encodedData = userDefaults.data(forKey: kVLCCustomEqualizerProfiles) guard let encodedData = encodedData, diff --git a/Sources/Playback/Player/PlayerViewController.swift b/Sources/Playback/Player/PlayerViewController.swift index 47a9d1c3e..20e746ee9 100644 --- a/Sources/Playback/Player/PlayerViewController.swift +++ b/Sources/Playback/Player/PlayerViewController.swift @@ -765,7 +765,7 @@ class PlayerViewController: UIViewController { return } - let profileIndex = userDefaults.integer(forKey: kVLCSettingEqualizerProfile) + let profileIndex = VLCDefaults.shared.equalizerProfile let encodedData = userDefaults.data(forKey: kVLCCustomEqualizerProfiles) guard let encodedData = encodedData, diff --git a/Sources/Playback/Player/VideoPlayer-iOS/Subviews/CustomEqualizerProfiles.swift b/Sources/Playback/Player/VideoPlayer-iOS/Subviews/CustomEqualizerProfiles.swift index 1ee4d69a2..c1a16e4d8 100644 --- a/Sources/Playback/Player/VideoPlayer-iOS/Subviews/CustomEqualizerProfiles.swift +++ b/Sources/Playback/Player/VideoPlayer-iOS/Subviews/CustomEqualizerProfiles.swift @@ -89,12 +89,12 @@ class CustomEqualizerProfiles: NSObject, NSCoding { let userDefaults = UserDefaults.standard if userDefaults.bool(forKey: kVLCCustomProfileEnabled) { - let currentProfileIndex = userDefaults.integer(forKey: kVLCSettingEqualizerProfile) + let currentProfileIndex = VLCDefaults.shared.equalizerProfile if currentProfileIndex == index { - userDefaults.setValue(index - 1, forKeyPath: kVLCSettingEqualizerProfile) + VLCDefaults.shared.equalizerProfile = index - 1 } else if currentProfileIndex == index - 1 { - userDefaults.setValue(index, forKey: kVLCSettingEqualizerProfile) + VLCDefaults.shared.equalizerProfile = index } } } @@ -108,12 +108,12 @@ class CustomEqualizerProfiles: NSObject, NSCoding { let userDefaults = UserDefaults.standard if userDefaults.bool(forKey: kVLCCustomProfileEnabled) { - let currentProfileIndex = userDefaults.integer(forKey: kVLCSettingEqualizerProfile) + let currentProfileIndex = VLCDefaults.shared.equalizerProfile if currentProfileIndex == index { - userDefaults.setValue(index + 1, forKeyPath: kVLCSettingEqualizerProfile) + VLCDefaults.shared.equalizerProfile = index + 1 } else if currentProfileIndex == index + 1 { - userDefaults.setValue(index, forKey: kVLCSettingEqualizerProfile) + VLCDefaults.shared.equalizerProfile = index } } } diff --git a/Sources/Playback/Player/VideoPlayer-iOS/Subviews/EqualizerView.swift b/Sources/Playback/Player/VideoPlayer-iOS/Subviews/EqualizerView.swift index f05bbef26..79e2b5d2f 100644 --- a/Sources/Playback/Player/VideoPlayer-iOS/Subviews/EqualizerView.swift +++ b/Sources/Playback/Player/VideoPlayer-iOS/Subviews/EqualizerView.swift @@ -463,7 +463,7 @@ extension EqualizerView { userDefaults.setValue(NSKeyedArchiver.archivedData(withRootObject: customProfiles), forKey: kVLCCustomEqualizerProfiles) userDefaults.setValue(true, forKey: kVLCCustomProfileEnabled) VLCDefaults.shared.equalizerProfileDisabled = false - userDefaults.setValue(index, forKey: kVLCSettingEqualizerProfile) + VLCDefaults.shared.equalizerProfile = index self.presetSelectorView?.presetsTableView.reloadData() self.shouldDisplaySaveButton(false) @@ -485,10 +485,10 @@ extension EqualizerView { let profile: Int if !isCustomProfile { - profile = isEqualizerDisabled ? 0 : userDefaults.integer(forKey: kVLCSettingEqualizerProfile) + 1 + profile = isEqualizerDisabled ? 0 : VLCDefaults.shared.equalizerProfile + 1 delegate?.resetEqualizer(fromProfile: UInt32(profile)) } else { - profile = userDefaults.integer(forKey: kVLCSettingEqualizerProfile) + profile = VLCDefaults.shared.equalizerProfile applyCustomProfile(profile) } @@ -518,7 +518,7 @@ extension EqualizerView { playbackService.setAmplification(CGFloat(frequency), forBand: UInt32(bandIndex)) } - userDefaults.setValue(index, forKey: kVLCSettingEqualizerProfile) + VLCDefaults.shared.equalizerProfile = index VLCDefaults.shared.equalizerProfileDisabled = false userDefaults.setValue(true, forKey: kVLCCustomProfileEnabled) } diff --git a/Sources/Playback/Player/VideoPlayer-iOS/VideoPlayerViewController.swift b/Sources/Playback/Player/VideoPlayer-iOS/VideoPlayerViewController.swift index 93764335b..be302a0b4 100644 --- a/Sources/Playback/Player/VideoPlayer-iOS/VideoPlayerViewController.swift +++ b/Sources/Playback/Player/VideoPlayer-iOS/VideoPlayerViewController.swift @@ -1389,7 +1389,7 @@ class VideoPlayerViewController: PlayerViewController { return } - let profileIndex = userDefaults.integer(forKey: kVLCSettingEqualizerProfile) + let profileIndex = VLCDefaults.shared.equalizerProfile let encodedData = userDefaults.data(forKey: kVLCCustomEqualizerProfiles) guard let encodedData = encodedData, -- GitLab From 76510ea14ea4db250f75050504037002735f42f7 Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Tue, 25 Feb 2025 19:18:07 -0500 Subject: [PATCH 49/97] Convert kVLCTabBarIndex --- Sources/App/iOS/TabBarCoordinator.swift | 4 ++-- Sources/Headers/VLCConstants.h | 2 -- Sources/Helpers/VLCDefaults.swift | 11 +++++++++++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Sources/App/iOS/TabBarCoordinator.swift b/Sources/App/iOS/TabBarCoordinator.swift index 83047c4df..b956f1bc0 100644 --- a/Sources/App/iOS/TabBarCoordinator.swift +++ b/Sources/App/iOS/TabBarCoordinator.swift @@ -50,7 +50,7 @@ class TabBarCoordinator: NSObject { ] tabBarController.viewControllers = controllers.map { UINavigationController(rootViewController: $0) } - tabBarController.selectedIndex = UserDefaults.standard.integer(forKey: kVLCTabBarIndex) + tabBarController.selectedIndex = VLCDefaults.shared.tabBarIndex } func setupEditToolbar() { @@ -162,6 +162,6 @@ class TabBarCoordinator: NSObject { extension TabBarCoordinator: UITabBarControllerDelegate { func tabBarController(_ tabBarController: UITabBarController, didSelect viewController: UIViewController) { let viewControllerIndex: Int = tabBarController.viewControllers?.firstIndex(of: viewController) ?? 0 - UserDefaults.standard.set(viewControllerIndex, forKey: kVLCTabBarIndex) + VLCDefaults.shared.tabBarIndex = viewControllerIndex } } diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index 844c93820..c717aecd6 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -108,8 +108,6 @@ #define kVLCNumberOfLaunches @"kVLCNumberOfLaunches" #define kVLCHasActiveSubscription @"kVLCHasActiveSubscription" -#define kVLCTabBarIndex @"TabBarIndex" - #define kVLCGroupLayout @"kVLCGroupLayout" #define kVLCEqualizerSnapBands @"EqualizerSnapBands" diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index a876aa07d..48c7da091 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -62,6 +62,7 @@ Keys.playbackBackwardSkipLengthSwipe: DefaultValues.playbackBackwardSkipLengthSwipe, Keys.playbackForwardSkipLengthSwipe: DefaultValues.playbackForwardSkipLengthSwipe, Keys.playerControlDuration: DefaultValues.playerControlDuration, + Keys.tabBarIndex: 0, // other Keys.hardwareDecoding: HardwareDecoding.hardware.rawValue, @@ -472,6 +473,15 @@ extension VLCDefaults { } } + @objc var tabBarIndex: Int { + get { + userDefaults.integer(forKey: Keys.tabBarIndex) + } + set { + userDefaults.set(newValue, forKey: Keys.tabBarIndex) + } + } + // Other var hardwareDecoding: HardwareDecoding { @@ -637,6 +647,7 @@ fileprivate enum Keys { static let showRemainingTime = "show-remaining-time" static let showThumbnails = "ShowThumbnails" static let stretchAudio = "audio-time-stretch" + static let tabBarIndex = "TabBarIndex" static let textEncoding = "subsdec-encoding" static let videoFullscreenPlayback = "AlwaysUseFullscreenForVideo" static let volumeGesture = "EnableVolumeGesture" -- GitLab From 14f78acb781b6865b4cef6ea3ebebcc90d316a24 Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Tue, 25 Feb 2025 19:27:44 -0500 Subject: [PATCH 50/97] Convert kVLCSettingPlaybackForwardSkipLength --- Sources/App/iOS/VLCAppDelegate.m | 1 - Sources/App/tvOS/AppleTVAppDelegate.m | 1 - Sources/Headers/VLCConstants.h | 2 -- Sources/Headers/VLCTVConstants.h | 2 -- Sources/Helpers/VLCDefaults.swift | 13 +++++++++++++ Sources/Playback/Control/VLCPlaybackService.m | 2 +- .../Playback/Control/VLCPlayerDisplayController.m | 2 +- .../OS Integration/VLCRemoteControlService.m | 3 ++- Sources/Playback/Player/PlayerViewController.swift | 2 +- .../VideoPlayer-iOS/MediaScrubProgressBar.swift | 3 +-- .../VideoPlayer-iOS/VideoPlayerViewController.swift | 2 +- Sources/Settings/Model/SettingsSection.swift | 2 +- 12 files changed, 21 insertions(+), 14 deletions(-) diff --git a/Sources/App/iOS/VLCAppDelegate.m b/Sources/App/iOS/VLCAppDelegate.m index 1ca4d1959..6afbebac5 100644 --- a/Sources/App/iOS/VLCAppDelegate.m +++ b/Sources/App/iOS/VLCAppDelegate.m @@ -50,7 +50,6 @@ kVLCSettingSubtitlesFontSize : kVLCSettingSubtitlesFontSizeDefaultValue, kVLCSettingSubtitlesBoldFont: kVLCSettingSubtitlesBoldFontDefaultValue, kVLCSettingWiFiSharingIPv6 : kVLCSettingWiFiSharingIPv6DefaultValue, - kVLCSettingPlaybackForwardSkipLength : kVLCSettingPlaybackForwardSkipLengthDefaultValue, kVLCSettingPlaybackBackwardSkipLength : kVLCSettingPlaybackBackwardSkipLengthDefaultValue, kVLCSettingCastingConversionQuality : @(2), }; diff --git a/Sources/App/tvOS/AppleTVAppDelegate.m b/Sources/App/tvOS/AppleTVAppDelegate.m index 87f68dcdb..f57a3ad76 100644 --- a/Sources/App/tvOS/AppleTVAppDelegate.m +++ b/Sources/App/tvOS/AppleTVAppDelegate.m @@ -45,7 +45,6 @@ kVLCSettingSubtitlesFontColor : kVLCSettingSubtitlesFontColorDefaultValue, kVLCSettingSubtitlesFontSize : kVLCSettingSubtitlesFontSizeDefaultValue, kVLCSettingSubtitlesBoldFont: kVLCSettingSubtitlesBoldFontDefaultValue, - kVLCSettingPlaybackForwardSkipLength : kVLCSettingPlaybackForwardSkipLengthDefaultValue, kVLCSettingPlaybackBackwardSkipLength : kVLCSettingPlaybackBackwardSkipLengthDefaultValue, kVLCSettingPlaybackLockscreenSkip : @(NO), kVLCSettingPlaybackRemoteControlSkip : @(NO), diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index c717aecd6..27e4187e4 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -40,8 +40,6 @@ #define kVLCSettingsDecrapifyTitles @"MLDecrapifyTitles" #define kVLCSettingWiFiSharingIPv6 @"wifi-sharing-ipv6" #define kVLCSettingWiFiSharingIPv6DefaultValue @(NO) -#define kVLCSettingPlaybackForwardSkipLength @"playback-forward-skip-length" -#define kVLCSettingPlaybackForwardSkipLengthDefaultValue @(10) #define kVLCSettingPlaybackBackwardSkipLength @"playback-backward-skip-length" #define kVLCSettingPlaybackBackwardSkipLengthDefaultValue @(10) #define kVLCSettingsDisableGrouping @"MLDisableGrouping" diff --git a/Sources/Headers/VLCTVConstants.h b/Sources/Headers/VLCTVConstants.h index 8502a17d8..fc1f243b8 100644 --- a/Sources/Headers/VLCTVConstants.h +++ b/Sources/Headers/VLCTVConstants.h @@ -46,8 +46,6 @@ #define kVLCSettingSubtitlesFontColorDefaultValue @"16777215" #define kVLCSubtitlesCacheFolderName @"cached-subtitles" #define kVLCSettingSubtitlesFilePath @"sub-file" -#define kVLCSettingPlaybackForwardSkipLength @"playback-forward-skip-length" -#define kVLCSettingPlaybackForwardSkipLengthDefaultValue @(10) #define kVLCSettingPlaybackBackwardSkipLength @"playback-backward-skip-length" #define kVLCSettingPlaybackBackwardSkipLengthDefaultValue @(10) #define kVLCSettingPlaybackLockscreenSkip @"playback-lockscreen-skip" diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index 48c7da091..2c4cf818e 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -60,6 +60,7 @@ Keys.deinterlace: DefaultValues.deinterlace, Keys.equalizerProfile: DefaultValues.equalizerProfile, Keys.playbackBackwardSkipLengthSwipe: DefaultValues.playbackBackwardSkipLengthSwipe, + Keys.playbackForwardSkipLength: DefaultValues.playbackForwardSkipLength, Keys.playbackForwardSkipLengthSwipe: DefaultValues.playbackForwardSkipLengthSwipe, Keys.playerControlDuration: DefaultValues.playerControlDuration, Keys.tabBarIndex: 0, @@ -446,6 +447,15 @@ extension VLCDefaults { } } + @objc var playbackForwardSkipLength: Int { + get { + userDefaults.integer(forKey: Keys.playbackForwardSkipLength) + } + set { + userDefaults.set(newValue, forKey: Keys.playbackForwardSkipLength) + } + } + @objc var playbackForwardSkipLengthSwipe: Int { get { userDefaults.integer(forKey: Keys.playbackForwardSkipLengthSwipe) @@ -568,6 +578,7 @@ extension VLCDefaults { static let hideLibraryInFilesAppKey: String = Keys.hideLibraryInFilesApp static let networkCachingKey: String = Keys.networkCaching static let playbackBackwardSkipLengthSwipeKey: String = Keys.playbackBackwardSkipLengthSwipe + static let playbackForwardSkipLengthKey: String = Keys.playbackForwardSkipLength static let playbackForwardSkipLengthSwipeKey: String = Keys.playbackForwardSkipLengthSwipe static let playbackSpeedDefaultValueKey: String = Keys.playbackSpeedDefaultValue static let playerControlDurationKey: String = Keys.playerControlDuration @@ -628,6 +639,7 @@ fileprivate enum Keys { static let passcodeEnableBiometricAuth = "EnableBiometricAuth" static let pauseWhenShowingControls = "kVLCSettingPauseWhenShowingControls" static let playbackForwardBackwardEqual = "playback-forward-backward-equal" + static let playbackForwardSkipLength = "playback-forward-skip-length" static let playbackBackwardSkipLengthSwipe = "playback-backward-skip-length-swipe" static let playbackForwardSkipLengthSwipe = "playback-forward-skip-length-swipe" static let playbackLongTouchSpeedUp = "LongTouchSpeedUp" @@ -667,6 +679,7 @@ fileprivate enum DefaultValues { static let textEncoding = "Windows-1252" static let networkSatIPChannelListUrl = "" static let playbackBackwardSkipLengthSwipe = 10 + static let playbackForwardSkipLength = 10 static let playbackForwardSkipLengthSwipe = 10 static let playbackSpeedDefaultValue = Float(1) static let playerControlDuration = 4 diff --git a/Sources/Playback/Control/VLCPlaybackService.m b/Sources/Playback/Control/VLCPlaybackService.m index 2826aaf63..a7a4ca1ab 100644 --- a/Sources/Playback/Control/VLCPlaybackService.m +++ b/Sources/Playback/Control/VLCPlaybackService.m @@ -1080,7 +1080,7 @@ NSString *const VLCLastPlaylistPlayedMedia = @"LastPlaylistPlayedMedia"; - (BOOL)next { if (_mediaList.count == 1) { - NSNumber *skipLength = [[NSUserDefaults standardUserDefaults] valueForKey:kVLCSettingPlaybackForwardSkipLength]; + NSNumber *skipLength = [NSNumber numberWithInteger:VLCDefaults.shared.playbackForwardSkipLength]; [_mediaPlayer jumpForward:skipLength.intValue]; return YES; } diff --git a/Sources/Playback/Control/VLCPlayerDisplayController.m b/Sources/Playback/Control/VLCPlayerDisplayController.m index 869f321ce..037cc0ff7 100644 --- a/Sources/Playback/Control/VLCPlayerDisplayController.m +++ b/Sources/Playback/Control/VLCPlayerDisplayController.m @@ -679,7 +679,7 @@ NSString *const VLCPlayerDisplayControllerHideMiniPlayer = @"VLCPlayerDisplayCon - (void)keyRightArrow { - NSInteger seekBy = [[NSUserDefaults standardUserDefaults] integerForKey:kVLCSettingPlaybackForwardSkipLength]; + NSInteger seekBy = VLCDefaults.shared.playbackForwardSkipLength; [_playbackController jumpForward:(int)seekBy]; } diff --git a/Sources/Playback/OS Integration/VLCRemoteControlService.m b/Sources/Playback/OS Integration/VLCRemoteControlService.m index 4ac418525..2eba79e35 100644 --- a/Sources/Playback/OS Integration/VLCRemoteControlService.m +++ b/Sources/Playback/OS Integration/VLCRemoteControlService.m @@ -13,6 +13,7 @@ #import "VLCRemoteControlService.h" #import "VLCPlaybackService.h" +#import "VLC-Swift.h" #import <MediaPlayer/MediaPlayer.h> @implementation VLCRemoteControlService @@ -78,7 +79,7 @@ static inline NSArray * RemoteCommandCenterCommandsToHandle(void) commandCenter.seekForwardCommand.enabled = NO; commandCenter.seekBackwardCommand.enabled = NO; - NSNumber *forwardSkip = [defaults valueForKey:kVLCSettingPlaybackForwardSkipLength]; + NSNumber *forwardSkip = [NSNumber numberWithInteger:VLCDefaults.shared.playbackForwardSkipLength]; commandCenter.skipForwardCommand.preferredIntervals = @[forwardSkip]; NSNumber *backwardSkip = [defaults valueForKey:kVLCSettingPlaybackBackwardSkipLength]; commandCenter.skipBackwardCommand.preferredIntervals = @[backwardSkip]; diff --git a/Sources/Playback/Player/PlayerViewController.swift b/Sources/Playback/Player/PlayerViewController.swift index 20e746ee9..e13dcea16 100644 --- a/Sources/Playback/Player/PlayerViewController.swift +++ b/Sources/Playback/Player/PlayerViewController.swift @@ -740,7 +740,7 @@ class PlayerViewController: UIViewController { tapSwipeEqual = VLCDefaults.shared.playbackTapSwipeEqual forwardBackwardEqual = VLCDefaults.shared.playbackForwardBackwardEqual - seekForwardBy = defaults.integer(forKey: kVLCSettingPlaybackForwardSkipLength) + seekForwardBy = VLCDefaults.shared.playbackForwardSkipLength seekBackwardBy = forwardBackwardEqual ? seekForwardBy : defaults.integer(forKey: kVLCSettingPlaybackBackwardSkipLength) seekForwardBySwipe = tapSwipeEqual ? seekForwardBy : VLCDefaults.shared.playbackForwardSkipLengthSwipe diff --git a/Sources/Playback/Player/VideoPlayer-iOS/MediaScrubProgressBar.swift b/Sources/Playback/Player/VideoPlayer-iOS/MediaScrubProgressBar.swift index 3dea3fb01..ac7747173 100644 --- a/Sources/Playback/Player/VideoPlayer-iOS/MediaScrubProgressBar.swift +++ b/Sources/Playback/Player/VideoPlayer-iOS/MediaScrubProgressBar.swift @@ -144,8 +144,7 @@ class MediaScrubProgressBar: UIStackView { } @objc private func handleAccessibilityForward() -> Bool { - let defaults = UserDefaults.standard - playbackService.jumpForward(Int32(defaults.integer(forKey: kVLCSettingPlaybackForwardSkipLength))) + playbackService.jumpForward(Int32(VLCDefaults.shared.playbackForwardSkipLength)) return true } diff --git a/Sources/Playback/Player/VideoPlayer-iOS/VideoPlayerViewController.swift b/Sources/Playback/Player/VideoPlayer-iOS/VideoPlayerViewController.swift index be302a0b4..840b4f18d 100644 --- a/Sources/Playback/Player/VideoPlayer-iOS/VideoPlayerViewController.swift +++ b/Sources/Playback/Player/VideoPlayer-iOS/VideoPlayerViewController.swift @@ -869,7 +869,7 @@ class VideoPlayerViewController: PlayerViewController { tapSwipeEqual = VLCDefaults.shared.playbackTapSwipeEqual forwardBackwardEqual = VLCDefaults.shared.playbackForwardBackwardEqual - seekForwardBy = defaults.integer(forKey: kVLCSettingPlaybackForwardSkipLength) + seekForwardBy = VLCDefaults.shared.playbackForwardSkipLength seekBackwardBy = forwardBackwardEqual ? seekForwardBy : defaults.integer(forKey: kVLCSettingPlaybackBackwardSkipLength) seekForwardBySwipe = tapSwipeEqual ? seekForwardBy : VLCDefaults.shared.playbackForwardSkipLengthSwipe diff --git a/Sources/Settings/Model/SettingsSection.swift b/Sources/Settings/Model/SettingsSection.swift index 63c1869c2..53bc36a29 100644 --- a/Sources/Settings/Model/SettingsSection.swift +++ b/Sources/Settings/Model/SettingsSection.swift @@ -389,7 +389,7 @@ enum GestureControlOptions { } static var forwardSkipLength: SettingsItem { - let k = kVLCSettingPlaybackForwardSkipLength + let k = VLCDefaults.Compat.playbackForwardSkipLengthKey return .init(title: dynamicForwardSkipDescription(), subtitle: Localizer.getSubtitle(for: k), action: .showActionSheet(title: dynamicForwardSkipDescription(), preferenceKey: k, hasInfo: false)) -- GitLab From 165169161c722c2d9c97dd8c477b0bde01d30b8d Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Tue, 25 Feb 2025 19:36:40 -0500 Subject: [PATCH 51/97] Convert kVLCSettingPlaybackBackwardSkipLength --- Sources/App/iOS/VLCAppDelegate.m | 1 - Sources/App/tvOS/AppleTVAppDelegate.m | 3 --- Sources/Headers/VLCConstants.h | 2 -- Sources/Headers/VLCTVConstants.h | 4 ---- Sources/Helpers/VLCDefaults.swift | 13 +++++++++++++ Sources/Playback/Control/VLCPlaybackService.m | 2 +- .../Playback/Control/VLCPlayerDisplayController.m | 2 +- .../OS Integration/VLCRemoteControlService.m | 2 +- Sources/Playback/Player/PlayerViewController.swift | 2 +- .../VideoPlayer-iOS/MediaScrubProgressBar.swift | 2 +- .../VideoPlayer-iOS/VideoPlayerViewController.swift | 2 +- Sources/Settings/Model/SettingsSection.swift | 2 +- 12 files changed, 20 insertions(+), 17 deletions(-) diff --git a/Sources/App/iOS/VLCAppDelegate.m b/Sources/App/iOS/VLCAppDelegate.m index 6afbebac5..f9e72cbb8 100644 --- a/Sources/App/iOS/VLCAppDelegate.m +++ b/Sources/App/iOS/VLCAppDelegate.m @@ -50,7 +50,6 @@ kVLCSettingSubtitlesFontSize : kVLCSettingSubtitlesFontSizeDefaultValue, kVLCSettingSubtitlesBoldFont: kVLCSettingSubtitlesBoldFontDefaultValue, kVLCSettingWiFiSharingIPv6 : kVLCSettingWiFiSharingIPv6DefaultValue, - kVLCSettingPlaybackBackwardSkipLength : kVLCSettingPlaybackBackwardSkipLengthDefaultValue, kVLCSettingCastingConversionQuality : @(2), }; [defaults registerDefaults:appDefaults]; diff --git a/Sources/App/tvOS/AppleTVAppDelegate.m b/Sources/App/tvOS/AppleTVAppDelegate.m index f57a3ad76..1bc34ce9e 100644 --- a/Sources/App/tvOS/AppleTVAppDelegate.m +++ b/Sources/App/tvOS/AppleTVAppDelegate.m @@ -45,9 +45,6 @@ kVLCSettingSubtitlesFontColor : kVLCSettingSubtitlesFontColorDefaultValue, kVLCSettingSubtitlesFontSize : kVLCSettingSubtitlesFontSizeDefaultValue, kVLCSettingSubtitlesBoldFont: kVLCSettingSubtitlesBoldFontDefaultValue, - kVLCSettingPlaybackBackwardSkipLength : kVLCSettingPlaybackBackwardSkipLengthDefaultValue, - kVLCSettingPlaybackLockscreenSkip : @(NO), - kVLCSettingPlaybackRemoteControlSkip : @(NO), kVLCSettingWiFiSharingIPv6 : kVLCSettingWiFiSharingIPv6DefaultValue, kVLCPlayerUIShouldHide : @(NO), }; diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index 27e4187e4..f13aef895 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -40,8 +40,6 @@ #define kVLCSettingsDecrapifyTitles @"MLDecrapifyTitles" #define kVLCSettingWiFiSharingIPv6 @"wifi-sharing-ipv6" #define kVLCSettingWiFiSharingIPv6DefaultValue @(NO) -#define kVLCSettingPlaybackBackwardSkipLength @"playback-backward-skip-length" -#define kVLCSettingPlaybackBackwardSkipLengthDefaultValue @(10) #define kVLCSettingsDisableGrouping @"MLDisableGrouping" #define kVLCkVLCSettingsDisableGroupingDefaultValue @NO #define kVLCSettingCastingConversionQuality @"sout-chromecast-conversion-quality" diff --git a/Sources/Headers/VLCTVConstants.h b/Sources/Headers/VLCTVConstants.h index fc1f243b8..7cdf2d558 100644 --- a/Sources/Headers/VLCTVConstants.h +++ b/Sources/Headers/VLCTVConstants.h @@ -46,10 +46,6 @@ #define kVLCSettingSubtitlesFontColorDefaultValue @"16777215" #define kVLCSubtitlesCacheFolderName @"cached-subtitles" #define kVLCSettingSubtitlesFilePath @"sub-file" -#define kVLCSettingPlaybackBackwardSkipLength @"playback-backward-skip-length" -#define kVLCSettingPlaybackBackwardSkipLengthDefaultValue @(10) -#define kVLCSettingPlaybackLockscreenSkip @"playback-lockscreen-skip" -#define kVLCSettingPlaybackRemoteControlSkip @"playback-remote-control-skip" #define kVLCSettingSaveHTTPUploadServerStatus @"isHTTPServerOn" #define kVLCPlayerUIShouldHide @"PlayerUIShouldHide" #define kVLCSettingUseSPDIF @"kVLCSettingUseSPDIF" diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index 2c4cf818e..ce8d1dcb5 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -59,6 +59,7 @@ Keys.defaultPreampLevel: Float(6), Keys.deinterlace: DefaultValues.deinterlace, Keys.equalizerProfile: DefaultValues.equalizerProfile, + Keys.playbackBackwardSkipLength: DefaultValues.playbackBackwardSkipLength, Keys.playbackBackwardSkipLengthSwipe: DefaultValues.playbackBackwardSkipLengthSwipe, Keys.playbackForwardSkipLength: DefaultValues.playbackForwardSkipLength, Keys.playbackForwardSkipLengthSwipe: DefaultValues.playbackForwardSkipLengthSwipe, @@ -438,6 +439,15 @@ extension VLCDefaults { } } + @objc var playbackBackwardSkipLength: Int { + get { + userDefaults.integer(forKey: Keys.playbackBackwardSkipLength) + } + set { + userDefaults.set(newValue, forKey: Keys.playbackBackwardSkipLength) + } + } + @objc var playbackBackwardSkipLengthSwipe: Int { get { userDefaults.integer(forKey: Keys.playbackBackwardSkipLengthSwipe) @@ -577,6 +587,7 @@ extension VLCDefaults { static let hardwareDecodingKey: String = Keys.hardwareDecoding static let hideLibraryInFilesAppKey: String = Keys.hideLibraryInFilesApp static let networkCachingKey: String = Keys.networkCaching + static let playbackBackwardSkipLengthKey: String = Keys.playbackBackwardSkipLength static let playbackBackwardSkipLengthSwipeKey: String = Keys.playbackBackwardSkipLengthSwipe static let playbackForwardSkipLengthKey: String = Keys.playbackForwardSkipLength static let playbackForwardSkipLengthSwipeKey: String = Keys.playbackForwardSkipLengthSwipe @@ -639,6 +650,7 @@ fileprivate enum Keys { static let passcodeEnableBiometricAuth = "EnableBiometricAuth" static let pauseWhenShowingControls = "kVLCSettingPauseWhenShowingControls" static let playbackForwardBackwardEqual = "playback-forward-backward-equal" + static let playbackBackwardSkipLength = "playback-backward-skip-length" static let playbackForwardSkipLength = "playback-forward-skip-length" static let playbackBackwardSkipLengthSwipe = "playback-backward-skip-length-swipe" static let playbackForwardSkipLengthSwipe = "playback-forward-skip-length-swipe" @@ -678,6 +690,7 @@ fileprivate enum DefaultValues { static let equalizerProfile = Int(0) static let textEncoding = "Windows-1252" static let networkSatIPChannelListUrl = "" + static let playbackBackwardSkipLength = 10 static let playbackBackwardSkipLengthSwipe = 10 static let playbackForwardSkipLength = 10 static let playbackForwardSkipLengthSwipe = 10 diff --git a/Sources/Playback/Control/VLCPlaybackService.m b/Sources/Playback/Control/VLCPlaybackService.m index a7a4ca1ab..83900f5a8 100644 --- a/Sources/Playback/Control/VLCPlaybackService.m +++ b/Sources/Playback/Control/VLCPlaybackService.m @@ -1133,7 +1133,7 @@ NSString *const VLCLastPlaylistPlayedMedia = @"LastPlaylistPlayedMedia"; [_listPlayer playItemAtNumber:@(_currentIndex)]; } } else { - NSNumber *skipLength = [[NSUserDefaults standardUserDefaults] valueForKey:kVLCSettingPlaybackBackwardSkipLength]; + NSNumber *skipLength = [NSNumber numberWithInteger:VLCDefaults.shared.playbackBackwardSkipLength]; [_mediaPlayer jumpBackward:skipLength.intValue]; } return YES; diff --git a/Sources/Playback/Control/VLCPlayerDisplayController.m b/Sources/Playback/Control/VLCPlayerDisplayController.m index 037cc0ff7..689c2f4cb 100644 --- a/Sources/Playback/Control/VLCPlayerDisplayController.m +++ b/Sources/Playback/Control/VLCPlayerDisplayController.m @@ -673,7 +673,7 @@ NSString *const VLCPlayerDisplayControllerHideMiniPlayer = @"VLCPlayerDisplayCon - (void)keyLeftArrow { - NSInteger seekBy = [[NSUserDefaults standardUserDefaults] integerForKey:kVLCSettingPlaybackBackwardSkipLength]; + NSInteger seekBy = VLCDefaults.shared.playbackBackwardSkipLength; [_playbackController jumpBackward:(int)seekBy]; } diff --git a/Sources/Playback/OS Integration/VLCRemoteControlService.m b/Sources/Playback/OS Integration/VLCRemoteControlService.m index 2eba79e35..43bc9cd96 100644 --- a/Sources/Playback/OS Integration/VLCRemoteControlService.m +++ b/Sources/Playback/OS Integration/VLCRemoteControlService.m @@ -81,7 +81,7 @@ static inline NSArray * RemoteCommandCenterCommandsToHandle(void) NSNumber *forwardSkip = [NSNumber numberWithInteger:VLCDefaults.shared.playbackForwardSkipLength]; commandCenter.skipForwardCommand.preferredIntervals = @[forwardSkip]; - NSNumber *backwardSkip = [defaults valueForKey:kVLCSettingPlaybackBackwardSkipLength]; + NSNumber *backwardSkip = [NSNumber numberWithInteger:VLCDefaults.shared.playbackBackwardSkipLength]; commandCenter.skipBackwardCommand.preferredIntervals = @[backwardSkip]; commandCenter.changePlaybackRateCommand.supportedPlaybackRates = @[@(0.5),@(0.75),@(1.0),@(1.25),@(1.5),@(1.75),@(2.0)]; diff --git a/Sources/Playback/Player/PlayerViewController.swift b/Sources/Playback/Player/PlayerViewController.swift index e13dcea16..7be4475ec 100644 --- a/Sources/Playback/Player/PlayerViewController.swift +++ b/Sources/Playback/Player/PlayerViewController.swift @@ -741,7 +741,7 @@ class PlayerViewController: UIViewController { tapSwipeEqual = VLCDefaults.shared.playbackTapSwipeEqual forwardBackwardEqual = VLCDefaults.shared.playbackForwardBackwardEqual seekForwardBy = VLCDefaults.shared.playbackForwardSkipLength - seekBackwardBy = forwardBackwardEqual ? seekForwardBy : defaults.integer(forKey: kVLCSettingPlaybackBackwardSkipLength) + seekBackwardBy = forwardBackwardEqual ? seekForwardBy : VLCDefaults.shared.playbackBackwardSkipLength seekForwardBySwipe = tapSwipeEqual ? seekForwardBy : VLCDefaults.shared.playbackForwardSkipLengthSwipe if tapSwipeEqual, forwardBackwardEqual { diff --git a/Sources/Playback/Player/VideoPlayer-iOS/MediaScrubProgressBar.swift b/Sources/Playback/Player/VideoPlayer-iOS/MediaScrubProgressBar.swift index ac7747173..2746a44c6 100644 --- a/Sources/Playback/Player/VideoPlayer-iOS/MediaScrubProgressBar.swift +++ b/Sources/Playback/Player/VideoPlayer-iOS/MediaScrubProgressBar.swift @@ -150,7 +150,7 @@ class MediaScrubProgressBar: UIStackView { @objc private func handleAccessibilityBackward() -> Bool { let defaults = UserDefaults.standard - playbackService.jumpBackward(Int32(defaults.integer(forKey: kVLCSettingPlaybackBackwardSkipLength))) + playbackService.jumpBackward(Int32(VLCDefaults.shared.playbackBackwardSkipLength)) return true } diff --git a/Sources/Playback/Player/VideoPlayer-iOS/VideoPlayerViewController.swift b/Sources/Playback/Player/VideoPlayer-iOS/VideoPlayerViewController.swift index 840b4f18d..6556eda4b 100644 --- a/Sources/Playback/Player/VideoPlayer-iOS/VideoPlayerViewController.swift +++ b/Sources/Playback/Player/VideoPlayer-iOS/VideoPlayerViewController.swift @@ -870,7 +870,7 @@ class VideoPlayerViewController: PlayerViewController { tapSwipeEqual = VLCDefaults.shared.playbackTapSwipeEqual forwardBackwardEqual = VLCDefaults.shared.playbackForwardBackwardEqual seekForwardBy = VLCDefaults.shared.playbackForwardSkipLength - seekBackwardBy = forwardBackwardEqual ? seekForwardBy : defaults.integer(forKey: kVLCSettingPlaybackBackwardSkipLength) + seekBackwardBy = forwardBackwardEqual ? seekForwardBy : VLCDefaults.shared.playbackBackwardSkipLength seekForwardBySwipe = tapSwipeEqual ? seekForwardBy : VLCDefaults.shared.playbackForwardSkipLengthSwipe if tapSwipeEqual, forwardBackwardEqual { diff --git a/Sources/Settings/Model/SettingsSection.swift b/Sources/Settings/Model/SettingsSection.swift index 53bc36a29..c075c348f 100644 --- a/Sources/Settings/Model/SettingsSection.swift +++ b/Sources/Settings/Model/SettingsSection.swift @@ -396,7 +396,7 @@ enum GestureControlOptions { } static var backwardSkipLength: SettingsItem { - let k = kVLCSettingPlaybackBackwardSkipLength + let k = VLCDefaults.Compat.playbackBackwardSkipLengthKey return .init(title: dynamicBackwardSkipDescription(), subtitle: Localizer.getSubtitle(for: k), action: .showActionSheet(title: dynamicBackwardSkipDescription(), preferenceKey: k, hasInfo: false)) -- GitLab From 2a560be0fa8180731abbfac63ba2155096e471e0 Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Tue, 25 Feb 2025 19:43:47 -0500 Subject: [PATCH 52/97] Convert kVLCSettingCastingConversionQuality --- Sources/App/iOS/VLCAppDelegate.m | 1 - Sources/Headers/VLCConstants.h | 1 - Sources/Headers/VLCTVConstants.h | 2 -- Sources/Helpers/VLCDefaults.swift | 13 +++++++++++++ Sources/Playback/Control/VLCPlaybackService.m | 4 ++-- Sources/Settings/Model/SettingsSection.swift | 2 +- 6 files changed, 16 insertions(+), 7 deletions(-) diff --git a/Sources/App/iOS/VLCAppDelegate.m b/Sources/App/iOS/VLCAppDelegate.m index f9e72cbb8..a469a1093 100644 --- a/Sources/App/iOS/VLCAppDelegate.m +++ b/Sources/App/iOS/VLCAppDelegate.m @@ -50,7 +50,6 @@ kVLCSettingSubtitlesFontSize : kVLCSettingSubtitlesFontSizeDefaultValue, kVLCSettingSubtitlesBoldFont: kVLCSettingSubtitlesBoldFontDefaultValue, kVLCSettingWiFiSharingIPv6 : kVLCSettingWiFiSharingIPv6DefaultValue, - kVLCSettingCastingConversionQuality : @(2), }; [defaults registerDefaults:appDefaults]; } diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index f13aef895..b2fb79053 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -42,7 +42,6 @@ #define kVLCSettingWiFiSharingIPv6DefaultValue @(NO) #define kVLCSettingsDisableGrouping @"MLDisableGrouping" #define kVLCkVLCSettingsDisableGroupingDefaultValue @NO -#define kVLCSettingCastingConversionQuality @"sout-chromecast-conversion-quality" #define kVLCSettingLastUsedSubtitlesSearchLanguage @"kVLCSettingLastUsedSubtitlesSearchLanguage" #define kVLCSettingDisableSubtitles @"kVLCSettingDisableSubtitles" diff --git a/Sources/Headers/VLCTVConstants.h b/Sources/Headers/VLCTVConstants.h index 7cdf2d558..167ce4628 100644 --- a/Sources/Headers/VLCTVConstants.h +++ b/Sources/Headers/VLCTVConstants.h @@ -65,6 +65,4 @@ #define kVLCHTTPUploadDirectory @"Upload" -#define kVLCSettingCastingConversionQuality @"sout-chromecast-conversion-quality" - #define kVLCSettingReset @"kVLCSettingReset" diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index ce8d1dcb5..1a899858e 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -54,6 +54,7 @@ Keys.volumeGesture: true, // numbers + Keys.castingConversionQuality: DefaultValues.castingConversionQuality, Keys.continueAudioPlayback: 1, Keys.continuePlayback: 1, Keys.defaultPreampLevel: Float(6), @@ -394,6 +395,15 @@ extension VLCDefaults { // Numbers + @objc var castingConversionQuality: Int { + get { + userDefaults.integer(forKey: Keys.castingConversionQuality) + } + set { + userDefaults.set(newValue, forKey: Keys.castingConversionQuality) + } + } + @objc var continueAudioPlayback: Int { get { userDefaults.integer(forKey: Keys.continueAudioPlayback) @@ -580,6 +590,7 @@ extension VLCDefaults { final class Compat: NSObject { static let automaticallyPlayNextItemKey: String = Keys.automaticallyPlayNextItem static let backupMediaLibraryKey: String = Keys.backupMediaLibrary + static let castingConversionQualityKey: String = Keys.castingConversionQuality static let continueAudioPlaybackKey: String = Keys.continueAudioPlayback static let continuePlaybackKey: String = Keys.continuePlayback static let defaultPreampLevelKey: String = Keys.defaultPreampLevel @@ -631,6 +642,7 @@ fileprivate enum Keys { static let backupMediaLibrary = "BackupMediaLibrary" static let brightnessGesture = "EnableBrightnessGesture" static let castingAudioPassthrough = "sout-chromecast-audio-passthrough" + static let castingConversionQuality = "sout-chromecast-conversion-quality" static let closeGesture = "EnableCloseGesture" static let continueAudioInBackground = "BackgroundAudioPlayback" static let continueAudioPlayback = "ContinueAudioPlayback" @@ -686,6 +698,7 @@ fileprivate enum Keys { // MARK: - Default Values fileprivate enum DefaultValues { + static let castingConversionQuality = 2 static let deinterlace = Int(-1) static let equalizerProfile = Int(0) static let textEncoding = "Windows-1252" diff --git a/Sources/Playback/Control/VLCPlaybackService.m b/Sources/Playback/Control/VLCPlaybackService.m index 83900f5a8..e6bc11ba6 100644 --- a/Sources/Playback/Control/VLCPlaybackService.m +++ b/Sources/Playback/Control/VLCPlaybackService.m @@ -250,12 +250,12 @@ NSString *const VLCLastPlaylistPlayedMedia = @"LastPlaylistPlayedMedia"; NSMutableArray *libVLCOptions = [NSMutableArray array]; #if TARGET_OS_IOS BOOL chromecastPassthrough = VLCDefaults.shared.castingAudioPassthrough; - int chromecastQuality = [[userDefaults objectForKey:kVLCSettingCastingConversionQuality] intValue]; + int chromecastQuality = (int)VLCDefaults.shared.castingConversionQuality; if (chromecastPassthrough) { [libVLCOptions addObject:@"--sout-chromecast-audio-passthrough"]; } if (chromecastQuality != 2) { - [libVLCOptions addObject:[NSString stringWithFormat:@"--%@=%i", kVLCSettingCastingConversionQuality, chromecastQuality]]; + [libVLCOptions addObject:[NSString stringWithFormat:@"--sout-chromecast-conversion-quality=%i", chromecastQuality]]; } #endif if (!audioTimeStretch) { diff --git a/Sources/Settings/Model/SettingsSection.swift b/Sources/Settings/Model/SettingsSection.swift index c075c348f..8670a1f2d 100644 --- a/Sources/Settings/Model/SettingsSection.swift +++ b/Sources/Settings/Model/SettingsSection.swift @@ -603,7 +603,7 @@ enum CastingOptions { } static var conversionQuality: SettingsItem { - let k = kVLCSettingCastingConversionQuality + let k = VLCDefaults.Compat.castingConversionQualityKey return .init(title: "SETTINGS_CASTING_CONVERSION_QUALITY", subtitle: Localizer.getSubtitle(for: k), action: .showActionSheet(title: "SETTINGS_CASTING_CONVERSION_QUALITY", preferenceKey: k, hasInfo: false)) -- GitLab From b9e590a8dc544587dd1fab4ee332ab6221923e6d Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Tue, 25 Feb 2025 19:51:50 -0500 Subject: [PATCH 53/97] Convert kVLCSettingWiFiSharingIPv6 --- Sources/App/iOS/VLCAppDelegate.m | 1 - Sources/App/tvOS/AppleTVAppDelegate.m | 1 - Sources/Headers/VLCConstants.h | 2 -- Sources/Headers/VLCTVConstants.h | 2 -- Sources/Helpers/VLCDefaults.swift | 11 +++++++++++ Sources/Settings/Model/SettingsSection.swift | 2 +- Sources/WiFi Sharing/VLCHTTPUploaderController.m | 5 +++-- 7 files changed, 15 insertions(+), 9 deletions(-) diff --git a/Sources/App/iOS/VLCAppDelegate.m b/Sources/App/iOS/VLCAppDelegate.m index a469a1093..e17f5e7ad 100644 --- a/Sources/App/iOS/VLCAppDelegate.m +++ b/Sources/App/iOS/VLCAppDelegate.m @@ -49,7 +49,6 @@ kVLCSettingSubtitlesFontColor : kVLCSettingSubtitlesFontColorDefaultValue, kVLCSettingSubtitlesFontSize : kVLCSettingSubtitlesFontSizeDefaultValue, kVLCSettingSubtitlesBoldFont: kVLCSettingSubtitlesBoldFontDefaultValue, - kVLCSettingWiFiSharingIPv6 : kVLCSettingWiFiSharingIPv6DefaultValue, }; [defaults registerDefaults:appDefaults]; } diff --git a/Sources/App/tvOS/AppleTVAppDelegate.m b/Sources/App/tvOS/AppleTVAppDelegate.m index 1bc34ce9e..ae7f5664e 100644 --- a/Sources/App/tvOS/AppleTVAppDelegate.m +++ b/Sources/App/tvOS/AppleTVAppDelegate.m @@ -45,7 +45,6 @@ kVLCSettingSubtitlesFontColor : kVLCSettingSubtitlesFontColorDefaultValue, kVLCSettingSubtitlesFontSize : kVLCSettingSubtitlesFontSizeDefaultValue, kVLCSettingSubtitlesBoldFont: kVLCSettingSubtitlesBoldFontDefaultValue, - kVLCSettingWiFiSharingIPv6 : kVLCSettingWiFiSharingIPv6DefaultValue, kVLCPlayerUIShouldHide : @(NO), }; [defaults registerDefaults:appDefaults]; diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index b2fb79053..a3a548a6d 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -38,8 +38,6 @@ #define kVLCSettingNetworkSatIPChannelList @"satip-channelist" #define kVLCSettingNetworkSatIPChannelListCustom @"CustomList" #define kVLCSettingsDecrapifyTitles @"MLDecrapifyTitles" -#define kVLCSettingWiFiSharingIPv6 @"wifi-sharing-ipv6" -#define kVLCSettingWiFiSharingIPv6DefaultValue @(NO) #define kVLCSettingsDisableGrouping @"MLDisableGrouping" #define kVLCkVLCSettingsDisableGroupingDefaultValue @NO #define kVLCSettingLastUsedSubtitlesSearchLanguage @"kVLCSettingLastUsedSubtitlesSearchLanguage" diff --git a/Sources/Headers/VLCTVConstants.h b/Sources/Headers/VLCTVConstants.h index 167ce4628..f7ccddec8 100644 --- a/Sources/Headers/VLCTVConstants.h +++ b/Sources/Headers/VLCTVConstants.h @@ -56,8 +56,6 @@ #define kVLCPlayerOpenInMiniPlayer @"OpenInMiniPlayer" #define kVLCSettingLastUsedSubtitlesSearchLanguage @"kVLCSettingLastUsedSubtitlesSearchLanguage" -#define kVLCSettingWiFiSharingIPv6 @"wifi-sharing-ipv6" -#define kVLCSettingWiFiSharingIPv6DefaultValue @(NO) #define kVLCfortvOSMovieDBKey @"" diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index 1a899858e..a7e40b634 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -52,6 +52,7 @@ Keys.stretchAudio: true, Keys.videoFullscreenPlayback: true, Keys.volumeGesture: true, + Keys.wifiSharingIPv6: false, // numbers Keys.castingConversionQuality: DefaultValues.castingConversionQuality, @@ -393,6 +394,15 @@ extension VLCDefaults { } } + @objc var wifiSharingIPv6: Bool { + get { + userDefaults.bool(forKey: Keys.wifiSharingIPv6) + } + set { + userDefaults.set(newValue, forKey: Keys.wifiSharingIPv6) + } + } + // Numbers @objc var castingConversionQuality: Int { @@ -687,6 +697,7 @@ fileprivate enum Keys { static let textEncoding = "subsdec-encoding" static let videoFullscreenPlayback = "AlwaysUseFullscreenForVideo" static let volumeGesture = "EnableVolumeGesture" + static let wifiSharingIPv6 = "wifi-sharing-ipv6" static func videoLibraryGridLayout(collectionModelName: String? = nil, name: String) -> String { [ diff --git a/Sources/Settings/Model/SettingsSection.swift b/Sources/Settings/Model/SettingsSection.swift index 8670a1f2d..106e92884 100644 --- a/Sources/Settings/Model/SettingsSection.swift +++ b/Sources/Settings/Model/SettingsSection.swift @@ -724,7 +724,7 @@ enum NetworkOptions { static var ipv6SupportForWiFiSharing: SettingsItem { .toggle(title: "SETTINGS_WIFISHARING_IPv6", subtitle: nil, - preferenceKey: kVLCSettingWiFiSharingIPv6) + keyPath: \.wifiSharingIPv6) } static var forceSMBv1: SettingsItem { diff --git a/Sources/WiFi Sharing/VLCHTTPUploaderController.m b/Sources/WiFi Sharing/VLCHTTPUploaderController.m index 866c7f3fc..1a168c4cf 100644 --- a/Sources/WiFi Sharing/VLCHTTPUploaderController.m +++ b/Sources/WiFi Sharing/VLCHTTPUploaderController.m @@ -27,8 +27,9 @@ #import "NSString+SupportedMedia.h" -#if TARGET_OS_IOS || TARGET_OS_VISION #import "VLC-Swift.h" + +#if TARGET_OS_IOS || TARGET_OS_VISION #import "VLCMediaFileDiscoverer.h" #endif @@ -256,7 +257,7 @@ NSString *VLCHTTPUploaderBackgroundTaskName = @"VLCHTTPUploaderBackgroundTaskNam [_httpServer setInterface:_nameOfUsedNetworkInterface]; [_httpServer setIPv4Enabled:YES]; - [_httpServer setIPv6Enabled:[[[NSUserDefaults standardUserDefaults] objectForKey:kVLCSettingWiFiSharingIPv6] boolValue]]; + [_httpServer setIPv6Enabled:VLCDefaults.shared.wifiSharingIPv6]; // Tell the server to broadcast its presence via Bonjour. // This allows browsers such as Safari to automatically discover our service. -- GitLab From c1316c96b1c5b1c172d96ad000b3ba7486be5776 Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Tue, 25 Feb 2025 19:57:02 -0500 Subject: [PATCH 54/97] Convert kVLCSettingSubtitlesBoldFont --- Sources/App/iOS/VLCAppDelegate.m | 1 - Sources/App/tvOS/AppleTVAppDelegate.m | 1 - Sources/Headers/VLCConstants.h | 2 -- Sources/Headers/VLCTVConstants.h | 2 -- Sources/Helpers/VLCDefaults.swift | 11 +++++++++++ Sources/Playback/Control/VLCPlaybackService.m | 2 +- Sources/Settings/Model/SettingsSection.swift | 2 +- 7 files changed, 13 insertions(+), 8 deletions(-) diff --git a/Sources/App/iOS/VLCAppDelegate.m b/Sources/App/iOS/VLCAppDelegate.m index e17f5e7ad..9ea315494 100644 --- a/Sources/App/iOS/VLCAppDelegate.m +++ b/Sources/App/iOS/VLCAppDelegate.m @@ -48,7 +48,6 @@ kVLCSettingSubtitlesFont : kVLCSettingSubtitlesFontDefaultValue, kVLCSettingSubtitlesFontColor : kVLCSettingSubtitlesFontColorDefaultValue, kVLCSettingSubtitlesFontSize : kVLCSettingSubtitlesFontSizeDefaultValue, - kVLCSettingSubtitlesBoldFont: kVLCSettingSubtitlesBoldFontDefaultValue, }; [defaults registerDefaults:appDefaults]; } diff --git a/Sources/App/tvOS/AppleTVAppDelegate.m b/Sources/App/tvOS/AppleTVAppDelegate.m index ae7f5664e..fece906bc 100644 --- a/Sources/App/tvOS/AppleTVAppDelegate.m +++ b/Sources/App/tvOS/AppleTVAppDelegate.m @@ -44,7 +44,6 @@ kVLCSettingSubtitlesFont : kVLCSettingSubtitlesFontDefaultValue, kVLCSettingSubtitlesFontColor : kVLCSettingSubtitlesFontColorDefaultValue, kVLCSettingSubtitlesFontSize : kVLCSettingSubtitlesFontSizeDefaultValue, - kVLCSettingSubtitlesBoldFont: kVLCSettingSubtitlesBoldFontDefaultValue, kVLCPlayerUIShouldHide : @(NO), }; [defaults registerDefaults:appDefaults]; diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index a3a548a6d..798d224c6 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -27,8 +27,6 @@ #define kVLCSettingSubtitlesFontDefaultValue @"HelveticaNeue" #define kVLCSettingSubtitlesFontSize @"quartztext-rel-fontsize" #define kVLCSettingSubtitlesFontSizeDefaultValue @"16" -#define kVLCSettingSubtitlesBoldFont @"quartztext-bold" -#define kVLCSettingSubtitlesBoldFontDefaultValue @NO #define kVLCSettingSubtitlesFontColor @"quartztext-color" #define kVLCSettingSubtitlesFontColorDefaultValue @"16777215" #define kVLCSettingSubtitlesFilePath @"sub-file" diff --git a/Sources/Headers/VLCTVConstants.h b/Sources/Headers/VLCTVConstants.h index f7ccddec8..65c6f46b4 100644 --- a/Sources/Headers/VLCTVConstants.h +++ b/Sources/Headers/VLCTVConstants.h @@ -40,8 +40,6 @@ #define kVLCSettingSubtitlesFontDefaultValue @"HelveticaNeue" #define kVLCSettingSubtitlesFontSize @"quartztext-rel-fontsize" #define kVLCSettingSubtitlesFontSizeDefaultValue @"16" -#define kVLCSettingSubtitlesBoldFont @"quartztext-bold" -#define kVLCSettingSubtitlesBoldFontDefaultValue @NO #define kVLCSettingSubtitlesFontColor @"quartztext-color" #define kVLCSettingSubtitlesFontColorDefaultValue @"16777215" #define kVLCSubtitlesCacheFolderName @"cached-subtitles" diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index a7e40b634..85c65aa05 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -50,6 +50,7 @@ Keys.showRemainingTime: false, Keys.showThumbnails: true, Keys.stretchAudio: true, + Keys.subtitlesBoldFont: false, Keys.videoFullscreenPlayback: true, Keys.volumeGesture: true, Keys.wifiSharingIPv6: false, @@ -376,6 +377,15 @@ extension VLCDefaults { } } + @objc var subtitlesBoldFont: Bool { + get { + userDefaults.bool(forKey: Keys.subtitlesBoldFont) + } + set { + userDefaults.set(newValue, forKey: Keys.subtitlesBoldFont) + } + } + @objc var videoFullscreenPlayback: Bool { get { userDefaults.bool(forKey: Keys.videoFullscreenPlayback) @@ -693,6 +703,7 @@ fileprivate enum Keys { static let showRemainingTime = "show-remaining-time" static let showThumbnails = "ShowThumbnails" static let stretchAudio = "audio-time-stretch" + static let subtitlesBoldFont = "quartztext-bold" static let tabBarIndex = "TabBarIndex" static let textEncoding = "subsdec-encoding" static let videoFullscreenPlayback = "AlwaysUseFullscreenForVideo" diff --git a/Sources/Playback/Control/VLCPlaybackService.m b/Sources/Playback/Control/VLCPlaybackService.m index e6bc11ba6..46cec48e2 100644 --- a/Sources/Playback/Control/VLCPlaybackService.m +++ b/Sources/Playback/Control/VLCPlaybackService.m @@ -865,7 +865,7 @@ NSString *const VLCLastPlaylistPlayedMedia = @"LastPlaylistPlayedMedia"; [_mediaPlayer performSelector:@selector(setTextRendererFont:) withObject:[defaults objectForKey:kVLCSettingSubtitlesFont]]; [_mediaPlayer performSelector:@selector(setTextRendererFontSize:) withObject:[defaults objectForKey:kVLCSettingSubtitlesFontSize]]; [_mediaPlayer performSelector:@selector(setTextRendererFontColor:) withObject:[defaults objectForKey:kVLCSettingSubtitlesFontColor]]; - [_mediaPlayer performSelector:@selector(setTextRendererFontForceBold:) withObject:[defaults objectForKey:kVLCSettingSubtitlesBoldFont]]; + [_mediaPlayer performSelector:@selector(setTextRendererFontForceBold:) withObject:[NSNumber numberWithBool:VLCDefaults.shared.subtitlesBoldFont]]; #pragma clang diagnostic pop } break; diff --git a/Sources/Settings/Model/SettingsSection.swift b/Sources/Settings/Model/SettingsSection.swift index 106e92884..d1d06b38a 100644 --- a/Sources/Settings/Model/SettingsSection.swift +++ b/Sources/Settings/Model/SettingsSection.swift @@ -564,7 +564,7 @@ enum SubtitlesOptions { static var useBoldFont: SettingsItem { .toggle(title: "SETTINGS_SUBTITLES_BOLDFONT", subtitle: nil, - preferenceKey: kVLCSettingSubtitlesBoldFont) + keyPath: \.subtitlesBoldFont) } static var fontColor: SettingsItem { -- GitLab From 2c9dd3242ff756889fcd0c3896d1f298df4fbf4b Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Tue, 25 Feb 2025 20:03:24 -0500 Subject: [PATCH 55/97] Convert kVLCSettingSubtitlesFontSize --- Sources/App/iOS/VLCAppDelegate.m | 1 - Sources/App/tvOS/AppleTVAppDelegate.m | 1 - Sources/Headers/VLCConstants.h | 2 -- Sources/Headers/VLCTVConstants.h | 2 -- Sources/Helpers/VLCDefaults.swift | 13 +++++++++++++ Sources/Playback/Control/VLCPlaybackService.m | 2 +- Sources/Settings/Model/SettingsSection.swift | 2 +- 7 files changed, 15 insertions(+), 8 deletions(-) diff --git a/Sources/App/iOS/VLCAppDelegate.m b/Sources/App/iOS/VLCAppDelegate.m index 9ea315494..64fe3ce24 100644 --- a/Sources/App/iOS/VLCAppDelegate.m +++ b/Sources/App/iOS/VLCAppDelegate.m @@ -47,7 +47,6 @@ kVLCSettingSkipLoopFilter : kVLCSettingSkipLoopFilterNonRef, kVLCSettingSubtitlesFont : kVLCSettingSubtitlesFontDefaultValue, kVLCSettingSubtitlesFontColor : kVLCSettingSubtitlesFontColorDefaultValue, - kVLCSettingSubtitlesFontSize : kVLCSettingSubtitlesFontSizeDefaultValue, }; [defaults registerDefaults:appDefaults]; } diff --git a/Sources/App/tvOS/AppleTVAppDelegate.m b/Sources/App/tvOS/AppleTVAppDelegate.m index fece906bc..c85b3e3ed 100644 --- a/Sources/App/tvOS/AppleTVAppDelegate.m +++ b/Sources/App/tvOS/AppleTVAppDelegate.m @@ -43,7 +43,6 @@ NSDictionary *appDefaults = @{kVLCSettingSkipLoopFilter : kVLCSettingSkipLoopFilterNonRef, kVLCSettingSubtitlesFont : kVLCSettingSubtitlesFontDefaultValue, kVLCSettingSubtitlesFontColor : kVLCSettingSubtitlesFontColorDefaultValue, - kVLCSettingSubtitlesFontSize : kVLCSettingSubtitlesFontSizeDefaultValue, kVLCPlayerUIShouldHide : @(NO), }; [defaults registerDefaults:appDefaults]; diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index 798d224c6..e2a5e8616 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -25,8 +25,6 @@ #define kVLCSettingSaveHTTPUploadServerStatus @"isHTTPServerOn" #define kVLCSettingSubtitlesFont @"quartztext-font" #define kVLCSettingSubtitlesFontDefaultValue @"HelveticaNeue" -#define kVLCSettingSubtitlesFontSize @"quartztext-rel-fontsize" -#define kVLCSettingSubtitlesFontSizeDefaultValue @"16" #define kVLCSettingSubtitlesFontColor @"quartztext-color" #define kVLCSettingSubtitlesFontColorDefaultValue @"16777215" #define kVLCSettingSubtitlesFilePath @"sub-file" diff --git a/Sources/Headers/VLCTVConstants.h b/Sources/Headers/VLCTVConstants.h index 65c6f46b4..5ea89e2b0 100644 --- a/Sources/Headers/VLCTVConstants.h +++ b/Sources/Headers/VLCTVConstants.h @@ -38,8 +38,6 @@ #define kVLCSettingSkipLoopFilterNonKey @(3) #define kVLCSettingSubtitlesFont @"quartztext-font" #define kVLCSettingSubtitlesFontDefaultValue @"HelveticaNeue" -#define kVLCSettingSubtitlesFontSize @"quartztext-rel-fontsize" -#define kVLCSettingSubtitlesFontSizeDefaultValue @"16" #define kVLCSettingSubtitlesFontColor @"quartztext-color" #define kVLCSettingSubtitlesFontColorDefaultValue @"16777215" #define kVLCSubtitlesCacheFolderName @"cached-subtitles" diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index 85c65aa05..29120b076 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -74,6 +74,7 @@ Keys.networkCaching: NetworkCaching.normal.rawValue, Keys.networkSatIPChannelListUrl: DefaultValues.networkSatIPChannelListUrl, Keys.playerIsRepeatEnabled: DefaultValues.playerRepeatMode, + Keys.subtitlesFontSize: DefaultValues.subtitlesFontSize, Keys.textEncoding: DefaultValues.textEncoding, ] @@ -593,6 +594,15 @@ extension VLCDefaults { } } + @objc var subtitlesFontSize: String { + get { + userDefaults.string(forKey: Keys.subtitlesFontSize) ?? DefaultValues.subtitlesFontSize + } + set { + userDefaults.set(newValue, forKey: Keys.subtitlesFontSize) + } + } + func videoLibraryGridLayout(collectionModelName: String? = nil, name: String) -> Bool { userDefaults.bool(forKey: Keys.videoLibraryGridLayout(collectionModelName: collectionModelName, name: name)) } @@ -624,6 +634,7 @@ extension VLCDefaults { static let playbackForwardSkipLengthSwipeKey: String = Keys.playbackForwardSkipLengthSwipe static let playbackSpeedDefaultValueKey: String = Keys.playbackSpeedDefaultValue static let playerControlDurationKey: String = Keys.playerControlDuration + static let subtitlesFontSizeKey: String = Keys.subtitlesFontSize static let textEncodingKey: String = Keys.textEncoding override init() { @@ -704,6 +715,7 @@ fileprivate enum Keys { static let showThumbnails = "ShowThumbnails" static let stretchAudio = "audio-time-stretch" static let subtitlesBoldFont = "quartztext-bold" + static let subtitlesFontSize = "quartztext-rel-fontsize" static let tabBarIndex = "TabBarIndex" static let textEncoding = "subsdec-encoding" static let videoFullscreenPlayback = "AlwaysUseFullscreenForVideo" @@ -732,4 +744,5 @@ fileprivate enum DefaultValues { static let playbackSpeedDefaultValue = Float(1) static let playerControlDuration = 4 static let playerRepeatMode = VLCRepeatMode.doNotRepeat + static let subtitlesFontSize = "16" } diff --git a/Sources/Playback/Control/VLCPlaybackService.m b/Sources/Playback/Control/VLCPlaybackService.m index 46cec48e2..a4deb13cb 100644 --- a/Sources/Playback/Control/VLCPlaybackService.m +++ b/Sources/Playback/Control/VLCPlaybackService.m @@ -863,7 +863,7 @@ NSString *const VLCLastPlaylistPlayedMedia = @"LastPlaylistPlayedMedia"; #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wundeclared-selector" [_mediaPlayer performSelector:@selector(setTextRendererFont:) withObject:[defaults objectForKey:kVLCSettingSubtitlesFont]]; - [_mediaPlayer performSelector:@selector(setTextRendererFontSize:) withObject:[defaults objectForKey:kVLCSettingSubtitlesFontSize]]; + [_mediaPlayer performSelector:@selector(setTextRendererFontSize:) withObject:VLCDefaults.shared.subtitlesFontSize]; [_mediaPlayer performSelector:@selector(setTextRendererFontColor:) withObject:[defaults objectForKey:kVLCSettingSubtitlesFontColor]]; [_mediaPlayer performSelector:@selector(setTextRendererFontForceBold:) withObject:[NSNumber numberWithBool:VLCDefaults.shared.subtitlesBoldFont]]; #pragma clang diagnostic pop diff --git a/Sources/Settings/Model/SettingsSection.swift b/Sources/Settings/Model/SettingsSection.swift index d1d06b38a..6168cbcc6 100644 --- a/Sources/Settings/Model/SettingsSection.swift +++ b/Sources/Settings/Model/SettingsSection.swift @@ -555,7 +555,7 @@ enum SubtitlesOptions { } static var relativeFontSize: SettingsItem { - let k = kVLCSettingSubtitlesFontSize + let k = VLCDefaults.Compat.subtitlesFontSizeKey return .init(title: "SETTINGS_SUBTITLES_FONTSIZE", subtitle: Localizer.getSubtitle(for: k), action: .showActionSheet(title: "SETTINGS_SUBTITLES_FONTSIZE", preferenceKey: k, hasInfo: true)) -- GitLab From ef8dbf35d00b85ef5b64c6867cd9d40afb2b9002 Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Tue, 25 Feb 2025 20:07:20 -0500 Subject: [PATCH 56/97] Convert kVLCPlayerUIShouldHide --- Sources/App/tvOS/AppleTVAppDelegate.m | 1 - Sources/Headers/VLCTVConstants.h | 1 - Sources/Helpers/VLCDefaults.swift | 12 ++++++++++++ .../VLCFullscreenMovieTVViewController.m | 2 +- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Sources/App/tvOS/AppleTVAppDelegate.m b/Sources/App/tvOS/AppleTVAppDelegate.m index c85b3e3ed..b6c88f034 100644 --- a/Sources/App/tvOS/AppleTVAppDelegate.m +++ b/Sources/App/tvOS/AppleTVAppDelegate.m @@ -43,7 +43,6 @@ NSDictionary *appDefaults = @{kVLCSettingSkipLoopFilter : kVLCSettingSkipLoopFilterNonRef, kVLCSettingSubtitlesFont : kVLCSettingSubtitlesFontDefaultValue, kVLCSettingSubtitlesFontColor : kVLCSettingSubtitlesFontColorDefaultValue, - kVLCPlayerUIShouldHide : @(NO), }; [defaults registerDefaults:appDefaults]; } diff --git a/Sources/Headers/VLCTVConstants.h b/Sources/Headers/VLCTVConstants.h index 5ea89e2b0..e32dc34b9 100644 --- a/Sources/Headers/VLCTVConstants.h +++ b/Sources/Headers/VLCTVConstants.h @@ -43,7 +43,6 @@ #define kVLCSubtitlesCacheFolderName @"cached-subtitles" #define kVLCSettingSubtitlesFilePath @"sub-file" #define kVLCSettingSaveHTTPUploadServerStatus @"isHTTPServerOn" -#define kVLCPlayerUIShouldHide @"PlayerUIShouldHide" #define kVLCSettingUseSPDIF @"kVLCSettingUseSPDIF" #define kVLCSettingDisableSubtitles @"kVLCSettingDisableSubtitles" diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index 29120b076..26eb305f4 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -43,6 +43,7 @@ Keys.playerShouldRememberBrightness: false, Keys.playerShouldRememberState: true, Keys.playerShowPlaybackSpeedShortcut: false, + Keys.playerUIShouldHide: false, Keys.playlistPlayNextItem: true, Keys.playPauseGesture: true, Keys.restoreLastPlayedMedia: true, @@ -306,6 +307,16 @@ extension VLCDefaults { } } + /// tvOS only + @objc var playerUIShouldHide: Bool { + get { + userDefaults.bool(forKey: Keys.playerUIShouldHide) + } + set { + userDefaults.set(newValue, forKey: Keys.playerUIShouldHide) + } + } + @objc var playlistPlayNextItem: Bool { get { userDefaults.bool(forKey: Keys.playlistPlayNextItem) @@ -706,6 +717,7 @@ fileprivate enum Keys { static let playerShouldRememberBrightness = "PlayerShouldRememberBrightness" static let playerShouldRememberState = "PlayerShouldRememberState" static let playerShowPlaybackSpeedShortcut = "kVLCPlayerShowPlaybackSpeedShortcut" + static let playerUIShouldHide = "PlayerUIShouldHide" static let playlistPlayNextItem = "PlaylistPlayNextItem" static let playPauseGesture = "EnablePlayPauseGesture" static let restoreLastPlayedMedia = "RestoreLastPlayedMedia" diff --git a/Sources/Playback/Player/VideoPlayer-tvOS/VLCFullscreenMovieTVViewController.m b/Sources/Playback/Player/VideoPlayer-tvOS/VLCFullscreenMovieTVViewController.m index fddbe7516..acb41cefc 100644 --- a/Sources/Playback/Player/VideoPlayer-tvOS/VLCFullscreenMovieTVViewController.m +++ b/Sources/Playback/Player/VideoPlayer-tvOS/VLCFullscreenMovieTVViewController.m @@ -178,7 +178,7 @@ typedef NS_ENUM(NSInteger, VLCPlayerScanState) vpc.repeatMode = VLCDefaults.shared.playerIsRepeatEnabled; } - self.playbackUIShouldHide = [defaults boolForKey:kVLCPlayerUIShouldHide]; + self.playbackUIShouldHide = VLCDefaults.shared.playerUIShouldHide; if (self.playbackUIShouldHide) { self.activityIndicator.alpha = 0.; [self.activityIndicator stopAnimating]; -- GitLab From 8b0c238eee68456bd22c78f8b1454b73d791203a Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Tue, 25 Feb 2025 20:23:56 -0500 Subject: [PATCH 57/97] Convert kVLCSettingSkipLoopFilter --- Sources/About/AboutController.swift | 2 +- Sources/App/iOS/VLCAppDelegate.m | 1 - Sources/App/tvOS/AppleTVAppDelegate.m | 3 +- Sources/Headers/VLCConstants.h | 3 -- Sources/Headers/VLCTVConstants.h | 4 --- Sources/Helpers/VLCDefaults.swift | 28 +++++++++++++++++++ Sources/Playback/Control/VLCPlaybackService.m | 4 +-- Sources/Settings/Model/SettingsSection.swift | 2 +- 8 files changed, 32 insertions(+), 15 deletions(-) diff --git a/Sources/About/AboutController.swift b/Sources/About/AboutController.swift index b532d8873..5669e1e3e 100644 --- a/Sources/About/AboutController.swift +++ b/Sources/About/AboutController.swift @@ -194,7 +194,7 @@ class AboutController: UIViewController, MFMailComposeViewControllerDelegate, UI VLCLibrary.shared().changeset, VLCDefaults.shared.hardwareDecoding == .hardware ? 0 : 1, // TODO: unsure VLCDefaults.shared.networkCaching.rawValue, - defaults.integer(forKey: kVLCSettingSkipLoopFilter), + VLCDefaults.shared.skipLoopFilter.rawValue, VLCDefaults.shared.networkRTSPTCP ? 1 : 0, VLCDefaults.shared.stretchAudio ? 1 : 0) // TODO: unsure return prefilledFeedback diff --git a/Sources/App/iOS/VLCAppDelegate.m b/Sources/App/iOS/VLCAppDelegate.m index 64fe3ce24..2fb192a12 100644 --- a/Sources/App/iOS/VLCAppDelegate.m +++ b/Sources/App/iOS/VLCAppDelegate.m @@ -44,7 +44,6 @@ [VLCDefaults.shared registerDefaults]; NSDictionary *appDefaults = @{kVLCSettingAppTheme : @(appThemeIndex), - kVLCSettingSkipLoopFilter : kVLCSettingSkipLoopFilterNonRef, kVLCSettingSubtitlesFont : kVLCSettingSubtitlesFontDefaultValue, kVLCSettingSubtitlesFontColor : kVLCSettingSubtitlesFontColorDefaultValue, }; diff --git a/Sources/App/tvOS/AppleTVAppDelegate.m b/Sources/App/tvOS/AppleTVAppDelegate.m index b6c88f034..3cc003f43 100644 --- a/Sources/App/tvOS/AppleTVAppDelegate.m +++ b/Sources/App/tvOS/AppleTVAppDelegate.m @@ -40,8 +40,7 @@ { NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; - NSDictionary *appDefaults = @{kVLCSettingSkipLoopFilter : kVLCSettingSkipLoopFilterNonRef, - kVLCSettingSubtitlesFont : kVLCSettingSubtitlesFontDefaultValue, + NSDictionary *appDefaults = @{kVLCSettingSubtitlesFont : kVLCSettingSubtitlesFontDefaultValue, kVLCSettingSubtitlesFontColor : kVLCSettingSubtitlesFontColorDefaultValue, }; [defaults registerDefaults:appDefaults]; diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index e2a5e8616..9898f550a 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -19,9 +19,6 @@ #define kVLCOptimizeItemNamesForDisplay @"MLDecrapifyTitles" #define kVLCLastPlayedPlaylist @"LastPlayedPlaylist" #define kVLCIsCurrentlyPlayingPlaylist @"isPlaylistCurrentlyPlaying" -#define kVLCSettingSkipLoopFilter @"avcodec-skiploopfilter" -#define kVLCSettingSkipLoopFilterNone @(0) -#define kVLCSettingSkipLoopFilterNonRef @(1) #define kVLCSettingSaveHTTPUploadServerStatus @"isHTTPServerOn" #define kVLCSettingSubtitlesFont @"quartztext-font" #define kVLCSettingSubtitlesFontDefaultValue @"HelveticaNeue" diff --git a/Sources/Headers/VLCTVConstants.h b/Sources/Headers/VLCTVConstants.h index e32dc34b9..78e77d04c 100644 --- a/Sources/Headers/VLCTVConstants.h +++ b/Sources/Headers/VLCTVConstants.h @@ -32,10 +32,6 @@ /* deprecated */ #define kVLCSettingNetworkSatIPChannelListUrl @"satip-channellist-url" -#define kVLCSettingSkipLoopFilter @"avcodec-skiploopfilter" -#define kVLCSettingSkipLoopFilterNone @(0) -#define kVLCSettingSkipLoopFilterNonRef @(1) -#define kVLCSettingSkipLoopFilterNonKey @(3) #define kVLCSettingSubtitlesFont @"quartztext-font" #define kVLCSettingSubtitlesFontDefaultValue @"HelveticaNeue" #define kVLCSettingSubtitlesFontColor @"quartztext-color" diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index 26eb305f4..d7bb5e889 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -75,6 +75,7 @@ Keys.networkCaching: NetworkCaching.normal.rawValue, Keys.networkSatIPChannelListUrl: DefaultValues.networkSatIPChannelListUrl, Keys.playerIsRepeatEnabled: DefaultValues.playerRepeatMode, + Keys.skipLoopFilter: DefaultValues.skipLoopFilter, Keys.subtitlesFontSize: DefaultValues.subtitlesFontSize, Keys.textEncoding: DefaultValues.textEncoding, ] @@ -605,6 +606,22 @@ extension VLCDefaults { } } + var skipLoopFilter: SkipLoopFilter { + get { + let v = userDefaults.integer(forKey: Keys.skipLoopFilter) + return SkipLoopFilter(rawValue: v) ?? DefaultValues.skipLoopFilter + } + set { + userDefaults.set(newValue, forKey: Keys.skipLoopFilter) + } + } + + @objc var skipLoopFilterObjC: Int { + get { + userDefaults.integer(forKey: Keys.skipLoopFilter) + } + } + @objc var subtitlesFontSize: String { get { userDefaults.string(forKey: Keys.subtitlesFontSize) ?? DefaultValues.subtitlesFontSize @@ -645,6 +662,7 @@ extension VLCDefaults { static let playbackForwardSkipLengthSwipeKey: String = Keys.playbackForwardSkipLengthSwipe static let playbackSpeedDefaultValueKey: String = Keys.playbackSpeedDefaultValue static let playerControlDurationKey: String = Keys.playerControlDuration + static let skipLoopFilterKey: String = Keys.skipLoopFilter static let subtitlesFontSizeKey: String = Keys.subtitlesFontSize static let textEncodingKey: String = Keys.textEncoding @@ -673,6 +691,14 @@ extension VLCDefaults { } } +extension VLCDefaults { + enum SkipLoopFilter: Int { + case none = 0 + case nonRef = 1 + case nonKey = 3 + } +} + // MARK: - Keys fileprivate enum Keys { @@ -722,6 +748,7 @@ fileprivate enum Keys { static let playPauseGesture = "EnablePlayPauseGesture" static let restoreLastPlayedMedia = "RestoreLastPlayedMedia" static let seekGesture = "EnableSeekGesture" + static let skipLoopFilter = "avcodec-skiploopfilter" static let showArtworks = "ShowArtworks" static let showRemainingTime = "show-remaining-time" static let showThumbnails = "ShowThumbnails" @@ -756,5 +783,6 @@ fileprivate enum DefaultValues { static let playbackSpeedDefaultValue = Float(1) static let playerControlDuration = 4 static let playerRepeatMode = VLCRepeatMode.doNotRepeat + static let skipLoopFilter = VLCDefaults.SkipLoopFilter.nonRef static let subtitlesFontSize = "16" } diff --git a/Sources/Playback/Control/VLCPlaybackService.m b/Sources/Playback/Control/VLCPlaybackService.m index a4deb13cb..0832d4e0d 100644 --- a/Sources/Playback/Control/VLCPlaybackService.m +++ b/Sources/Playback/Control/VLCPlaybackService.m @@ -1776,11 +1776,9 @@ NSString *const VLCLastPlaylistPlayedMedia = @"LastPlaylistPlayedMedia"; - (NSDictionary *)mediaOptionsDictionary { - NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; - return @{ @"network-caching" : [NSNumber numberWithInteger:VLCDefaults.shared.networkCachingObjC], @"subsdec-encoding" : VLCDefaults.shared.textEncoding, - @"avcodec-skiploopfilter" : [defaults objectForKey:kVLCSettingSkipLoopFilter], + @"avcodec-skiploopfilter" : [NSNumber numberWithInteger:VLCDefaults.shared.skipLoopFilterObjC], @"codec" : VLCDefaults.shared.hardwareDecodingObjC, @"rtsp-tcp" : [NSNumber numberWithBool:VLCDefaults.shared.networkRTSPTCP] }; diff --git a/Sources/Settings/Model/SettingsSection.swift b/Sources/Settings/Model/SettingsSection.swift index 6168cbcc6..06b39e0d5 100644 --- a/Sources/Settings/Model/SettingsSection.swift +++ b/Sources/Settings/Model/SettingsSection.swift @@ -495,7 +495,7 @@ enum GestureControlOptions { enum VideoOptions { static var deBlockingFilter: SettingsItem { - let k = kVLCSettingSkipLoopFilter + let k = VLCDefaults.Compat.skipLoopFilterKey return .init(title: "SETTINGS_SKIP_LOOP_FILTER", subtitle: Localizer.getSubtitle(for: k), action: .showActionSheet(title: "SETTINGS_SKIP_LOOP_FILTER", preferenceKey: k, hasInfo: true)) -- GitLab From 3f4232fd459299e596d2e96731ad0c38c9dd138e Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Tue, 25 Feb 2025 20:30:37 -0500 Subject: [PATCH 58/97] Convert kVLCSettingSubtitlesFontColor --- Sources/App/iOS/VLCAppDelegate.m | 1 - Sources/App/tvOS/AppleTVAppDelegate.m | 1 - Sources/Headers/VLCConstants.h | 2 -- Sources/Headers/VLCTVConstants.h | 2 -- Sources/Helpers/VLCDefaults.swift | 13 +++++++++++++ Sources/Playback/Control/VLCPlaybackService.m | 2 +- Sources/Settings/Model/SettingsSection.swift | 2 +- 7 files changed, 15 insertions(+), 8 deletions(-) diff --git a/Sources/App/iOS/VLCAppDelegate.m b/Sources/App/iOS/VLCAppDelegate.m index 2fb192a12..34248e858 100644 --- a/Sources/App/iOS/VLCAppDelegate.m +++ b/Sources/App/iOS/VLCAppDelegate.m @@ -45,7 +45,6 @@ NSDictionary *appDefaults = @{kVLCSettingAppTheme : @(appThemeIndex), kVLCSettingSubtitlesFont : kVLCSettingSubtitlesFontDefaultValue, - kVLCSettingSubtitlesFontColor : kVLCSettingSubtitlesFontColorDefaultValue, }; [defaults registerDefaults:appDefaults]; } diff --git a/Sources/App/tvOS/AppleTVAppDelegate.m b/Sources/App/tvOS/AppleTVAppDelegate.m index 3cc003f43..41c34803d 100644 --- a/Sources/App/tvOS/AppleTVAppDelegate.m +++ b/Sources/App/tvOS/AppleTVAppDelegate.m @@ -41,7 +41,6 @@ NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; NSDictionary *appDefaults = @{kVLCSettingSubtitlesFont : kVLCSettingSubtitlesFontDefaultValue, - kVLCSettingSubtitlesFontColor : kVLCSettingSubtitlesFontColorDefaultValue, }; [defaults registerDefaults:appDefaults]; } diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index 9898f550a..b46b6d3b5 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -22,8 +22,6 @@ #define kVLCSettingSaveHTTPUploadServerStatus @"isHTTPServerOn" #define kVLCSettingSubtitlesFont @"quartztext-font" #define kVLCSettingSubtitlesFontDefaultValue @"HelveticaNeue" -#define kVLCSettingSubtitlesFontColor @"quartztext-color" -#define kVLCSettingSubtitlesFontColorDefaultValue @"16777215" #define kVLCSettingSubtitlesFilePath @"sub-file" #define kVLCSubtitlesCacheFolderName @"cached-subtitles" #define kVLCSettingRotationLock @"kVLCSettingRotationLock" diff --git a/Sources/Headers/VLCTVConstants.h b/Sources/Headers/VLCTVConstants.h index 78e77d04c..b907f0065 100644 --- a/Sources/Headers/VLCTVConstants.h +++ b/Sources/Headers/VLCTVConstants.h @@ -34,8 +34,6 @@ #define kVLCSettingSubtitlesFont @"quartztext-font" #define kVLCSettingSubtitlesFontDefaultValue @"HelveticaNeue" -#define kVLCSettingSubtitlesFontColor @"quartztext-color" -#define kVLCSettingSubtitlesFontColorDefaultValue @"16777215" #define kVLCSubtitlesCacheFolderName @"cached-subtitles" #define kVLCSettingSubtitlesFilePath @"sub-file" #define kVLCSettingSaveHTTPUploadServerStatus @"isHTTPServerOn" diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index d7bb5e889..da409d763 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -76,6 +76,7 @@ Keys.networkSatIPChannelListUrl: DefaultValues.networkSatIPChannelListUrl, Keys.playerIsRepeatEnabled: DefaultValues.playerRepeatMode, Keys.skipLoopFilter: DefaultValues.skipLoopFilter, + Keys.subtitlesFontColor: DefaultValues.subtitlesFontColor, Keys.subtitlesFontSize: DefaultValues.subtitlesFontSize, Keys.textEncoding: DefaultValues.textEncoding, ] @@ -622,6 +623,15 @@ extension VLCDefaults { } } + @objc var subtitlesFontColor: String { + get { + userDefaults.string(forKey: Keys.subtitlesFontColor) ?? DefaultValues.subtitlesFontColor + } + set { + userDefaults.set(newValue, forKey: Keys.subtitlesFontColor) + } + } + @objc var subtitlesFontSize: String { get { userDefaults.string(forKey: Keys.subtitlesFontSize) ?? DefaultValues.subtitlesFontSize @@ -663,6 +673,7 @@ extension VLCDefaults { static let playbackSpeedDefaultValueKey: String = Keys.playbackSpeedDefaultValue static let playerControlDurationKey: String = Keys.playerControlDuration static let skipLoopFilterKey: String = Keys.skipLoopFilter + static let subtitlesFontColorKey: String = Keys.subtitlesFontColor static let subtitlesFontSizeKey: String = Keys.subtitlesFontSize static let textEncodingKey: String = Keys.textEncoding @@ -755,6 +766,7 @@ fileprivate enum Keys { static let stretchAudio = "audio-time-stretch" static let subtitlesBoldFont = "quartztext-bold" static let subtitlesFontSize = "quartztext-rel-fontsize" + static let subtitlesFontColor = "quartztext-color" static let tabBarIndex = "TabBarIndex" static let textEncoding = "subsdec-encoding" static let videoFullscreenPlayback = "AlwaysUseFullscreenForVideo" @@ -785,4 +797,5 @@ fileprivate enum DefaultValues { static let playerRepeatMode = VLCRepeatMode.doNotRepeat static let skipLoopFilter = VLCDefaults.SkipLoopFilter.nonRef static let subtitlesFontSize = "16" + static let subtitlesFontColor = "16777215" } diff --git a/Sources/Playback/Control/VLCPlaybackService.m b/Sources/Playback/Control/VLCPlaybackService.m index 0832d4e0d..86be288fd 100644 --- a/Sources/Playback/Control/VLCPlaybackService.m +++ b/Sources/Playback/Control/VLCPlaybackService.m @@ -864,7 +864,7 @@ NSString *const VLCLastPlaylistPlayedMedia = @"LastPlaylistPlayedMedia"; #pragma clang diagnostic ignored "-Wundeclared-selector" [_mediaPlayer performSelector:@selector(setTextRendererFont:) withObject:[defaults objectForKey:kVLCSettingSubtitlesFont]]; [_mediaPlayer performSelector:@selector(setTextRendererFontSize:) withObject:VLCDefaults.shared.subtitlesFontSize]; - [_mediaPlayer performSelector:@selector(setTextRendererFontColor:) withObject:[defaults objectForKey:kVLCSettingSubtitlesFontColor]]; + [_mediaPlayer performSelector:@selector(setTextRendererFontColor:) withObject:VLCDefaults.shared.subtitlesFontColor]; [_mediaPlayer performSelector:@selector(setTextRendererFontForceBold:) withObject:[NSNumber numberWithBool:VLCDefaults.shared.subtitlesBoldFont]]; #pragma clang diagnostic pop } break; diff --git a/Sources/Settings/Model/SettingsSection.swift b/Sources/Settings/Model/SettingsSection.swift index 06b39e0d5..e62d5dd3a 100644 --- a/Sources/Settings/Model/SettingsSection.swift +++ b/Sources/Settings/Model/SettingsSection.swift @@ -568,7 +568,7 @@ enum SubtitlesOptions { } static var fontColor: SettingsItem { - let k = kVLCSettingSubtitlesFontColor + let k = VLCDefaults.Compat.subtitlesFontColorKey return .init(title: "SETTINGS_SUBTITLES_FONTCOLOR", subtitle: Localizer.getSubtitle(for: k), action: .showActionSheet(title: "SETTINGS_SUBTITLES_FONTCOLOR", preferenceKey: k, hasInfo: true)) -- GitLab From adcfa19d662058edd12a10e307fc1b52f3e80b88 Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Tue, 25 Feb 2025 20:36:44 -0500 Subject: [PATCH 59/97] Convert kVLCSettingSubtitlesFont --- Sources/App/iOS/VLCAppDelegate.m | 4 +--- Sources/App/tvOS/AppleTVAppDelegate.m | 6 +----- Sources/Headers/VLCConstants.h | 2 -- Sources/Headers/VLCTVConstants.h | 2 -- Sources/Helpers/VLCDefaults.swift | 16 ++++++++++++++-- Sources/Playback/Control/VLCPlaybackService.m | 3 +-- Sources/Settings/Model/SettingsSection.swift | 2 +- 7 files changed, 18 insertions(+), 17 deletions(-) diff --git a/Sources/App/iOS/VLCAppDelegate.m b/Sources/App/iOS/VLCAppDelegate.m index 34248e858..0d486dfb7 100644 --- a/Sources/App/iOS/VLCAppDelegate.m +++ b/Sources/App/iOS/VLCAppDelegate.m @@ -43,9 +43,7 @@ [VLCDefaults.shared registerDefaults]; - NSDictionary *appDefaults = @{kVLCSettingAppTheme : @(appThemeIndex), - kVLCSettingSubtitlesFont : kVLCSettingSubtitlesFontDefaultValue, - }; + NSDictionary *appDefaults = @{kVLCSettingAppTheme : @(appThemeIndex)}; [defaults registerDefaults:appDefaults]; } diff --git a/Sources/App/tvOS/AppleTVAppDelegate.m b/Sources/App/tvOS/AppleTVAppDelegate.m index 41c34803d..6aa2f8046 100644 --- a/Sources/App/tvOS/AppleTVAppDelegate.m +++ b/Sources/App/tvOS/AppleTVAppDelegate.m @@ -38,11 +38,7 @@ + (void)initialize { - NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; - - NSDictionary *appDefaults = @{kVLCSettingSubtitlesFont : kVLCSettingSubtitlesFontDefaultValue, - }; - [defaults registerDefaults:appDefaults]; + [VLCDefaults.shared registerDefaults]; } - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index b46b6d3b5..b4eb43059 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -20,8 +20,6 @@ #define kVLCLastPlayedPlaylist @"LastPlayedPlaylist" #define kVLCIsCurrentlyPlayingPlaylist @"isPlaylistCurrentlyPlaying" #define kVLCSettingSaveHTTPUploadServerStatus @"isHTTPServerOn" -#define kVLCSettingSubtitlesFont @"quartztext-font" -#define kVLCSettingSubtitlesFontDefaultValue @"HelveticaNeue" #define kVLCSettingSubtitlesFilePath @"sub-file" #define kVLCSubtitlesCacheFolderName @"cached-subtitles" #define kVLCSettingRotationLock @"kVLCSettingRotationLock" diff --git a/Sources/Headers/VLCTVConstants.h b/Sources/Headers/VLCTVConstants.h index b907f0065..3d1093600 100644 --- a/Sources/Headers/VLCTVConstants.h +++ b/Sources/Headers/VLCTVConstants.h @@ -32,8 +32,6 @@ /* deprecated */ #define kVLCSettingNetworkSatIPChannelListUrl @"satip-channellist-url" -#define kVLCSettingSubtitlesFont @"quartztext-font" -#define kVLCSettingSubtitlesFontDefaultValue @"HelveticaNeue" #define kVLCSubtitlesCacheFolderName @"cached-subtitles" #define kVLCSettingSubtitlesFilePath @"sub-file" #define kVLCSettingSaveHTTPUploadServerStatus @"isHTTPServerOn" diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index da409d763..b8bb630ad 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -623,6 +623,15 @@ extension VLCDefaults { } } + @objc var subtitlesFont: String { + get { + userDefaults.string(forKey: Keys.subtitlesFont) ?? DefaultValues.subtitlesFont + } + set { + userDefaults.set(newValue, forKey: Keys.subtitlesFont) + } + } + @objc var subtitlesFontColor: String { get { userDefaults.string(forKey: Keys.subtitlesFontColor) ?? DefaultValues.subtitlesFontColor @@ -673,6 +682,7 @@ extension VLCDefaults { static let playbackSpeedDefaultValueKey: String = Keys.playbackSpeedDefaultValue static let playerControlDurationKey: String = Keys.playerControlDuration static let skipLoopFilterKey: String = Keys.skipLoopFilter + static let subtitlesFontKey: String = Keys.subtitlesFont static let subtitlesFontColorKey: String = Keys.subtitlesFontColor static let subtitlesFontSizeKey: String = Keys.subtitlesFontSize static let textEncodingKey: String = Keys.textEncoding @@ -765,8 +775,9 @@ fileprivate enum Keys { static let showThumbnails = "ShowThumbnails" static let stretchAudio = "audio-time-stretch" static let subtitlesBoldFont = "quartztext-bold" - static let subtitlesFontSize = "quartztext-rel-fontsize" + static let subtitlesFont = "quartztext-font" static let subtitlesFontColor = "quartztext-color" + static let subtitlesFontSize = "quartztext-rel-fontsize" static let tabBarIndex = "TabBarIndex" static let textEncoding = "subsdec-encoding" static let videoFullscreenPlayback = "AlwaysUseFullscreenForVideo" @@ -796,6 +807,7 @@ fileprivate enum DefaultValues { static let playerControlDuration = 4 static let playerRepeatMode = VLCRepeatMode.doNotRepeat static let skipLoopFilter = VLCDefaults.SkipLoopFilter.nonRef - static let subtitlesFontSize = "16" + static let subtitlesFont = "HelveticaNeue" static let subtitlesFontColor = "16777215" + static let subtitlesFontSize = "16" } diff --git a/Sources/Playback/Control/VLCPlaybackService.m b/Sources/Playback/Control/VLCPlaybackService.m index 86be288fd..812347259 100644 --- a/Sources/Playback/Control/VLCPlaybackService.m +++ b/Sources/Playback/Control/VLCPlaybackService.m @@ -859,10 +859,9 @@ NSString *const VLCLastPlaylistPlayedMedia = @"LastPlaylistPlayedMedia"; _mediaPlayer.media.delegate = self; /* on-the-fly values through hidden API */ - NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wundeclared-selector" - [_mediaPlayer performSelector:@selector(setTextRendererFont:) withObject:[defaults objectForKey:kVLCSettingSubtitlesFont]]; + [_mediaPlayer performSelector:@selector(setTextRendererFont:) withObject:VLCDefaults.shared.subtitlesFontSize]; [_mediaPlayer performSelector:@selector(setTextRendererFontSize:) withObject:VLCDefaults.shared.subtitlesFontSize]; [_mediaPlayer performSelector:@selector(setTextRendererFontColor:) withObject:VLCDefaults.shared.subtitlesFontColor]; [_mediaPlayer performSelector:@selector(setTextRendererFontForceBold:) withObject:[NSNumber numberWithBool:VLCDefaults.shared.subtitlesBoldFont]]; diff --git a/Sources/Settings/Model/SettingsSection.swift b/Sources/Settings/Model/SettingsSection.swift index e62d5dd3a..acdc1f3c5 100644 --- a/Sources/Settings/Model/SettingsSection.swift +++ b/Sources/Settings/Model/SettingsSection.swift @@ -548,7 +548,7 @@ enum SubtitlesOptions { } static var font: SettingsItem { - let k = kVLCSettingSubtitlesFont + let k = VLCDefaults.Compat.subtitlesFontKey return .init(title: "SETTINGS_SUBTITLES_FONT", subtitle: Localizer.getSubtitle(for: k), action: .showActionSheet(title: "SETTINGS_SUBTITLES_FONT", preferenceKey: k, hasInfo: true)) -- GitLab From 9d6d069baa6e1ec993c3c2fe5a00fc7412b160e4 Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Tue, 25 Feb 2025 21:00:34 -0500 Subject: [PATCH 60/97] Convert kVLCSettingAppTheme --- Sources/App/iOS/VLCAppDelegate.m | 9 ------ Sources/Headers/VLCConstants.h | 3 -- Sources/Helpers/ColorThemeExtension.swift | 2 +- Sources/Helpers/VLCDefaults.swift | 31 +++++++++++++++++++ .../Server List/VLCServerListViewController.m | 2 +- ...aybackInfoSubtitlesFetcherViewController.m | 2 +- .../Settings/Model/ActionSheetSpecifier.swift | 8 ++--- Sources/Settings/Model/SettingsSection.swift | 2 +- Sources/UI Elements/PresentationTheme.swift | 18 ++++++++--- 9 files changed, 52 insertions(+), 25 deletions(-) diff --git a/Sources/App/iOS/VLCAppDelegate.m b/Sources/App/iOS/VLCAppDelegate.m index 0d486dfb7..aea0b8e50 100644 --- a/Sources/App/iOS/VLCAppDelegate.m +++ b/Sources/App/iOS/VLCAppDelegate.m @@ -35,16 +35,7 @@ + (void)initialize { - NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; - NSUInteger appThemeIndex = kVLCSettingAppThemeBright; - if (@available(iOS 13.0, *)) { - appThemeIndex = kVLCSettingAppThemeSystem; - } - [VLCDefaults.shared registerDefaults]; - - NSDictionary *appDefaults = @{kVLCSettingAppTheme : @(appThemeIndex)}; - [defaults registerDefaults:appDefaults]; } - (void)setupTabBarAppearance diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index b4eb43059..ac9569a98 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -13,9 +13,6 @@ #define kVLCSettingPasscodeOnKey @"PasscodeProtection" #define kVLCThemeDidChangeNotification @"themeDidChangeNotfication" -#define kVLCSettingAppTheme @"darkMode" -#define kVLCSettingAppThemeBright 0 -#define kVLCSettingAppThemeSystem 2 #define kVLCOptimizeItemNamesForDisplay @"MLDecrapifyTitles" #define kVLCLastPlayedPlaylist @"LastPlayedPlaylist" #define kVLCIsCurrentlyPlayingPlaylist @"isPlaylistCurrentlyPlaying" diff --git a/Sources/Helpers/ColorThemeExtension.swift b/Sources/Helpers/ColorThemeExtension.swift index b3f07ce24..160384079 100644 --- a/Sources/Helpers/ColorThemeExtension.swift +++ b/Sources/Helpers/ColorThemeExtension.swift @@ -17,7 +17,7 @@ extension PresentationTheme { // there was a userInterfaceStyle change. return } - guard UserDefaults.standard.integer(forKey: kVLCSettingAppTheme) == kVLCSettingAppThemeSystem else { + guard VLCDefaults.shared.appTheme == .system else { // Theme is specificly set, do not follow systeme theme. return } diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index b8bb630ad..9fe53c7cd 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -71,6 +71,7 @@ Keys.tabBarIndex: 0, // other + Keys.appTheme: DefaultValues.appTheme, Keys.hardwareDecoding: HardwareDecoding.hardware.rawValue, Keys.networkCaching: NetworkCaching.normal.rawValue, Keys.networkSatIPChannelListUrl: DefaultValues.networkSatIPChannelListUrl, @@ -548,6 +549,20 @@ extension VLCDefaults { // Other + var appTheme: AppTheme { + get { + let v = userDefaults.integer(forKey: Keys.appTheme) + return AppTheme(rawValue: v) ?? DefaultValues.appTheme + } + set { + userDefaults.set(newValue.rawValue, forKey: Keys.appTheme) + } + } + + @objc var appThemeIsSystem: Bool { + appTheme == .system + } + var hardwareDecoding: HardwareDecoding { get { guard let v = userDefaults.string(forKey: Keys.hardwareDecoding) else { @@ -665,6 +680,7 @@ extension VLCDefaults { @available(*, deprecated, message: "avoid using keys to access defaults directly, instead use properties on VLCDefaults") @objc(VLCDefaultsCompat) final class Compat: NSObject { + static let appThemeKey: String = Keys.appTheme static let automaticallyPlayNextItemKey: String = Keys.automaticallyPlayNextItem static let backupMediaLibraryKey: String = Keys.backupMediaLibrary static let castingConversionQualityKey: String = Keys.castingConversionQuality @@ -695,6 +711,14 @@ extension VLCDefaults { // MARK: - Value Types +extension VLCDefaults { + enum AppTheme: Int { + case bright = 0 + case dark = 1 + case system = 2 + } +} + extension VLCDefaults { enum HardwareDecoding: String { case software = "avcodec,all" @@ -726,6 +750,7 @@ fileprivate enum Keys { // Avoid ever changing these values. Some are used as parameters in functions. // Changing a value also causes the locally stored value to become unreachable. static let alwaysPlayURLs = "kVLCSettingAlwaysPlayURLs" + static let appTheme = "darkMode" static let appThemeBlack = "blackTheme" static let automaticallyPlayNextItem = "AutomaticallyPlayNextItem" static let backupMediaLibrary = "BackupMediaLibrary" @@ -794,6 +819,12 @@ fileprivate enum Keys { // MARK: - Default Values fileprivate enum DefaultValues { + static let appTheme: VLCDefaults.AppTheme = { + if #available(iOS 13.0, *) { + return .system + } + return .bright + }() static let castingConversionQuality = 2 static let deinterlace = Int(-1) static let equalizerProfile = Int(0) diff --git a/Sources/Network/Server List/VLCServerListViewController.m b/Sources/Network/Server List/VLCServerListViewController.m index d18889263..8dbc3aeb6 100644 --- a/Sources/Network/Server List/VLCServerListViewController.m +++ b/Sources/Network/Server List/VLCServerListViewController.m @@ -82,7 +82,7 @@ return; } - if ([[NSUserDefaults standardUserDefaults] integerForKey:kVLCSettingAppTheme] == kVLCSettingAppThemeSystem) { + if (VLCDefaults.shared.appThemeIsSystem) { [PresentationTheme themeDidUpdate]; } [self themeDidChange]; diff --git a/Sources/Playback/Subtitles Downloading/VLCPlaybackInfoSubtitlesFetcherViewController.m b/Sources/Playback/Subtitles Downloading/VLCPlaybackInfoSubtitlesFetcherViewController.m index 8320861dd..144e28ad3 100644 --- a/Sources/Playback/Subtitles Downloading/VLCPlaybackInfoSubtitlesFetcherViewController.m +++ b/Sources/Playback/Subtitles Downloading/VLCPlaybackInfoSubtitlesFetcherViewController.m @@ -231,7 +231,7 @@ return; } - if ([[NSUserDefaults standardUserDefaults] integerForKey:kVLCSettingAppTheme] == kVLCSettingAppThemeSystem) { + if (VLCDefaults.shared.appThemeIsSystem) { [PresentationTheme themeDidUpdate]; } [self themeDidChange]; diff --git a/Sources/Settings/Model/ActionSheetSpecifier.swift b/Sources/Settings/Model/ActionSheetSpecifier.swift index 9d59fb1e9..e1b5dd369 100644 --- a/Sources/Settings/Model/ActionSheetSpecifier.swift +++ b/Sources/Settings/Model/ActionSheetSpecifier.swift @@ -60,7 +60,7 @@ extension ActionSheetSpecifier: ActionSheetDelegate { return } - guard preferenceKey != kVLCSettingAppTheme || + guard preferenceKey != VLCDefaults.Compat.appThemeKey || (!PresentationTheme.current.isDark || indexPath.row != numberOfRows() - 1) else { // Disable the selection for the black background option cell in the appearance action sheet return @@ -73,7 +73,7 @@ extension ActionSheetSpecifier: ActionSheetDelegate { userDefaults.set(settingSpecifier?.specifier[indexPath.row].value, forKey: preferenceKey) - if preferenceKey == kVLCSettingAppTheme { + if preferenceKey == VLCDefaults.Compat.appThemeKey { PresentationTheme.themeDidUpdate() } @@ -106,7 +106,7 @@ extension ActionSheetSpecifier: ActionSheetDataSource { return 0 } - if preferenceKey == kVLCSettingAppTheme { + if preferenceKey == VLCDefaults.Compat.appThemeKey { let isThemeDark: Bool = PresentationTheme.current.isDark if #available(iOS 13, *) { return isThemeDark ? rowCount : rowCount - 1 @@ -128,7 +128,7 @@ extension ActionSheetSpecifier: ActionSheetDataSource { return UICollectionViewCell() } - if preferenceKey == kVLCSettingAppTheme && + if preferenceKey == VLCDefaults.Compat.appThemeKey && PresentationTheme.current.isDark && indexPath.row == numberOfRows() - 1 { // Update the black background option cell cell.setAccessoryType(to: .toggleSwitch) diff --git a/Sources/Settings/Model/SettingsSection.swift b/Sources/Settings/Model/SettingsSection.swift index acdc1f3c5..5cbf4942f 100644 --- a/Sources/Settings/Model/SettingsSection.swift +++ b/Sources/Settings/Model/SettingsSection.swift @@ -195,7 +195,7 @@ enum MainOptions { } static var appearance: SettingsItem { - let k = kVLCSettingAppTheme + let k = VLCDefaults.Compat.appThemeKey return .init(title: "SETTINGS_DARKTHEME", subtitle: Localizer.getSubtitle(for: k), action: .showActionSheet(title: "SETTINGS_DARKTHEME", preferenceKey: k, hasInfo: false)) diff --git a/Sources/UI Elements/PresentationTheme.swift b/Sources/UI Elements/PresentationTheme.swift index 560b40079..6ecf715e8 100644 --- a/Sources/UI Elements/PresentationTheme.swift +++ b/Sources/UI Elements/PresentationTheme.swift @@ -104,6 +104,17 @@ enum PresentationThemeType: Int { case bright = 0 case dark case auto + + static func from(appTheme: VLCDefaults.AppTheme) -> PresentationThemeType { + switch appTheme { + case .dark: + return .dark + case .bright: + return .bright + case .system: + return .auto + } + } } @objcMembers class PresentationTheme: NSObject { @@ -121,8 +132,7 @@ enum PresentationThemeType: Int { } static var current: PresentationTheme = { - let themeSettings = UserDefaults.standard.integer(forKey: kVLCSettingAppTheme) - return PresentationTheme.respectiveTheme(for: PresentationThemeType(rawValue: themeSettings)) + return PresentationTheme.respectiveTheme(for: PresentationThemeType.from(appTheme: VLCDefaults.shared.appTheme)) }() { didSet { AppearanceManager.setupAppearance(theme: self.current) @@ -144,9 +154,7 @@ enum PresentationThemeType: Int { } @objc static func themeDidUpdate() { - let themeSettings = UserDefaults.standard.integer(forKey: kVLCSettingAppTheme) - PresentationTheme.current = PresentationTheme.respectiveTheme(for: - PresentationThemeType(rawValue: themeSettings)) + PresentationTheme.current = PresentationTheme.respectiveTheme(for: PresentationThemeType.from(appTheme: VLCDefaults.shared.appTheme)) } static func respectiveTheme(for theme: PresentationThemeType?, excludingBlackTheme: Bool = false) -> PresentationTheme { -- GitLab From 106cdb563bd31a358e60425f3e463bc3ebf34c55 Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Tue, 25 Feb 2025 21:06:35 -0500 Subject: [PATCH 61/97] Fix a crash. Fix sorting of defaults keys. --- Sources/Helpers/VLCDefaults.swift | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index 9fe53c7cd..b24f7871d 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -71,12 +71,12 @@ Keys.tabBarIndex: 0, // other - Keys.appTheme: DefaultValues.appTheme, + Keys.appTheme: DefaultValues.appTheme.rawValue, Keys.hardwareDecoding: HardwareDecoding.hardware.rawValue, Keys.networkCaching: NetworkCaching.normal.rawValue, Keys.networkSatIPChannelListUrl: DefaultValues.networkSatIPChannelListUrl, - Keys.playerIsRepeatEnabled: DefaultValues.playerRepeatMode, - Keys.skipLoopFilter: DefaultValues.skipLoopFilter, + Keys.playerIsRepeatEnabled: DefaultValues.playerRepeatMode.rawValue, + Keys.skipLoopFilter: DefaultValues.skipLoopFilter.rawValue, Keys.subtitlesFontColor: DefaultValues.subtitlesFontColor, Keys.subtitlesFontSize: DefaultValues.subtitlesFontSize, Keys.textEncoding: DefaultValues.textEncoding, @@ -698,8 +698,8 @@ extension VLCDefaults { static let playbackSpeedDefaultValueKey: String = Keys.playbackSpeedDefaultValue static let playerControlDurationKey: String = Keys.playerControlDuration static let skipLoopFilterKey: String = Keys.skipLoopFilter - static let subtitlesFontKey: String = Keys.subtitlesFont static let subtitlesFontColorKey: String = Keys.subtitlesFontColor + static let subtitlesFontKey: String = Keys.subtitlesFont static let subtitlesFontSizeKey: String = Keys.subtitlesFontSize static let textEncodingKey: String = Keys.textEncoding @@ -775,10 +775,10 @@ fileprivate enum Keys { static let networkSatIPChannelListUrl = "satip-channellist-url" static let passcodeEnableBiometricAuth = "EnableBiometricAuth" static let pauseWhenShowingControls = "kVLCSettingPauseWhenShowingControls" - static let playbackForwardBackwardEqual = "playback-forward-backward-equal" static let playbackBackwardSkipLength = "playback-backward-skip-length" - static let playbackForwardSkipLength = "playback-forward-skip-length" static let playbackBackwardSkipLengthSwipe = "playback-backward-skip-length-swipe" + static let playbackForwardBackwardEqual = "playback-forward-backward-equal" + static let playbackForwardSkipLength = "playback-forward-skip-length" static let playbackForwardSkipLengthSwipe = "playback-forward-skip-length-swipe" static let playbackLongTouchSpeedUp = "LongTouchSpeedUp" static let playbackSpeedDefaultValue = "playback-speed" @@ -794,10 +794,10 @@ fileprivate enum Keys { static let playPauseGesture = "EnablePlayPauseGesture" static let restoreLastPlayedMedia = "RestoreLastPlayedMedia" static let seekGesture = "EnableSeekGesture" - static let skipLoopFilter = "avcodec-skiploopfilter" static let showArtworks = "ShowArtworks" static let showRemainingTime = "show-remaining-time" static let showThumbnails = "ShowThumbnails" + static let skipLoopFilter = "avcodec-skiploopfilter" static let stretchAudio = "audio-time-stretch" static let subtitlesBoldFont = "quartztext-bold" static let subtitlesFont = "quartztext-font" -- GitLab From a1342db119c15a0401fc61e6f1b521207b443897 Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Tue, 25 Feb 2025 21:25:32 -0500 Subject: [PATCH 62/97] Convert kVLCAudioLibraryGridLayout --- Sources/Headers/VLCConstants.h | 1 - Sources/Helpers/VLCDefaults.swift | 14 ++++++++++++++ .../MediaCategoryViewController.swift | 8 +++----- .../MediaLibraryModel/AlbumModel.swift | 2 +- .../MediaLibraryModel/ArtistModel.swift | 2 +- .../MediaLibraryModel/CollectionModel.swift | 9 ++++++--- .../MediaLibraryModel/GenreModel.swift | 2 +- .../MediaLibraryModel/PlaylistModel.swift | 2 +- .../MediaLibraryModel/TrackModel.swift | 2 +- .../ActionSheet/ActionSheetSortSectionHeader.swift | 3 +-- 10 files changed, 29 insertions(+), 16 deletions(-) diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index ac9569a98..dead8512f 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -34,7 +34,6 @@ #define kVLCPrivateWebStreaming @"private-streaming" #define kVLChttpScanSubtitle @"http-scan-subtitle" #define kVLCHTTPUploadDirectory @"Upload" -#define kVLCAudioLibraryGridLayout @"kVLCAudioLibraryGridLayout" #define kVLCAudioLibraryHideFeatArtists @"kVLCAudioLibraryHideFeatArtists" #define kVLCAudioLibraryHideTrackNumbers @"kVLCAudioLibraryHideTrackNumbers" diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index b24f7871d..7473780f6 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -672,6 +672,14 @@ extension VLCDefaults { func setVideoLibraryGridLayout(collectionModelName: String? = nil, name: String, isGrid: Bool) { userDefaults.set(isGrid, forKey: Keys.videoLibraryGridLayout(collectionModelName: collectionModelName, name: name)) } + + func audioLibraryGridLayout(collectionModelName: String? = nil, name: String) -> Bool { + userDefaults.bool(forKey: Keys.audioLibraryGridLayout(collectionModelName: collectionModelName, name: name)) + } + + func setAudioLibraryGridLayout(collectionModelName: String? = nil, name: String, isGrid: Bool) { + userDefaults.set(isGrid, forKey: Keys.audioLibraryGridLayout(collectionModelName: collectionModelName, name: name)) + } } // MARK: - Compatibility @@ -814,6 +822,12 @@ fileprivate enum Keys { "kVLCVideoLibraryGridLayout", collectionModelName, name ].compactMap { $0 }.joined() } + + static func audioLibraryGridLayout(collectionModelName: String? = nil, name: String) -> String { + [ + "kVLCAudioLibraryGridLayout", collectionModelName, name + ].compactMap { $0 }.joined() + } } // MARK: - Default Values diff --git a/Sources/Media Library/MediaCategories/MediaCategoryViewController.swift b/Sources/Media Library/MediaCategories/MediaCategoryViewController.swift index bf417ba96..fe64bf5fd 100644 --- a/Sources/Media Library/MediaCategories/MediaCategoryViewController.swift +++ b/Sources/Media Library/MediaCategories/MediaCategoryViewController.swift @@ -1525,8 +1525,6 @@ extension MediaCategoryViewController: ActionSheetSortSectionHeaderDelegate { func handleLayoutChange(gridLayout: Bool) { var prefix: String = "" - var suffix: String = "" - var collectionModelName: String = "" var isVideoModel = false if let model = model as? CollectionModel { @@ -1544,9 +1542,9 @@ extension MediaCategoryViewController: ActionSheetSortSectionHeaderDelegate { name: model.name, isGrid: gridLayout) case false: - prefix = kVLCAudioLibraryGridLayout - suffix = collectionModelName + model.name - userDefaults.set(gridLayout, forKey: "\(prefix)\(suffix)") + VLCDefaults.shared.setAudioLibraryGridLayout(collectionModelName: collectionModelName, + name: model.name, + isGrid: gridLayout) } setupCollectionView() diff --git a/Sources/Media Library/MediaLibraryModel/AlbumModel.swift b/Sources/Media Library/MediaLibraryModel/AlbumModel.swift index a2ccfa9f2..ec14e4ca5 100644 --- a/Sources/Media Library/MediaLibraryModel/AlbumModel.swift +++ b/Sources/Media Library/MediaLibraryModel/AlbumModel.swift @@ -22,7 +22,7 @@ class AlbumModel: AudioCollectionModel { private var artist: VLCMLArtist? = nil var cellType: BaseCollectionViewCell.Type { - return UserDefaults.standard.bool(forKey: "\(kVLCAudioLibraryGridLayout)\(name)") ? MediaGridCollectionCell.self : MediaCollectionViewCell.self + return VLCDefaults.shared.audioLibraryGridLayout(name: name) ? MediaGridCollectionCell.self : MediaCollectionViewCell.self } var medialibrary: MediaLibraryService diff --git a/Sources/Media Library/MediaLibraryModel/ArtistModel.swift b/Sources/Media Library/MediaLibraryModel/ArtistModel.swift index 4934fab6e..93cd11092 100644 --- a/Sources/Media Library/MediaLibraryModel/ArtistModel.swift +++ b/Sources/Media Library/MediaLibraryModel/ArtistModel.swift @@ -20,7 +20,7 @@ class ArtistModel: AudioCollectionModel { var fileArrayLock = NSRecursiveLock() var cellType: BaseCollectionViewCell.Type { - return UserDefaults.standard.bool(forKey: "\(kVLCAudioLibraryGridLayout)\(name)") ? MediaGridCollectionCell.self : MediaCollectionViewCell.self + return VLCDefaults.shared.audioLibraryGridLayout(name: name) ? MediaGridCollectionCell.self : MediaCollectionViewCell.self } var medialibrary: MediaLibraryService diff --git a/Sources/Media Library/MediaLibraryModel/CollectionModel.swift b/Sources/Media Library/MediaLibraryModel/CollectionModel.swift index d39b103d0..a0ac6ec3e 100644 --- a/Sources/Media Library/MediaLibraryModel/CollectionModel.swift +++ b/Sources/Media Library/MediaLibraryModel/CollectionModel.swift @@ -27,13 +27,16 @@ class CollectionModel: MLBaseModel { var files = [VLCMLMedia]() var cellType: BaseCollectionViewCell.Type { + let collectionModelName: String = String(describing: type(of: mediaCollection)) + if mediaCollection is VLCMLMediaGroup { return VLCDefaults.shared - .videoLibraryGridLayout(collectionModelName: String(describing: type(of: mediaCollection)), name: name) ? + .videoLibraryGridLayout(collectionModelName: collectionModelName, name: name) ? MovieCollectionViewCell.self : MediaCollectionViewCell.self } else { - return UserDefaults.standard.bool(forKey: "\(kVLCAudioLibraryGridLayout)\(String(describing: type(of: mediaCollection)) + name)") ? - MediaGridCollectionCell.self : MediaCollectionViewCell.self + return VLCDefaults.shared + .audioLibraryGridLayout(collectionModelName: collectionModelName, name: name) ? + MediaGridCollectionCell.self : MediaCollectionViewCell.self } } diff --git a/Sources/Media Library/MediaLibraryModel/GenreModel.swift b/Sources/Media Library/MediaLibraryModel/GenreModel.swift index 6824e031e..d0f7cbb18 100644 --- a/Sources/Media Library/MediaLibraryModel/GenreModel.swift +++ b/Sources/Media Library/MediaLibraryModel/GenreModel.swift @@ -20,7 +20,7 @@ class GenreModel: AudioCollectionModel { var files = [VLCMLGenre]() var cellType: BaseCollectionViewCell.Type { - return UserDefaults.standard.bool(forKey: "\(kVLCAudioLibraryGridLayout)\(name)") ? MediaGridCollectionCell.self : MediaCollectionViewCell.self + return VLCDefaults.shared.audioLibraryGridLayout(name: name) ? MediaGridCollectionCell.self : MediaCollectionViewCell.self } var medialibrary: MediaLibraryService diff --git a/Sources/Media Library/MediaLibraryModel/PlaylistModel.swift b/Sources/Media Library/MediaLibraryModel/PlaylistModel.swift index 25c1e9732..a7164ff00 100644 --- a/Sources/Media Library/MediaLibraryModel/PlaylistModel.swift +++ b/Sources/Media Library/MediaLibraryModel/PlaylistModel.swift @@ -21,7 +21,7 @@ class PlaylistModel: MLBaseModel { var files = [VLCMLPlaylist]() var cellType: BaseCollectionViewCell.Type { - return UserDefaults.standard.bool(forKey: "\(kVLCAudioLibraryGridLayout)\(name)") ? MovieCollectionViewCell.self : MediaCollectionViewCell.self + return VLCDefaults.shared.audioLibraryGridLayout(name: name) ? MovieCollectionViewCell.self : MediaCollectionViewCell.self } var medialibrary: MediaLibraryService diff --git a/Sources/Media Library/MediaLibraryModel/TrackModel.swift b/Sources/Media Library/MediaLibraryModel/TrackModel.swift index f7cdb6b0c..7623a4152 100644 --- a/Sources/Media Library/MediaLibraryModel/TrackModel.swift +++ b/Sources/Media Library/MediaLibraryModel/TrackModel.swift @@ -20,7 +20,7 @@ class TrackModel: MediaModel { var fileArrayLock = NSRecursiveLock() var cellType: BaseCollectionViewCell.Type { - return UserDefaults.standard.bool(forKey: "\(kVLCAudioLibraryGridLayout)\(name)") ? MediaGridCollectionCell.self : MediaCollectionViewCell.self + return VLCDefaults.shared.audioLibraryGridLayout(name: name) ? MediaGridCollectionCell.self : MediaCollectionViewCell.self } var medialibrary: MediaLibraryService diff --git a/Sources/UI Elements/ActionSheet/ActionSheetSortSectionHeader.swift b/Sources/UI Elements/ActionSheet/ActionSheetSortSectionHeader.swift index ba8961acf..bf84f7419 100644 --- a/Sources/UI Elements/ActionSheet/ActionSheetSortSectionHeader.swift +++ b/Sources/UI Elements/ActionSheet/ActionSheetSortSectionHeader.swift @@ -30,7 +30,6 @@ class ActionSheetSortSectionHeader: ActionSheetSectionHeader { private var sortModel: SortModel private var secondSortModel: SortModel? - private let userDefaults = UserDefaults.standard private var isAdditionalOptionShown: Bool = false private let descendingStackView: UIStackView = { @@ -255,7 +254,7 @@ class ActionSheetSortSectionHeader: ActionSheetSectionHeader { case true: layoutChangeSwitch.isOn = VLCDefaults.shared.videoLibraryGridLayout(name: modelType) case false: - layoutChangeSwitch.isOn = UserDefaults.standard.bool(forKey: kVLCAudioLibraryGridLayout + modelType) + layoutChangeSwitch.isOn = VLCDefaults.shared.audioLibraryGridLayout(name: modelType) } } -- GitLab From 301ae765c59e3f58edbbec78067196c31d87b59c Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Tue, 25 Feb 2025 21:26:25 -0500 Subject: [PATCH 63/97] Convert kVLCAudioLibraryHideFeatArtists --- Sources/CarPlay/VLCCarPlayArtistsController.m | 2 +- Sources/Headers/VLCConstants.h | 1 - Sources/Helpers/VLCDefaults.swift | 11 +++++++++++ .../MediaCategories/MediaCategoryViewController.swift | 2 +- .../Media Library/MediaLibraryModel/ArtistModel.swift | 2 +- .../MediaViewControllers/MediaViewController.swift | 2 +- .../ActionSheet/ActionSheetSortSectionHeader.swift | 2 +- 7 files changed, 16 insertions(+), 6 deletions(-) diff --git a/Sources/CarPlay/VLCCarPlayArtistsController.m b/Sources/CarPlay/VLCCarPlayArtistsController.m index 4a21decea..191325aa3 100644 --- a/Sources/CarPlay/VLCCarPlayArtistsController.m +++ b/Sources/CarPlay/VLCCarPlayArtistsController.m @@ -66,7 +66,7 @@ - (NSArray *)listOfArtists { - BOOL hideFeatArtists = [[NSUserDefaults standardUserDefaults] boolForKey:kVLCAudioLibraryHideFeatArtists]; + BOOL hideFeatArtists = VLCDefaults.shared.audioLibraryHideFeatArtists; NSArray *artists = [[VLCAppCoordinator sharedInstance].mediaLibraryService artistsWithSortingCriteria:VLCMLSortingCriteriaDefault desc:NO listAll:!hideFeatArtists]; diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index dead8512f..f93760635 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -34,7 +34,6 @@ #define kVLCPrivateWebStreaming @"private-streaming" #define kVLChttpScanSubtitle @"http-scan-subtitle" #define kVLCHTTPUploadDirectory @"Upload" -#define kVLCAudioLibraryHideFeatArtists @"kVLCAudioLibraryHideFeatArtists" #define kVLCAudioLibraryHideTrackNumbers @"kVLCAudioLibraryHideTrackNumbers" #define kVLCLastPlayedMediaIdentifier @"LastPlayedMediaIdentifier" diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index 7473780f6..2f8cdbf9f 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -22,6 +22,7 @@ // bools Keys.alwaysPlayURLs: false, Keys.appThemeBlack: false, + Keys.audioLibraryHideFeatArtists: false, Keys.automaticallyPlayNextItem: true, Keys.backupMediaLibrary: false, Keys.brightnessGesture: true, @@ -121,6 +122,15 @@ extension VLCDefaults { } } + @objc var audioLibraryHideFeatArtists: Bool { + get { + userDefaults.bool(forKey: Keys.audioLibraryHideFeatArtists) + } + set { + userDefaults.set(newValue, forKey: Keys.audioLibraryHideFeatArtists) + } + } + @objc var automaticallyPlayNextItem: Bool { get { userDefaults.bool(forKey: Keys.automaticallyPlayNextItem) @@ -760,6 +770,7 @@ fileprivate enum Keys { static let alwaysPlayURLs = "kVLCSettingAlwaysPlayURLs" static let appTheme = "darkMode" static let appThemeBlack = "blackTheme" + static let audioLibraryHideFeatArtists = "kVLCAudioLibraryHideFeatArtists" static let automaticallyPlayNextItem = "AutomaticallyPlayNextItem" static let backupMediaLibrary = "BackupMediaLibrary" static let brightnessGesture = "EnableBrightnessGesture" diff --git a/Sources/Media Library/MediaCategories/MediaCategoryViewController.swift b/Sources/Media Library/MediaCategories/MediaCategoryViewController.swift index fe64bf5fd..8c4740348 100644 --- a/Sources/Media Library/MediaCategories/MediaCategoryViewController.swift +++ b/Sources/Media Library/MediaCategories/MediaCategoryViewController.swift @@ -1554,7 +1554,7 @@ extension MediaCategoryViewController: ActionSheetSortSectionHeaderDelegate { } func actionSheetSortSectionHeaderShouldHideFeatArtists(onSwitchIsOnChange: Bool) { - userDefaults.set(onSwitchIsOnChange, forKey: "\(kVLCAudioLibraryHideFeatArtists)") + VLCDefaults.shared.audioLibraryHideFeatArtists = onSwitchIsOnChange setupCollectionView() cachedCellSize = .zero model.sort(by: model.sortModel.currentSort, desc: model.sortModel.desc) diff --git a/Sources/Media Library/MediaLibraryModel/ArtistModel.swift b/Sources/Media Library/MediaLibraryModel/ArtistModel.swift index 93cd11092..6422ec0a3 100644 --- a/Sources/Media Library/MediaLibraryModel/ArtistModel.swift +++ b/Sources/Media Library/MediaLibraryModel/ArtistModel.swift @@ -30,7 +30,7 @@ class ArtistModel: AudioCollectionModel { var indicatorName: String = NSLocalizedString("ARTISTS", comment: "") var hideFeatArtists: Bool { - return UserDefaults.standard.bool(forKey: "\(kVLCAudioLibraryHideFeatArtists)") + return VLCDefaults.shared.audioLibraryHideFeatArtists } required init(medialibrary: MediaLibraryService) { diff --git a/Sources/Media Library/MediaViewControllers/MediaViewController.swift b/Sources/Media Library/MediaViewControllers/MediaViewController.swift index 3077251a6..5bbaacdee 100644 --- a/Sources/Media Library/MediaViewControllers/MediaViewController.swift +++ b/Sources/Media Library/MediaViewControllers/MediaViewController.swift @@ -533,7 +533,7 @@ extension MediaViewController { var additionalMenuItems: [UIAction] = [] if mediaCategoryViewController.model is ArtistModel { - let isIncludeAllArtistActive = UserDefaults.standard.bool(forKey: kVLCAudioLibraryHideFeatArtists) + let isIncludeAllArtistActive = VLCDefaults.shared.audioLibraryHideFeatArtists let includeAllArtist = UIAction(title: NSLocalizedString("HIDE_FEAT_ARTISTS", comment: ""), image: UIImage(systemName: "person.3"), state: isIncludeAllArtistActive ? .on : .off, diff --git a/Sources/UI Elements/ActionSheet/ActionSheetSortSectionHeader.swift b/Sources/UI Elements/ActionSheet/ActionSheetSortSectionHeader.swift index bf84f7419..7fe3e0132 100644 --- a/Sources/UI Elements/ActionSheet/ActionSheetSortSectionHeader.swift +++ b/Sources/UI Elements/ActionSheet/ActionSheetSortSectionHeader.swift @@ -299,7 +299,7 @@ class ActionSheetSortSectionHeader: ActionSheetSectionHeader { secondaryStackView.addArrangedSubview(hideFeatArtistsStackView) - hideFeatArtistsSwitch.isOn = UserDefaults.standard.bool(forKey: kVLCAudioLibraryHideFeatArtists) + hideFeatArtistsSwitch.isOn = VLCDefaults.shared.audioLibraryHideFeatArtists } func updateHeaderForAlbums() { -- GitLab From a551e8fe10b49a1874ce1dcdd6bd1682bbb94a83 Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Tue, 25 Feb 2025 21:28:46 -0500 Subject: [PATCH 64/97] Remove unused kVLCOptimizeItemNamesForDisplay --- Sources/Headers/VLCConstants.h | 1 - Sources/Media Library/MediaLibraryModel/MediaModel.swift | 5 ----- 2 files changed, 6 deletions(-) diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index f93760635..6bd58d4e0 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -13,7 +13,6 @@ #define kVLCSettingPasscodeOnKey @"PasscodeProtection" #define kVLCThemeDidChangeNotification @"themeDidChangeNotfication" -#define kVLCOptimizeItemNamesForDisplay @"MLDecrapifyTitles" #define kVLCLastPlayedPlaylist @"LastPlayedPlaylist" #define kVLCIsCurrentlyPlayingPlaylist @"isPlaylistCurrentlyPlaying" #define kVLCSettingSaveHTTPUploadServerStatus @"isHTTPServerOn" diff --git a/Sources/Media Library/MediaLibraryModel/MediaModel.swift b/Sources/Media Library/MediaLibraryModel/MediaModel.swift index af56877fd..2e76b447c 100644 --- a/Sources/Media Library/MediaLibraryModel/MediaModel.swift +++ b/Sources/Media Library/MediaLibraryModel/MediaModel.swift @@ -78,11 +78,6 @@ extension VLCMLMedia { } func title() -> String { - if UserDefaults.standard.bool(forKey: kVLCOptimizeItemNamesForDisplay) == true - && ((subtype() == .albumTrack && title.isSupportedAudioMediaFormat()) - || (subtype() != .albumTrack && title.isSupportedMediaFormat())) { - return (title as NSString).deletingPathExtension - } return title } } -- GitLab From 345562338d92184baf86b428258b97f25e24b245 Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Tue, 25 Feb 2025 21:34:47 -0500 Subject: [PATCH 65/97] Convert kVLCIsCurrentlyPlayingPlaylist --- Sources/Headers/VLCConstants.h | 1 - Sources/Helpers/VLCDefaults.swift | 23 ++++++++++++++----- .../MediaCategoryViewController.swift | 8 +++---- .../MediaCollectionViewCell.swift | 2 +- .../MovieCollectionViewCell.swift | 2 +- 5 files changed, 23 insertions(+), 13 deletions(-) diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index 6bd58d4e0..b4ea793b9 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -14,7 +14,6 @@ #define kVLCSettingPasscodeOnKey @"PasscodeProtection" #define kVLCThemeDidChangeNotification @"themeDidChangeNotfication" #define kVLCLastPlayedPlaylist @"LastPlayedPlaylist" -#define kVLCIsCurrentlyPlayingPlaylist @"isPlaylistCurrentlyPlaying" #define kVLCSettingSaveHTTPUploadServerStatus @"isHTTPServerOn" #define kVLCSettingSubtitlesFilePath @"sub-file" #define kVLCSubtitlesCacheFolderName @"cached-subtitles" diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index 2f8cdbf9f..4bd476add 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -29,6 +29,7 @@ Keys.castingAudioPassthrough: false, Keys.closeGesture: true, Keys.continueAudioInBackground: true, + Keys.currentlyPlayingPlaylist: false, Keys.downloadArtwork: true, Keys.enableMediaCellTextScrolling: false, Keys.equalizerProfileDisabled: true, @@ -176,21 +177,30 @@ extension VLCDefaults { } } - @objc var downloadArtwork: Bool { + @objc var continueAudioInBackgroundKey: Bool { get { - userDefaults.bool(forKey: Keys.downloadArtwork) + userDefaults.bool(forKey: Keys.continueAudioInBackground) } set { - userDefaults.set(newValue, forKey: Keys.downloadArtwork) + userDefaults.set(newValue, forKey: Keys.continueAudioInBackground) } } - @objc var continueAudioInBackgroundKey: Bool { + @objc var currentlyPlayingPlaylist: Bool { get { - userDefaults.bool(forKey: Keys.continueAudioInBackground) + userDefaults.bool(forKey: Keys.currentlyPlayingPlaylist) } set { - userDefaults.set(newValue, forKey: Keys.continueAudioInBackground) + userDefaults.set(newValue, forKey: Keys.currentlyPlayingPlaylist) + } + } + + @objc var downloadArtwork: Bool { + get { + userDefaults.bool(forKey: Keys.downloadArtwork) + } + set { + userDefaults.set(newValue, forKey: Keys.downloadArtwork) } } @@ -780,6 +790,7 @@ fileprivate enum Keys { static let continueAudioInBackground = "BackgroundAudioPlayback" static let continueAudioPlayback = "ContinueAudioPlayback" static let continuePlayback = "ContinuePlayback" + static let currentlyPlayingPlaylist = "isPlaylistCurrentlyPlaying" static let defaultPreampLevel = "pre-amp-level" static let deinterlace = "deinterlace" static let downloadArtwork = "download-artwork" diff --git a/Sources/Media Library/MediaCategories/MediaCategoryViewController.swift b/Sources/Media Library/MediaCategories/MediaCategoryViewController.swift index 8c4740348..d09708036 100644 --- a/Sources/Media Library/MediaCategories/MediaCategoryViewController.swift +++ b/Sources/Media Library/MediaCategories/MediaCategoryViewController.swift @@ -212,7 +212,7 @@ class MediaCategoryViewController: UICollectionViewController, UISearchBarDelega // Indicating that the current chosen collection to play is playlist, useful for handling Observer private var isPlaylistCurrentlyPlaying: Bool { - return userDefaults.bool(forKey: kVLCIsCurrentlyPlayingPlaylist) + return VLCDefaults.shared.currentlyPlayingPlaylist } // catch the selected index from collection view, helper for playbackDidStart @@ -641,7 +641,7 @@ class MediaCategoryViewController: UICollectionViewController, UISearchBarDelega saveCurrentPlaylistInfo(with: playlist.identifier(), playlistTitle: playlist.title(), media: playlist.media?[selectedIndex.row]) addPlaybackWillStopObserver() reloadData() - userDefaults.set(true, forKey: kVLCIsCurrentlyPlayingPlaylist) + VLCDefaults.shared.currentlyPlayingPlaylist = true } else if let playlists = currentDataSet as? [VLCMLPlaylist], let selectedIndex = collectionSelectedIndex { let selectedPlaylist = playlists[selectedIndex.row] guard let media = PlaybackService.sharedInstance().currentlyPlayingMedia, @@ -650,7 +650,7 @@ class MediaCategoryViewController: UICollectionViewController, UISearchBarDelega saveCurrentPlaylistInfo(with: selectedPlaylist.identifier(), playlistTitle: selectedPlaylist.title(), media: mlMedia) addPlaybackWillStopObserver() reloadData() - userDefaults.set(true, forKey: kVLCIsCurrentlyPlayingPlaylist) + VLCDefaults.shared.currentlyPlayingPlaylist = true } else if isPlaylistCurrentlyPlaying { //if the playlist media is already being played and the current model is not Playlist or playlist collection media. //This will update the value of last played media, leading to right indication if the app is suddenly closed. @@ -1865,7 +1865,7 @@ extension MediaCategoryViewController { reloadData() removePlaybackWillStopObserver() - userDefaults.setValue(false, forKey: kVLCIsCurrentlyPlayingPlaylist) + VLCDefaults.shared.currentlyPlayingPlaylist = false playbackCache.clearQueuePlaylistInfo() } diff --git a/Sources/Media Library/MediaCategoryCells/MediaCollectionViewCell.swift b/Sources/Media Library/MediaCategoryCells/MediaCollectionViewCell.swift index 63d5fb35f..0648915b0 100644 --- a/Sources/Media Library/MediaCategoryCells/MediaCollectionViewCell.swift +++ b/Sources/Media Library/MediaCategoryCells/MediaCollectionViewCell.swift @@ -617,7 +617,7 @@ class MediaCollectionViewCell: BaseCollectionViewCell, UIScrollViewDelegate { // MARK: - Handle New label Text func handleLastPlayed() { - let isCurrentlyPlayingPlaylist = UserDefaults.standard.bool(forKey: kVLCIsCurrentlyPlayingPlaylist) + let isCurrentlyPlayingPlaylist = VLCDefaults.shared.currentlyPlayingPlaylist let shouldDisplayLastPlayedLabel = (!playbackService.isPlaying && playbackService.currentlyPlayingMedia == nil) || !isCurrentlyPlayingPlaylist newLabel.isHidden = !shouldDisplayLastPlayedLabel diff --git a/Sources/Media Library/MediaCategoryCells/MovieCollectionViewCell.swift b/Sources/Media Library/MediaCategoryCells/MovieCollectionViewCell.swift index d4cb9b393..99500d1df 100644 --- a/Sources/Media Library/MediaCategoryCells/MovieCollectionViewCell.swift +++ b/Sources/Media Library/MediaCategoryCells/MovieCollectionViewCell.swift @@ -193,7 +193,7 @@ class MovieCollectionViewCell: BaseCollectionViewCell { let playbackService = PlaybackService.sharedInstance() if lastPlayed { - let isCurrentlyPlayingPlaylist = UserDefaults.standard.bool(forKey: kVLCIsCurrentlyPlayingPlaylist) + let isCurrentlyPlayingPlaylist = VLCDefaults.shared.currentlyPlayingPlaylist let shouldDisplayLastPlayedLabel = (!playbackService.isPlaying && playbackService.currentlyPlayingMedia == nil) || !isCurrentlyPlayingPlaylist groupLastPlayedLabel.isHidden = !shouldDisplayLastPlayedLabel groupLastPlayedLabel.text = NSLocalizedString("LAST_PLAYED_PLAYLIST_LABEL_TITLE", comment: "") -- GitLab From 00a2cbd2a18eddb58adc810e572db7eb16a23cfc Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Tue, 25 Feb 2025 21:38:51 -0500 Subject: [PATCH 66/97] Convert MediaLibraryDidForceRescan --- Sources/Helpers/VLCDefaults.swift | 11 +++++++++++ Sources/Media Library/MediaLibraryService.swift | 5 ++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index 4bd476add..6f8b8c7eb 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -35,6 +35,7 @@ Keys.equalizerProfileDisabled: true, Keys.forceSMBV1: true, Keys.hideLibraryInFilesApp: false, + Keys.mediaLibraryServiceDidForceRescan: false, Keys.networkRTSPTCP: false, Keys.passcodeEnableBiometricAuth: true, Keys.pauseWhenShowingControls: false, @@ -240,6 +241,15 @@ extension VLCDefaults { } } + @objc var mediaLibraryServiceDidForceRescan: Bool { + get { + userDefaults.bool(forKey: Keys.mediaLibraryServiceDidForceRescan) + } + set { + userDefaults.set(newValue, forKey: Keys.mediaLibraryServiceDidForceRescan) + } + } + @objc var networkRTSPTCP: Bool { get { userDefaults.bool(forKey: Keys.networkRTSPTCP) @@ -800,6 +810,7 @@ fileprivate enum Keys { static let forceSMBV1 = "smb-force-v1" static let hardwareDecoding = "codec" static let hideLibraryInFilesApp = "HideLibraryInFilesApp" + static let mediaLibraryServiceDidForceRescan = "MediaLibraryDidForceRescan" static let networkCaching = "network-caching" static let networkRTSPTCP = "rtsp-tcp" static let networkSatIPChannelListUrl = "satip-channellist-url" diff --git a/Sources/Media Library/MediaLibraryService.swift b/Sources/Media Library/MediaLibraryService.swift index 012f32f21..4d14094ed 100644 --- a/Sources/Media Library/MediaLibraryService.swift +++ b/Sources/Media Library/MediaLibraryService.swift @@ -136,7 +136,6 @@ extension NSNotification { class MediaLibraryService: NSObject { private static let databaseName: String = "medialibrary.db" - private static let didForceRescan: String = "MediaLibraryDidForceRescan" private var triedToRecoverFromInitializationErrorOnce = false private var didFinishDiscovery = false @@ -194,9 +193,9 @@ private extension MediaLibraryService { excludeFromDeviceBackup(excludeMediaLibrary) hideMediaLibrary(hideML) - if UserDefaults.standard.bool(forKey: MediaLibraryService.didForceRescan) == false { + if !VLCDefaults.shared.mediaLibraryServiceDidForceRescan { medialib.forceRescan() - UserDefaults.standard.set(true, forKey: MediaLibraryService.didForceRescan) + VLCDefaults.shared.mediaLibraryServiceDidForceRescan = true } FileManager.default.createFile(atPath: "\(path)/\(NSLocalizedString("MEDIALIBRARY_FILES_PLACEHOLDER", comment: ""))", contents: nil, attributes: nil) -- GitLab From ba84f10a62d1a6def9ccef963f9bda0fba455326 Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Tue, 25 Feb 2025 21:46:03 -0500 Subject: [PATCH 67/97] Minor cleanup. --- Sources/About/AboutController.swift | 1 - Sources/Helpers/VLCDefaults.swift | 5 +++++ .../MediaCategoryCells/MediaGridCollectionCell.swift | 1 - Sources/Settings/Controller/SettingsController.swift | 4 +--- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Sources/About/AboutController.swift b/Sources/About/AboutController.swift index 5669e1e3e..5c833d849 100644 --- a/Sources/About/AboutController.swift +++ b/Sources/About/AboutController.swift @@ -181,7 +181,6 @@ class AboutController: UIViewController, MFMailComposeViewControllerDelegate, UI func generateFeedbackEmailPrefill() -> String { let bundleShortVersionString = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as! String let device = UIDevice.current - let defaults = UserDefaults.standard let locale = NSLocale.autoupdatingCurrent let prefilledFeedback = String(format: "\n\n\n----------------------------------------\n%@\nDevice: %@\nOS: %@ - %@\nLocale: %@ (%@)\nVLC app version: %@\nlibvlc version: %@\nhardware decoding: %i\nnetwork caching level: %i\nskip loop filter: %i\nRTSP over TCP: %i\nAudio time stretching: %i", NSLocalizedString("FEEDBACK_EMAIL_BODY", comment: ""), diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index 6f8b8c7eb..44a4e95b9 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -98,6 +98,11 @@ userDefaults.register(defaults: dict) } + + func reset() { + let appDomain = Bundle.main.bundleIdentifier! + UserDefaults().removePersistentDomain(forName: appDomain) + } } // MARK: - Defaults diff --git a/Sources/Media Library/MediaCategoryCells/MediaGridCollectionCell.swift b/Sources/Media Library/MediaCategoryCells/MediaGridCollectionCell.swift index 6c074ea1d..22f37e165 100644 --- a/Sources/Media Library/MediaCategoryCells/MediaGridCollectionCell.swift +++ b/Sources/Media Library/MediaCategoryCells/MediaGridCollectionCell.swift @@ -15,7 +15,6 @@ import UIKit class MediaGridCollectionCell: BaseCollectionViewCell { private let notificationCenter = NotificationCenter.default - private let userDefaults = UserDefaults.standard private let selectionOverlayColor = UIColor.orange.withAlphaComponent(0.4) private let checkboxImageView: UIImageView = { diff --git a/Sources/Settings/Controller/SettingsController.swift b/Sources/Settings/Controller/SettingsController.swift index c40bbda0b..401fa7920 100644 --- a/Sources/Settings/Controller/SettingsController.swift +++ b/Sources/Settings/Controller/SettingsController.swift @@ -296,9 +296,7 @@ class SettingsController: UITableViewController { } private func resetOptions() { - // note that [NSUserDefaults resetStandardUserDefaults] will NOT correctly reset to the defaults - let appDomain = Bundle.main.bundleIdentifier! - UserDefaults().removePersistentDomain(forName: appDomain) + VLCDefaults.shared.reset() } } -- GitLab From bf34c5544e5abc7d2cd10c8da19e65c58ec0cb5b Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Tue, 25 Feb 2025 21:50:49 -0500 Subject: [PATCH 68/97] Convert kVLCHasLaunchedBefore --- Sources/Headers/VLCConstants.h | 1 - Sources/Helpers/VLCDefaults.swift | 12 ++++++++++++ .../MediaCategoryViewController.swift | 4 ++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index b4ea793b9..4e3018dad 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -78,7 +78,6 @@ #define kVLCSortDefault @"SortDefault" #define kVLCSortDescendingDefault @"SortDescendingDefault" -#define kVLCHasLaunchedBefore @"hasLaunchedBefore" #define kVLCHasNaggedThisMonth @"kVLCHasNaggedThisMonth" #define kVLCNumberOfLaunches @"kVLCNumberOfLaunches" #define kVLCHasActiveSubscription @"kVLCHasActiveSubscription" diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index 44a4e95b9..a4c19e51e 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -34,6 +34,7 @@ Keys.enableMediaCellTextScrolling: false, Keys.equalizerProfileDisabled: true, Keys.forceSMBV1: true, + Keys.hasLaunchedBefore: false, Keys.hideLibraryInFilesApp: false, Keys.mediaLibraryServiceDidForceRescan: false, Keys.networkRTSPTCP: false, @@ -237,6 +238,16 @@ extension VLCDefaults { } } + var hasLaunchedBefore: Bool { + userDefaults.bool(forKey: Keys.hasLaunchedBefore) + } + + func setHasLaunchedBeforeIfNeeded() { + if !hasLaunchedBefore { + userDefaults.set(true, forKey: Keys.hasLaunchedBefore) + } + } + @objc var hideLibraryInFilesApp: Bool { get { userDefaults.bool(forKey: Keys.hideLibraryInFilesApp) @@ -814,6 +825,7 @@ fileprivate enum Keys { static let equalizerProfileDisabled = "EqualizerDisabled" static let forceSMBV1 = "smb-force-v1" static let hardwareDecoding = "codec" + static let hasLaunchedBefore = "hasLaunchedBefore" static let hideLibraryInFilesApp = "HideLibraryInFilesApp" static let mediaLibraryServiceDidForceRescan = "MediaLibraryDidForceRescan" static let networkCaching = "network-caching" diff --git a/Sources/Media Library/MediaCategories/MediaCategoryViewController.swift b/Sources/Media Library/MediaCategories/MediaCategoryViewController.swift index d09708036..c3a0f1e2c 100644 --- a/Sources/Media Library/MediaCategories/MediaCategoryViewController.swift +++ b/Sources/Media Library/MediaCategories/MediaCategoryViewController.swift @@ -79,7 +79,7 @@ class MediaCategoryViewController: UICollectionViewController, UISearchBarDelega private lazy var navItemTitle: VLCMarqueeLabel = VLCMarqueeLabel() private var hasLaunchedBefore: Bool { - return userDefaults.bool(forKey: kVLCHasLaunchedBefore) + return VLCDefaults.shared.hasLaunchedBefore } @objc private lazy var sortActionSheet: ActionSheet = { @@ -604,7 +604,7 @@ class MediaCategoryViewController: UICollectionViewController, UISearchBarDelega let navigationController = UINavigationController(rootViewController: firstStepController) navigationController.modalPresentationStyle = .formSheet self.present(navigationController, animated: true) - userDefaults.set(true, forKey: kVLCHasLaunchedBefore) + VLCDefaults.shared.setHasLaunchedBeforeIfNeeded() } else { if userDefaults.bool(forKey: kVLCHasActiveSubscription) { return -- GitLab From f218589928a8af4cf0ebd8fa36531eda4cf96acf Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Tue, 25 Feb 2025 21:56:06 -0500 Subject: [PATCH 69/97] Convert kVLCAudioLibraryHideTrackNumbers --- Sources/Headers/VLCConstants.h | 1 - Sources/Helpers/VLCDefaults.swift | 11 +++++++++++ .../MediaCategories/MediaCategoryViewController.swift | 2 +- .../MediaCategoryCells/MediaCollectionViewCell.swift | 2 +- .../MediaViewControllers/MediaViewController.swift | 2 +- .../ActionSheet/ActionSheetSortSectionHeader.swift | 2 +- 6 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index 4e3018dad..bc2fc479c 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -32,7 +32,6 @@ #define kVLCPrivateWebStreaming @"private-streaming" #define kVLChttpScanSubtitle @"http-scan-subtitle" #define kVLCHTTPUploadDirectory @"Upload" -#define kVLCAudioLibraryHideTrackNumbers @"kVLCAudioLibraryHideTrackNumbers" #define kVLCLastPlayedMediaIdentifier @"LastPlayedMediaIdentifier" diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index a4c19e51e..bdf3450e6 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -23,6 +23,7 @@ Keys.alwaysPlayURLs: false, Keys.appThemeBlack: false, Keys.audioLibraryHideFeatArtists: false, + Keys.audioLibraryHideTrackNumbers: false, Keys.automaticallyPlayNextItem: true, Keys.backupMediaLibrary: false, Keys.brightnessGesture: true, @@ -139,6 +140,15 @@ extension VLCDefaults { } } + @objc var audioLibraryHideTrackNumbers: Bool { + get { + userDefaults.bool(forKey: Keys.audioLibraryHideTrackNumbers) + } + set { + userDefaults.set(newValue, forKey: Keys.audioLibraryHideTrackNumbers) + } + } + @objc var automaticallyPlayNextItem: Bool { get { userDefaults.bool(forKey: Keys.automaticallyPlayNextItem) @@ -807,6 +817,7 @@ fileprivate enum Keys { static let appTheme = "darkMode" static let appThemeBlack = "blackTheme" static let audioLibraryHideFeatArtists = "kVLCAudioLibraryHideFeatArtists" + static let audioLibraryHideTrackNumbers = "kVLCAudioLibraryHideTrackNumbers" static let automaticallyPlayNextItem = "AutomaticallyPlayNextItem" static let backupMediaLibrary = "BackupMediaLibrary" static let brightnessGesture = "EnableBrightnessGesture" diff --git a/Sources/Media Library/MediaCategories/MediaCategoryViewController.swift b/Sources/Media Library/MediaCategories/MediaCategoryViewController.swift index c3a0f1e2c..2c31c2c90 100644 --- a/Sources/Media Library/MediaCategories/MediaCategoryViewController.swift +++ b/Sources/Media Library/MediaCategories/MediaCategoryViewController.swift @@ -1562,7 +1562,7 @@ extension MediaCategoryViewController: ActionSheetSortSectionHeaderDelegate { } func actionSheetSortSectionHeaderShouldHideTrackNumbers(onSwitchIsOnChange: Bool) { - userDefaults.set(onSwitchIsOnChange, forKey: "\(kVLCAudioLibraryHideTrackNumbers)") + VLCDefaults.shared.audioLibraryHideTrackNumbers = onSwitchIsOnChange setupCollectionView() cachedCellSize = .zero model.sort(by: model.sortModel.currentSort, desc: model.sortModel.desc) diff --git a/Sources/Media Library/MediaCategoryCells/MediaCollectionViewCell.swift b/Sources/Media Library/MediaCategoryCells/MediaCollectionViewCell.swift index 0648915b0..43d14a1f1 100644 --- a/Sources/Media Library/MediaCategoryCells/MediaCollectionViewCell.swift +++ b/Sources/Media Library/MediaCategoryCells/MediaCollectionViewCell.swift @@ -260,7 +260,7 @@ class MediaCollectionViewCell: BaseCollectionViewCell, UIScrollViewDelegate { trackNumber = String(describing: media.trackNumber) + ". " } - let displayTrackNumber: Bool = !UserDefaults.standard.bool(forKey: kVLCAudioLibraryHideTrackNumbers) + let displayTrackNumber: Bool = !VLCDefaults.shared.audioLibraryHideTrackNumbers titleLabel.text = displayTrackNumber ? trackNumber + audiotrack.title() : audiotrack.title() accessibilityLabel = audiotrack.accessibilityText(editing: false) var descriptionText = audiotrack.albumTrackArtistName() diff --git a/Sources/Media Library/MediaViewControllers/MediaViewController.swift b/Sources/Media Library/MediaViewControllers/MediaViewController.swift index 5bbaacdee..ff00e5e31 100644 --- a/Sources/Media Library/MediaViewControllers/MediaViewController.swift +++ b/Sources/Media Library/MediaViewControllers/MediaViewController.swift @@ -545,7 +545,7 @@ extension MediaViewController { } else if let model = mediaCategoryViewController.model as? CollectionModel, let mediaCollection = model.mediaCollection as? VLCMLAlbum, !mediaCollection.isUnknownAlbum() { - let hideTrackNumbers = UserDefaults.standard.bool(forKey: kVLCAudioLibraryHideTrackNumbers) + let hideTrackNumbers = VLCDefaults.shared.audioLibraryHideTrackNumbers let hideTrackNumbersAction = UIAction(title: NSLocalizedString("HIDE_TRACK_NUMBERS", comment: ""), state: hideTrackNumbers ? .on : .off, handler: { _ in diff --git a/Sources/UI Elements/ActionSheet/ActionSheetSortSectionHeader.swift b/Sources/UI Elements/ActionSheet/ActionSheetSortSectionHeader.swift index 7fe3e0132..1b2bbd8dc 100644 --- a/Sources/UI Elements/ActionSheet/ActionSheetSortSectionHeader.swift +++ b/Sources/UI Elements/ActionSheet/ActionSheetSortSectionHeader.swift @@ -309,6 +309,6 @@ class ActionSheetSortSectionHeader: ActionSheetSectionHeader { secondaryStackView.addArrangedSubview(hideTrackNumbersStackView) - hideTrackNumbersSwitch.isOn = UserDefaults.standard.bool(forKey: kVLCAudioLibraryHideTrackNumbers) + hideTrackNumbersSwitch.isOn = VLCDefaults.shared.audioLibraryHideTrackNumbers } } -- GitLab From 365ae17430635c389d2eb4f4ffa7775d38a51694 Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Tue, 25 Feb 2025 21:59:08 -0500 Subject: [PATCH 70/97] Remove some unused user default from objective C --- Sources/Playback/Control/VLCPlaybackService.m | 6 ------ Sources/Playback/Control/VLCPlayerDisplayController.m | 1 - 2 files changed, 7 deletions(-) diff --git a/Sources/Playback/Control/VLCPlaybackService.m b/Sources/Playback/Control/VLCPlaybackService.m index 812347259..8d27666c5 100644 --- a/Sources/Playback/Control/VLCPlaybackService.m +++ b/Sources/Playback/Control/VLCPlaybackService.m @@ -220,8 +220,6 @@ NSString *const VLCLastPlaylistPlayedMedia = @"LastPlaylistPlayedMedia"; return; } - NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; - if (!self.mediaList) { APLog(@"%s: no URL and no media list set, stopping playback", __PRETTY_FUNCTION__); [_playbackSessionManagementLock unlock]; @@ -340,7 +338,6 @@ NSString *const VLCLastPlaylistPlayedMedia = @"LastPlaylistPlayedMedia"; return; } - NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults]; BOOL equalizerEnabled = !VLCDefaults.shared.equalizerProfileDisabled; VLCAudioEqualizer *equalizer; @@ -580,7 +577,6 @@ NSString *const VLCLastPlaylistPlayedMedia = @"LastPlaylistPlayedMedia"; } [[NSNotificationCenter defaultCenter] postNotificationName:VLCPlaybackServicePlaybackModeUpdated object:self]; - NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; if (VLCDefaults.shared.playerShouldRememberState) { VLCDefaults.shared.playerIsRepeatEnabled = repeatMode; } @@ -1017,7 +1013,6 @@ NSString *const VLCLastPlaylistPlayedMedia = @"LastPlaylistPlayedMedia"; [[NSNotificationCenter defaultCenter] postNotificationName:VLCPlaybackServiceShuffleModeUpdated object:self]; - NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; if (VLCDefaults.shared.playerShouldRememberState) { VLCDefaults.shared.playerIsShuffleEnabled = shuffleMode; } @@ -1399,7 +1394,6 @@ NSString *const VLCLastPlaylistPlayedMedia = @"LastPlaylistPlayedMedia"; - (void)resetEqualizerFromProfile:(unsigned int)profile { - NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults]; if (profile == 0) { _mediaPlayer.equalizer = nil; VLCDefaults.shared.equalizerProfileDisabled = YES; diff --git a/Sources/Playback/Control/VLCPlayerDisplayController.m b/Sources/Playback/Control/VLCPlayerDisplayController.m index 689c2f4cb..8070810ac 100644 --- a/Sources/Playback/Control/VLCPlayerDisplayController.m +++ b/Sources/Playback/Control/VLCPlayerDisplayController.m @@ -483,7 +483,6 @@ NSString *const VLCPlayerDisplayControllerHideMiniPlayer = @"VLCPlayerDisplayCon } // Properly set the shuffle and repeat mode - NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults]; if (VLCDefaults.shared.playerShouldRememberState) { _playbackController.shuffleMode = VLCDefaults.shared.playerIsShuffleEnabled; _playbackController.repeatMode = VLCDefaults.shared.playerIsRepeatEnabled; -- GitLab From ca7c78daa7c11d3ec601fc37aa8f4da4ba6de328 Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Wed, 26 Feb 2025 10:19:30 -0500 Subject: [PATCH 71/97] Convert KVLCPlayerBrightness --- Sources/Headers/VLCConstants.h | 1 - Sources/Helpers/VLCDefaults.swift | 17 +++++++++++++++++ .../Playback/Player/PlayerViewController.swift | 14 +++++--------- .../VideoPlayer-iOS/MediaScrubProgressBar.swift | 1 - .../VideoPlayer-iOS/PlayerController.swift | 4 ---- .../VideoPlayerViewController.swift | 16 ++++++---------- .../Controller/PasscodeLockController.swift | 1 - 7 files changed, 28 insertions(+), 26 deletions(-) diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index bc2fc479c..d103fb21f 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -36,7 +36,6 @@ #define kVLCLastPlayedMediaIdentifier @"LastPlayedMediaIdentifier" #define kVLCPlayerOpenInMiniPlayer @"OpenInMiniPlayer" -#define KVLCPlayerBrightness @"playerbrightness" #define kVLCCustomProfileEnabled @"kVLCCustomProfileEnabled" #define kVLCCustomEqualizerProfiles @"kVLCCustomEqualizerProfiles" diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index bdf3450e6..228e92cfc 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -585,6 +585,22 @@ extension VLCDefaults { } } + var playerBrightness: Float? { + get { + // Use data(forKey:) to determine if a value has been set at all + userDefaults.data(forKey: Keys.playerBrightness).flatMap { _ in + userDefaults.float(forKey: Keys.playerBrightness) + } + } + set { + if let newValue = newValue { + userDefaults.set(newValue, forKey: Keys.playerBrightness) + } else { + userDefaults.removeObject(forKey: Keys.playerBrightness) + } + } + } + @objc var playerControlDuration: Int { get { userDefaults.integer(forKey: Keys.playerControlDuration) @@ -852,6 +868,7 @@ fileprivate enum Keys { static let playbackLongTouchSpeedUp = "LongTouchSpeedUp" static let playbackSpeedDefaultValue = "playback-speed" static let playbackTapSwipeEqual = "playback-tap-swipe-equal" + static let playerBrightness = "playerbrightness" static let playerControlDuration = "kVLCSettingPlayerControlDuration" static let playerIsRepeatEnabled = "PlayerIsRepeatEnabled" static let playerIsShuffleEnabled = "PlayerIsShuffleEnabled" diff --git a/Sources/Playback/Player/PlayerViewController.swift b/Sources/Playback/Player/PlayerViewController.swift index 7be4475ec..44c4e9270 100644 --- a/Sources/Playback/Player/PlayerViewController.swift +++ b/Sources/Playback/Player/PlayerViewController.swift @@ -314,8 +314,6 @@ class PlayerViewController: UIViewController { private let notificationCenter = NotificationCenter.default - private let userDefaults = UserDefaults.standard - // MARK: - Gestures lazy var panRecognizer: UIPanGestureRecognizer = { @@ -436,8 +434,8 @@ class PlayerViewController: UIViewController { super.viewDidAppear(animated) if playerController.isRememberBrightnessEnabled && self is VideoPlayerViewController { - if let brightness = userDefaults.value(forKey: KVLCPlayerBrightness) as? CGFloat { - animateBrightness(to: brightness) + if let brightness = VLCDefaults.shared.playerBrightness { + animateBrightness(to: CGFloat(brightness)) self.brightnessControl.value = Float(brightness) } } @@ -458,9 +456,9 @@ class PlayerViewController: UIViewController { super.viewDidDisappear(animated) if playerController.isRememberBrightnessEnabled && self is VideoPlayerViewController { - let currentBrightness = UIScreen.main.brightness - self.brightnessControl.value = Float(currentBrightness) // helper in indicating change in the system brightness - userDefaults.set(currentBrightness, forKey: KVLCPlayerBrightness) + let currentBrightness = Float(UIScreen.main.brightness) + self.brightnessControl.value = currentBrightness // helper in indicating change in the system brightness + VLCDefaults.shared.playerBrightness = currentBrightness } //set the value of system brightness after closing the app //even if the Player Should Remember Brightness option is disabled @@ -736,8 +734,6 @@ class PlayerViewController: UIViewController { } private func setupSeekDurations() { - let defaults = UserDefaults.standard - tapSwipeEqual = VLCDefaults.shared.playbackTapSwipeEqual forwardBackwardEqual = VLCDefaults.shared.playbackForwardBackwardEqual seekForwardBy = VLCDefaults.shared.playbackForwardSkipLength diff --git a/Sources/Playback/Player/VideoPlayer-iOS/MediaScrubProgressBar.swift b/Sources/Playback/Player/VideoPlayer-iOS/MediaScrubProgressBar.swift index 2746a44c6..ecf7f0dd1 100644 --- a/Sources/Playback/Player/VideoPlayer-iOS/MediaScrubProgressBar.swift +++ b/Sources/Playback/Player/VideoPlayer-iOS/MediaScrubProgressBar.swift @@ -149,7 +149,6 @@ class MediaScrubProgressBar: UIStackView { } @objc private func handleAccessibilityBackward() -> Bool { - let defaults = UserDefaults.standard playbackService.jumpBackward(Int32(VLCDefaults.shared.playbackBackwardSkipLength)) return true } diff --git a/Sources/Playback/Player/VideoPlayer-iOS/PlayerController.swift b/Sources/Playback/Player/VideoPlayer-iOS/PlayerController.swift index efcddd114..8a9ee49e9 100644 --- a/Sources/Playback/Player/VideoPlayer-iOS/PlayerController.swift +++ b/Sources/Playback/Player/VideoPlayer-iOS/PlayerController.swift @@ -89,10 +89,6 @@ class PlayerController: NSObject { setupObservers() } - func updateUserDefaults() { - - } - private func setupObservers() { let notificationCenter = NotificationCenter.default diff --git a/Sources/Playback/Player/VideoPlayer-iOS/VideoPlayerViewController.swift b/Sources/Playback/Player/VideoPlayer-iOS/VideoPlayerViewController.swift index 6556eda4b..e69f0972d 100644 --- a/Sources/Playback/Player/VideoPlayer-iOS/VideoPlayerViewController.swift +++ b/Sources/Playback/Player/VideoPlayer-iOS/VideoPlayerViewController.swift @@ -401,11 +401,10 @@ class VideoPlayerViewController: PlayerViewController { super.viewDidAppear(animated) #if os(iOS) - let defaults = UserDefaults.standard if VLCDefaults.shared.playerShouldRememberBrightness { - if let brightness = defaults.value(forKey: KVLCPlayerBrightness) as? CGFloat { - animateBrightness(to: brightness) - self.brightnessControl.value = Float(brightness) + if let brightness = VLCDefaults.shared.playerBrightness { + animateBrightness(to: CGFloat(brightness)) + self.brightnessControl.value = brightness } } #endif @@ -468,11 +467,10 @@ class VideoPlayerViewController: PlayerViewController { super.viewDidDisappear(animated) deviceMotion.stopDeviceMotion() #if os(iOS) - let defaults = UserDefaults.standard if VLCDefaults.shared.playerShouldRememberBrightness { - let currentBrightness = UIScreen.main.brightness - self.brightnessControl.value = Float(currentBrightness) // helper in indicating change in the system brightness - defaults.set(currentBrightness, forKey: KVLCPlayerBrightness) + let currentBrightness = Float(UIScreen.main.brightness) + self.brightnessControl.value = currentBrightness // helper in indicating change in the system brightness + VLCDefaults.shared.playerBrightness = currentBrightness } //set the value of system brightness after closing the app x @@ -865,8 +863,6 @@ class VideoPlayerViewController: PlayerViewController { } private func setupSeekDurations() { - let defaults = UserDefaults.standard - tapSwipeEqual = VLCDefaults.shared.playbackTapSwipeEqual forwardBackwardEqual = VLCDefaults.shared.playbackForwardBackwardEqual seekForwardBy = VLCDefaults.shared.playbackForwardSkipLength diff --git a/Sources/Settings/Controller/PasscodeLockController.swift b/Sources/Settings/Controller/PasscodeLockController.swift index 6bfedb1a3..dc76f7855 100644 --- a/Sources/Settings/Controller/PasscodeLockController.swift +++ b/Sources/Settings/Controller/PasscodeLockController.swift @@ -24,7 +24,6 @@ enum PasscodeAction { class PasscodeLockController: UIViewController { // - MARK: Properties - private let userDefaults = UserDefaults.standard private let notificationCenter = NotificationCenter.default let action: PasscodeAction -- GitLab From eae2ff07d38110d58993083e164085526b478afa Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Wed, 26 Feb 2025 10:30:31 -0500 Subject: [PATCH 72/97] Convert kVLCHasNaggedThisMonth --- Sources/Donation/VLCStripeController.m | 3 ++- Sources/Headers/VLCConstants.h | 1 - Sources/Helpers/VLCDefaults.swift | 11 +++++++++++ .../MediaCategories/MediaCategoryViewController.swift | 4 ++-- .../Player/VideoPlayer-iOS/PlayerController.swift | 2 +- 5 files changed, 16 insertions(+), 5 deletions(-) diff --git a/Sources/Donation/VLCStripeController.m b/Sources/Donation/VLCStripeController.m index 1e8b3e7ae..854d2f4fe 100644 --- a/Sources/Donation/VLCStripeController.m +++ b/Sources/Donation/VLCStripeController.m @@ -20,6 +20,7 @@ #import "VLCSubscription.h" #import "VLCDonationInvoicesViewController.h" #import "VLCDonationViewController.h" +#import "VLC-Swift.h" const NSString *publishableStripeAPIKey = @""; const NSString *secretStripeAPIKey = @""; @@ -708,7 +709,7 @@ NSString *callbackURLString = @"vlcpay://3ds"; nextReminderMonth = currentMonth + 3; } - [[NSUserDefaults standardUserDefaults] setInteger:nextReminderMonth forKey:kVLCHasNaggedThisMonth]; + VLCDefaults.shared.hasNaggedThisMonth = nextReminderMonth; } - (void)activeSubscription:(BOOL)bValue diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index d103fb21f..2b3f2d069 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -76,7 +76,6 @@ #define kVLCSortDefault @"SortDefault" #define kVLCSortDescendingDefault @"SortDescendingDefault" -#define kVLCHasNaggedThisMonth @"kVLCHasNaggedThisMonth" #define kVLCNumberOfLaunches @"kVLCNumberOfLaunches" #define kVLCHasActiveSubscription @"kVLCHasActiveSubscription" diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index 228e92cfc..06d410998 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -68,6 +68,7 @@ Keys.defaultPreampLevel: Float(6), Keys.deinterlace: DefaultValues.deinterlace, Keys.equalizerProfile: DefaultValues.equalizerProfile, + Keys.hasNaggedThisMonth: 0, Keys.playbackBackwardSkipLength: DefaultValues.playbackBackwardSkipLength, Keys.playbackBackwardSkipLengthSwipe: DefaultValues.playbackBackwardSkipLengthSwipe, Keys.playbackForwardSkipLength: DefaultValues.playbackForwardSkipLength, @@ -540,6 +541,15 @@ extension VLCDefaults { } } + @objc var hasNaggedThisMonth: Int { + get { + userDefaults.integer(forKey: Keys.hasNaggedThisMonth) + } + set { + userDefaults.set(newValue, forKey: Keys.hasNaggedThisMonth) + } + } + @objc var playbackBackwardSkipLength: Int { get { userDefaults.integer(forKey: Keys.playbackBackwardSkipLength) @@ -853,6 +863,7 @@ fileprivate enum Keys { static let forceSMBV1 = "smb-force-v1" static let hardwareDecoding = "codec" static let hasLaunchedBefore = "hasLaunchedBefore" + static let hasNaggedThisMonth = "kVLCHasNaggedThisMonth" static let hideLibraryInFilesApp = "HideLibraryInFilesApp" static let mediaLibraryServiceDidForceRescan = "MediaLibraryDidForceRescan" static let networkCaching = "network-caching" diff --git a/Sources/Media Library/MediaCategories/MediaCategoryViewController.swift b/Sources/Media Library/MediaCategories/MediaCategoryViewController.swift index 2c31c2c90..4530ae11d 100644 --- a/Sources/Media Library/MediaCategories/MediaCategoryViewController.swift +++ b/Sources/Media Library/MediaCategories/MediaCategoryViewController.swift @@ -610,7 +610,7 @@ class MediaCategoryViewController: UICollectionViewController, UISearchBarDelega return } - var lastNagMonth = userDefaults.integer(forKey: kVLCHasNaggedThisMonth) + var lastNagMonth = VLCDefaults.shared.hasNaggedThisMonth let numberOfLaunches = userDefaults.integer(forKey: kVLCNumberOfLaunches) let currentMonth = NSCalendar.current.component(.month, from: Date()) @@ -619,7 +619,7 @@ class MediaCategoryViewController: UICollectionViewController, UISearchBarDelega } if lastNagMonth < currentMonth && numberOfLaunches >= 5 { - userDefaults.setValue(currentMonth, forKey: kVLCHasNaggedThisMonth) + VLCDefaults.shared.hasNaggedThisMonth = currentMonth userDefaults.setValue(0, forKey: kVLCNumberOfLaunches) let donationVC = VLCDonationNagScreenViewController(nibName: "VLCDonationNagScreenViewController", bundle: nil) let donationNC = UINavigationController(rootViewController: donationVC) diff --git a/Sources/Playback/Player/VideoPlayer-iOS/PlayerController.swift b/Sources/Playback/Player/VideoPlayer-iOS/PlayerController.swift index 8a9ee49e9..978c7dc50 100644 --- a/Sources/Playback/Player/VideoPlayer-iOS/PlayerController.swift +++ b/Sources/Playback/Player/VideoPlayer-iOS/PlayerController.swift @@ -38,7 +38,7 @@ class PlayerController: NSObject { var isTapSeeking: Bool = false - // MARK: - UserDefaults computed properties getters + // MARK: - Defaults computed properties getters var displayRemainingTime: Bool { return VLCDefaults.shared.showRemainingTime -- GitLab From e40ead252354b42a7ae855b1ff76a6e5acb23f10 Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Wed, 26 Feb 2025 11:25:03 -0500 Subject: [PATCH 73/97] Convert kVLCCustomEqualizerProfiles --- Sources/Headers/VLCConstants.h | 1 - Sources/Helpers/VLCDefaults.swift | 28 +++++++++++++++++++ .../MiniPlayer-iOS/AudioMiniPlayer.swift | 4 +-- .../Player/PlayerViewController.swift | 4 +-- .../Subviews/EqualizerPresetSelector.swift | 19 ++++--------- .../Subviews/EqualizerView.swift | 24 ++++++---------- .../VideoPlayerViewController.swift | 4 +-- 7 files changed, 44 insertions(+), 40 deletions(-) diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index 2b3f2d069..d40ded681 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -38,7 +38,6 @@ #define kVLCPlayerOpenInMiniPlayer @"OpenInMiniPlayer" #define kVLCCustomProfileEnabled @"kVLCCustomProfileEnabled" -#define kVLCCustomEqualizerProfiles @"kVLCCustomEqualizerProfiles" #define kSupportedFileExtensions @"\\.(669|3g2|3gp|3gp2|3gpp|amv|asf|avi|bik|bin|crf|divx|drc|dv|evo|f4v|far|flv|gvi|gxf|hevc|iso|it|m1v|m2v|m2t|m2ts|m4v|mkv|mov|mp2|mp2v|mp4|mp4v|mpe|mpeg|mpeg1|mpeg2|mpeg4|mpg|mpv2|mtm|mts|mtv|mxf|mxg|nsv|nuv|ogg|ogm|ogv|ogx|ps|rec|rm|rmvb|rpl|s3m|thp|tod|ts|tts|txd|vlc|vob|vro|webm|wm|wmv|wtv|xesc|xm)$" #define kSupportedSubtitleFileExtensions @"\\.(cdg|idx|srt|sub|utf|ass|ssa|aqt|jss|psb|rt|smi|txt|smil|stl|usf|dks|pjs|mpl2|mks|vtt|ttml|dfxp)$" diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index 06d410998..d6c2ac095 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -645,6 +645,33 @@ extension VLCDefaults { appTheme == .system } + var customEqualizerProfiles: CustomEqualizerProfiles? { + get { + guard let encodedData = userDefaults.data(forKey: Keys.customEqualizerProfiles) else { + return nil + } + + guard let decoded = try? NSKeyedUnarchiver(forReadingFrom: encodedData) + .decodeObject(forKey: "root") as? CustomEqualizerProfiles else { + return nil + } + + return decoded + } + set { + guard let newValue = newValue else { + return + } + + guard let encoded = try? NSKeyedArchiver + .archivedData(withRootObject: newValue, requiringSecureCoding: false) else { + return + } + + userDefaults.setValue(encoded, forKey: Keys.customEqualizerProfiles) + } + } + var hardwareDecoding: HardwareDecoding { get { guard let v = userDefaults.string(forKey: Keys.hardwareDecoding) else { @@ -854,6 +881,7 @@ fileprivate enum Keys { static let continueAudioPlayback = "ContinueAudioPlayback" static let continuePlayback = "ContinuePlayback" static let currentlyPlayingPlaylist = "isPlaylistCurrentlyPlaying" + static let customEqualizerProfiles = "kVLCCustomEqualizerProfiles" static let defaultPreampLevel = "pre-amp-level" static let deinterlace = "deinterlace" static let downloadArtwork = "download-artwork" diff --git a/Sources/Playback/Player/MiniPlayer-iOS/AudioMiniPlayer.swift b/Sources/Playback/Player/MiniPlayer-iOS/AudioMiniPlayer.swift index 87a0304f7..ab9b5d3df 100644 --- a/Sources/Playback/Player/MiniPlayer-iOS/AudioMiniPlayer.swift +++ b/Sources/Playback/Player/MiniPlayer-iOS/AudioMiniPlayer.swift @@ -171,10 +171,8 @@ private extension AudioMiniPlayer { } let profileIndex = VLCDefaults.shared.equalizerProfile - let encodedData = userDefaults.data(forKey: kVLCCustomEqualizerProfiles) - guard let encodedData = encodedData, - let customProfiles = NSKeyedUnarchiver(forReadingWith: encodedData).decodeObject(forKey: "root") as? CustomEqualizerProfiles, + guard let customProfiles = VLCDefaults.shared.customEqualizerProfiles, profileIndex < customProfiles.profiles.count else { return } diff --git a/Sources/Playback/Player/PlayerViewController.swift b/Sources/Playback/Player/PlayerViewController.swift index 44c4e9270..6f6fb5c70 100644 --- a/Sources/Playback/Player/PlayerViewController.swift +++ b/Sources/Playback/Player/PlayerViewController.swift @@ -762,10 +762,8 @@ class PlayerViewController: UIViewController { } let profileIndex = VLCDefaults.shared.equalizerProfile - let encodedData = userDefaults.data(forKey: kVLCCustomEqualizerProfiles) - guard let encodedData = encodedData, - let customProfiles = NSKeyedUnarchiver(forReadingWith: encodedData).decodeObject(forKey: "root") as? CustomEqualizerProfiles, + guard let customProfiles = VLCDefaults.shared.customEqualizerProfiles, profileIndex < customProfiles.profiles.count else { return } diff --git a/Sources/Playback/Player/VideoPlayer-iOS/Subviews/EqualizerPresetSelector.swift b/Sources/Playback/Player/VideoPlayer-iOS/Subviews/EqualizerPresetSelector.swift index f26875a6b..4faac0a26 100644 --- a/Sources/Playback/Player/VideoPlayer-iOS/Subviews/EqualizerPresetSelector.swift +++ b/Sources/Playback/Player/VideoPlayer-iOS/Subviews/EqualizerPresetSelector.swift @@ -102,9 +102,7 @@ class EqualizerPresetSelector: SpoilerButton, UITableViewDataSource, UITableView // MARK: - table view data source func numberOfSections(in tableView: UITableView) -> Int { - let profilesData = UserDefaults.standard.data(forKey: kVLCCustomEqualizerProfiles) - guard let profilesData = profilesData, - let customProfiles = NSKeyedUnarchiver(forReadingWith: profilesData).decodeObject(forKey: "root") as? CustomEqualizerProfiles else { + guard let customProfiles = VLCDefaults.shared.customEqualizerProfiles else { return 1 } @@ -117,9 +115,7 @@ class EqualizerPresetSelector: SpoilerButton, UITableViewDataSource, UITableView return profiles.count + 1 } - let profilesData = UserDefaults.standard.data(forKey: kVLCCustomEqualizerProfiles) - guard let profilesData = profilesData, - let customProfiles = NSKeyedUnarchiver(forReadingWith: profilesData).decodeObject(forKey: "root") as? CustomEqualizerProfiles else { + guard let customProfiles = VLCDefaults.shared.customEqualizerProfiles else { return 0 } @@ -137,9 +133,7 @@ class EqualizerPresetSelector: SpoilerButton, UITableViewDataSource, UITableView cell.textLabel?.text = profiles[indexPath.row - 1].name } } else { - let profilesData = UserDefaults.standard.data(forKey: kVLCCustomEqualizerProfiles) - guard let profilesData = profilesData, - let customProfiles = NSKeyedUnarchiver(forReadingWith: profilesData).decodeObject(forKey: "root") as? CustomEqualizerProfiles else { + guard let customProfiles = VLCDefaults.shared.customEqualizerProfiles else { return cell } @@ -232,10 +226,7 @@ class EqualizerPresetSelector: SpoilerButton, UITableViewDataSource, UITableView } func moveProfile(_ moveIdentifier: MoveEventIdentifier, at index: IndexPath) { - let userDefaults = UserDefaults.standard - let profilesData = userDefaults.data(forKey: kVLCCustomEqualizerProfiles) - guard let profilesData = profilesData, - let customProfiles = NSKeyedUnarchiver(forReadingWith: profilesData).decodeObject(forKey: "root") as? CustomEqualizerProfiles else { + guard let customProfiles = VLCDefaults.shared.customEqualizerProfiles else { return } @@ -245,7 +236,7 @@ class EqualizerPresetSelector: SpoilerButton, UITableViewDataSource, UITableView customProfiles.moveDown(index: index.row) } - userDefaults.setValue(NSKeyedArchiver.archivedData(withRootObject: customProfiles), forKey: kVLCCustomEqualizerProfiles) + VLCDefaults.shared.customEqualizerProfiles = customProfiles } } diff --git a/Sources/Playback/Player/VideoPlayer-iOS/Subviews/EqualizerView.swift b/Sources/Playback/Player/VideoPlayer-iOS/Subviews/EqualizerView.swift index 79e2b5d2f..51d558c07 100644 --- a/Sources/Playback/Player/VideoPlayer-iOS/Subviews/EqualizerView.swift +++ b/Sources/Playback/Player/VideoPlayer-iOS/Subviews/EqualizerView.swift @@ -447,11 +447,9 @@ extension EqualizerView { let preAmplification = self.playbackService.preAmplification let customProfile = CustomEqualizerProfile(name: name, preAmpLevel: Float(preAmplification), frequencies: frequencies) - let encodedProfiles = UserDefaults.standard.data(forKey: kVLCCustomEqualizerProfiles) - var customProfiles: CustomEqualizerProfiles + let customProfiles: CustomEqualizerProfiles - if let encodedProfiles = encodedProfiles, - let profiles = NSKeyedUnarchiver(forReadingWith: encodedProfiles).decodeObject(forKey: "root") as? CustomEqualizerProfiles { + if let profiles = VLCDefaults.shared.customEqualizerProfiles { profiles.profiles.append(customProfile) customProfiles = profiles } else { @@ -459,8 +457,8 @@ extension EqualizerView { } let index = customProfiles.profiles.count - 1 + VLCDefaults.shared.customEqualizerProfiles = customProfiles let userDefaults = UserDefaults.standard - userDefaults.setValue(NSKeyedArchiver.archivedData(withRootObject: customProfiles), forKey: kVLCCustomEqualizerProfiles) userDefaults.setValue(true, forKey: kVLCCustomProfileEnabled) VLCDefaults.shared.equalizerProfileDisabled = false VLCDefaults.shared.equalizerProfile = index @@ -503,10 +501,8 @@ extension EqualizerView { private func applyCustomProfile(_ index: Int) { let userDefaults = UserDefaults.standard - let encodedData = userDefaults.data(forKey: kVLCCustomEqualizerProfiles) - guard let encodedData = encodedData, - let customProfiles = NSKeyedUnarchiver(forReadingWith: encodedData).decodeObject(forKey: "root") as? CustomEqualizerProfiles, + guard let customProfiles = VLCDefaults.shared.customEqualizerProfiles, index < customProfiles.profiles.count else { return } @@ -558,15 +554,13 @@ extension EqualizerView: EqualizerPresetSelectorDelegate { if type == .delete { action = UIAlertAction(title: NSLocalizedString("BUTTON_DELETE", comment: ""), style: .destructive) { _ in - let customEncodedProfiles = UserDefaults.standard.data(forKey: kVLCCustomEqualizerProfiles) - guard let customEncodedProfiles = customEncodedProfiles, - var customProfiles = NSKeyedUnarchiver(forReadingWith: customEncodedProfiles).decodeObject(forKey: "root") as? CustomEqualizerProfiles, + guard var customProfiles = VLCDefaults.shared.customEqualizerProfiles, index.row < customProfiles.profiles.count else { return } customProfiles.profiles.remove(at: index.row) - UserDefaults.standard.setValue(NSKeyedArchiver.archivedData(withRootObject: customProfiles), forKey: kVLCCustomEqualizerProfiles) + VLCDefaults.shared.customEqualizerProfiles = customProfiles self.presetSelectorView?.presetsTableView.reloadData() } } else { @@ -576,9 +570,7 @@ extension EqualizerView: EqualizerPresetSelectorDelegate { } action = UIAlertAction(title: NSLocalizedString("BUTTON_RENAME", comment: ""), style: .default) { _ in - let customEncodedProfiles = UserDefaults.standard.data(forKey: kVLCCustomEqualizerProfiles) - guard let customEncodedProfiles = customEncodedProfiles, - let customProfiles = NSKeyedUnarchiver(forReadingWith: customEncodedProfiles).decodeObject(forKey: "root") as? CustomEqualizerProfiles, + guard let customProfiles = VLCDefaults.shared.customEqualizerProfiles, index.row < customProfiles.profiles.count else { return } @@ -589,7 +581,7 @@ extension EqualizerView: EqualizerPresetSelectorDelegate { } customProfiles.profiles[index.row].name = newName - UserDefaults.standard.setValue(NSKeyedArchiver.archivedData(withRootObject: customProfiles), forKey: kVLCCustomEqualizerProfiles) + VLCDefaults.shared.customEqualizerProfiles = customProfiles self.presetSelectorView?.presetsTableView.reloadData() } } diff --git a/Sources/Playback/Player/VideoPlayer-iOS/VideoPlayerViewController.swift b/Sources/Playback/Player/VideoPlayer-iOS/VideoPlayerViewController.swift index e69f0972d..5427a3d9e 100644 --- a/Sources/Playback/Player/VideoPlayer-iOS/VideoPlayerViewController.swift +++ b/Sources/Playback/Player/VideoPlayer-iOS/VideoPlayerViewController.swift @@ -1386,10 +1386,8 @@ class VideoPlayerViewController: PlayerViewController { } let profileIndex = VLCDefaults.shared.equalizerProfile - let encodedData = userDefaults.data(forKey: kVLCCustomEqualizerProfiles) - guard let encodedData = encodedData, - let customProfiles = NSKeyedUnarchiver(forReadingWith: encodedData).decodeObject(forKey: "root") as? CustomEqualizerProfiles, + guard let customProfiles = VLCDefaults.shared.customEqualizerProfiles, profileIndex < customProfiles.profiles.count else { return } -- GitLab From 6d43bb720985d7236c7bb46e1e0df1e5c941e266 Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Wed, 26 Feb 2025 11:32:23 -0500 Subject: [PATCH 74/97] Convert kVLCCustomProfileEnabled --- Sources/Headers/VLCConstants.h | 2 -- Sources/Helpers/VLCDefaults.swift | 11 +++++++++++ Sources/Playback/Control/VLCPlaybackService.m | 8 ++++---- .../Player/MiniPlayer-iOS/AudioMiniPlayer.swift | 2 +- Sources/Playback/Player/PlayerViewController.swift | 3 +-- .../Subviews/CustomEqualizerProfiles.swift | 6 ++---- .../Subviews/EqualizerPresetSelector.swift | 2 +- .../VideoPlayer-iOS/Subviews/EqualizerView.swift | 7 +++---- .../VideoPlayer-iOS/VideoPlayerViewController.swift | 3 +-- 9 files changed, 24 insertions(+), 20 deletions(-) diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index d40ded681..72bb16cf5 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -37,8 +37,6 @@ #define kVLCPlayerOpenInMiniPlayer @"OpenInMiniPlayer" -#define kVLCCustomProfileEnabled @"kVLCCustomProfileEnabled" - #define kSupportedFileExtensions @"\\.(669|3g2|3gp|3gp2|3gpp|amv|asf|avi|bik|bin|crf|divx|drc|dv|evo|f4v|far|flv|gvi|gxf|hevc|iso|it|m1v|m2v|m2t|m2ts|m4v|mkv|mov|mp2|mp2v|mp4|mp4v|mpe|mpeg|mpeg1|mpeg2|mpeg4|mpg|mpv2|mtm|mts|mtv|mxf|mxg|nsv|nuv|ogg|ogm|ogv|ogx|ps|rec|rm|rmvb|rpl|s3m|thp|tod|ts|tts|txd|vlc|vob|vro|webm|wm|wmv|wtv|xesc|xm)$" #define kSupportedSubtitleFileExtensions @"\\.(cdg|idx|srt|sub|utf|ass|ssa|aqt|jss|psb|rt|smi|txt|smil|stl|usf|dks|pjs|mpl2|mks|vtt|ttml|dfxp)$" #define kSupportedAudioFileExtensions @"\\.(3ga|669|a52|aa3|aac|ac3|adt|adts|aif|aifc|aiff|amb|amr|aob|ape|at3|au|awb|caf|dts|flac|it|kar|m4a|m4b|m4p|m5p|mid|mka|mlp|mod|mpa|mp1|mp2|mp3|mpc|mpga|mus|oga|ogg|oma|opus|qcp|ra|rmi|s3m|sid|spx|tak|thd|tta|voc|vqf|w64|wav|wma|wv|xa|xm)$" diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index d6c2ac095..e99db21ba 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -31,6 +31,7 @@ Keys.closeGesture: true, Keys.continueAudioInBackground: true, Keys.currentlyPlayingPlaylist: false, + Keys.customEqualizerProfileEnabled: false, Keys.downloadArtwork: true, Keys.enableMediaCellTextScrolling: false, Keys.equalizerProfileDisabled: true, @@ -213,6 +214,15 @@ extension VLCDefaults { } } + @objc var customEqualizerProfileEnabled: Bool { + get { + userDefaults.bool(forKey: Keys.customEqualizerProfileEnabled) + } + set { + userDefaults.set(newValue, forKey: Keys.customEqualizerProfileEnabled) + } + } + @objc var downloadArtwork: Bool { get { userDefaults.bool(forKey: Keys.downloadArtwork) @@ -881,6 +891,7 @@ fileprivate enum Keys { static let continueAudioPlayback = "ContinueAudioPlayback" static let continuePlayback = "ContinuePlayback" static let currentlyPlayingPlaylist = "isPlaylistCurrentlyPlaying" + static let customEqualizerProfileEnabled = "kVLCCustomProfileEnabled" static let customEqualizerProfiles = "kVLCCustomEqualizerProfiles" static let defaultPreampLevel = "pre-amp-level" static let deinterlace = "deinterlace" diff --git a/Sources/Playback/Control/VLCPlaybackService.m b/Sources/Playback/Control/VLCPlaybackService.m index 8d27666c5..bce55aa48 100644 --- a/Sources/Playback/Control/VLCPlaybackService.m +++ b/Sources/Playback/Control/VLCPlaybackService.m @@ -1464,16 +1464,16 @@ NSString *const VLCLastPlaylistPlayedMedia = @"LastPlaylistPlayedMedia"; { /* this is a bit complex, if the eq is off, we need to return 0 * if it is on, we need to provide the profile + 1 as the UI fakes a "Off" profile in its list */ - NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults]; if (VLCDefaults.shared.equalizerProfileDisabled) { return [NSIndexPath indexPathForRow:0 inSection:0]; } unsigned int actualProfile = (unsigned int)VLCDefaults.shared.equalizerProfile; - if (![userDefaults boolForKey:kVLCCustomProfileEnabled]) { - return [NSIndexPath indexPathForRow:actualProfile + 1 inSection:0]; - } else { + + if (VLCDefaults.shared.customEqualizerProfileEnabled) { return [NSIndexPath indexPathForRow:actualProfile inSection:1]; + } else { + return [NSIndexPath indexPathForRow:actualProfile + 1 inSection:0]; } } #endif diff --git a/Sources/Playback/Player/MiniPlayer-iOS/AudioMiniPlayer.swift b/Sources/Playback/Player/MiniPlayer-iOS/AudioMiniPlayer.swift index ab9b5d3df..8d592e779 100644 --- a/Sources/Playback/Player/MiniPlayer-iOS/AudioMiniPlayer.swift +++ b/Sources/Playback/Player/MiniPlayer-iOS/AudioMiniPlayer.swift @@ -166,7 +166,7 @@ private extension AudioMiniPlayer { private func applyCustomEqualizerProfileIfNeeded() { let userDefaults = UserDefaults.standard - guard userDefaults.bool(forKey: kVLCCustomProfileEnabled) else { + guard VLCDefaults.shared.customEqualizerProfileEnabled else { return } diff --git a/Sources/Playback/Player/PlayerViewController.swift b/Sources/Playback/Player/PlayerViewController.swift index 6f6fb5c70..8d98b0b57 100644 --- a/Sources/Playback/Player/PlayerViewController.swift +++ b/Sources/Playback/Player/PlayerViewController.swift @@ -756,8 +756,7 @@ class PlayerViewController: UIViewController { } private func applyCustomEqualizerProfileIfNeeded() { - let userDefaults = UserDefaults.standard - guard userDefaults.bool(forKey: kVLCCustomProfileEnabled) else { + guard VLCDefaults.shared.customEqualizerProfileEnabled else { return } diff --git a/Sources/Playback/Player/VideoPlayer-iOS/Subviews/CustomEqualizerProfiles.swift b/Sources/Playback/Player/VideoPlayer-iOS/Subviews/CustomEqualizerProfiles.swift index c1a16e4d8..657428ff1 100644 --- a/Sources/Playback/Player/VideoPlayer-iOS/Subviews/CustomEqualizerProfiles.swift +++ b/Sources/Playback/Player/VideoPlayer-iOS/Subviews/CustomEqualizerProfiles.swift @@ -87,8 +87,7 @@ class CustomEqualizerProfiles: NSObject, NSCoding { profiles.swapAt(index, index - 1) - let userDefaults = UserDefaults.standard - if userDefaults.bool(forKey: kVLCCustomProfileEnabled) { + if VLCDefaults.shared.customEqualizerProfileEnabled { let currentProfileIndex = VLCDefaults.shared.equalizerProfile if currentProfileIndex == index { @@ -106,8 +105,7 @@ class CustomEqualizerProfiles: NSObject, NSCoding { profiles.swapAt(index, index + 1) - let userDefaults = UserDefaults.standard - if userDefaults.bool(forKey: kVLCCustomProfileEnabled) { + if VLCDefaults.shared.customEqualizerProfileEnabled { let currentProfileIndex = VLCDefaults.shared.equalizerProfile if currentProfileIndex == index { diff --git a/Sources/Playback/Player/VideoPlayer-iOS/Subviews/EqualizerPresetSelector.swift b/Sources/Playback/Player/VideoPlayer-iOS/Subviews/EqualizerPresetSelector.swift index 4faac0a26..d1165f808 100644 --- a/Sources/Playback/Player/VideoPlayer-iOS/Subviews/EqualizerPresetSelector.swift +++ b/Sources/Playback/Player/VideoPlayer-iOS/Subviews/EqualizerPresetSelector.swift @@ -173,7 +173,7 @@ class EqualizerPresetSelector: SpoilerButton, UITableViewDataSource, UITableView func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { tableView.deselectRow(at: indexPath, animated: false) let isCustomProfile: Bool = indexPath.section == 0 ? false : true - UserDefaults.standard.setValue(isCustomProfile, forKey: kVLCCustomProfileEnabled) + VLCDefaults.shared.customEqualizerProfileEnabled = isCustomProfile delegate?.equalizerPresetSelector(self, didSelectPreset: indexPath.row, isCustom: isCustomProfile) presetsTableView.reloadData() toggleHiddenView() diff --git a/Sources/Playback/Player/VideoPlayer-iOS/Subviews/EqualizerView.swift b/Sources/Playback/Player/VideoPlayer-iOS/Subviews/EqualizerView.swift index 51d558c07..cedc6d2f2 100644 --- a/Sources/Playback/Player/VideoPlayer-iOS/Subviews/EqualizerView.swift +++ b/Sources/Playback/Player/VideoPlayer-iOS/Subviews/EqualizerView.swift @@ -458,8 +458,7 @@ extension EqualizerView { let index = customProfiles.profiles.count - 1 VLCDefaults.shared.customEqualizerProfiles = customProfiles - let userDefaults = UserDefaults.standard - userDefaults.setValue(true, forKey: kVLCCustomProfileEnabled) + VLCDefaults.shared.customEqualizerProfileEnabled = true VLCDefaults.shared.equalizerProfileDisabled = false VLCDefaults.shared.equalizerProfile = index @@ -479,7 +478,7 @@ extension EqualizerView { @objc func resetEqualizer() { let userDefaults = UserDefaults.standard let isEqualizerDisabled = VLCDefaults.shared.equalizerProfileDisabled - let isCustomProfile = userDefaults.bool(forKey: kVLCCustomProfileEnabled) + let isCustomProfile = VLCDefaults.shared.customEqualizerProfileEnabled let profile: Int if !isCustomProfile { @@ -516,7 +515,7 @@ extension EqualizerView { VLCDefaults.shared.equalizerProfile = index VLCDefaults.shared.equalizerProfileDisabled = false - userDefaults.setValue(true, forKey: kVLCCustomProfileEnabled) + VLCDefaults.shared.customEqualizerProfileEnabled = true } private func shouldDisplaySaveButton(_ display: Bool) { diff --git a/Sources/Playback/Player/VideoPlayer-iOS/VideoPlayerViewController.swift b/Sources/Playback/Player/VideoPlayer-iOS/VideoPlayerViewController.swift index 5427a3d9e..f8362f132 100644 --- a/Sources/Playback/Player/VideoPlayer-iOS/VideoPlayerViewController.swift +++ b/Sources/Playback/Player/VideoPlayer-iOS/VideoPlayerViewController.swift @@ -1380,8 +1380,7 @@ class VideoPlayerViewController: PlayerViewController { } private func applyCustomEqualizerProfileIfNeeded() { - let userDefaults = UserDefaults.standard - guard userDefaults.bool(forKey: kVLCCustomProfileEnabled) else { + guard VLCDefaults.shared.customEqualizerProfileEnabled else { return } -- GitLab From 0384060d40c728017d88cc393ca37da1c2f4d3b7 Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Wed, 26 Feb 2025 11:37:32 -0500 Subject: [PATCH 75/97] Convert kVLCEqualizerSnapBands --- Sources/Headers/VLCConstants.h | 2 -- Sources/Helpers/VLCDefaults.swift | 11 +++++++++++ .../VideoPlayer-iOS/Subviews/EqualizerView.swift | 7 ++----- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index 72bb16cf5..1005a008c 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -78,8 +78,6 @@ #define kVLCGroupLayout @"kVLCGroupLayout" -#define kVLCEqualizerSnapBands @"EqualizerSnapBands" - #define kVLCDonationAnonymousCustomerID @"kVLCDonationAnonymousCustomerID" /* LEGACY KEYS, DO NOT USE IN NEW CODE */ diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index e99db21ba..316427770 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -35,6 +35,7 @@ Keys.downloadArtwork: true, Keys.enableMediaCellTextScrolling: false, Keys.equalizerProfileDisabled: true, + Keys.equalizerSnapBands: false, Keys.forceSMBV1: true, Keys.hasLaunchedBefore: false, Keys.hideLibraryInFilesApp: false, @@ -250,6 +251,15 @@ extension VLCDefaults { } } + @objc var equalizerSnapBands: Bool { + get { + userDefaults.bool(forKey: Keys.equalizerSnapBands) + } + set { + userDefaults.set(newValue, forKey: Keys.equalizerSnapBands) + } + } + @objc var forceSMBV1: Bool { get { userDefaults.bool(forKey: Keys.forceSMBV1) @@ -899,6 +909,7 @@ fileprivate enum Keys { static let enableMediaCellTextScrolling = "EnableMediaCellTextScrolling" static let equalizerProfile = "EqualizerProfile" static let equalizerProfileDisabled = "EqualizerDisabled" + static let equalizerSnapBands = "EqualizerSnapBands" static let forceSMBV1 = "smb-force-v1" static let hardwareDecoding = "codec" static let hasLaunchedBefore = "hasLaunchedBefore" diff --git a/Sources/Playback/Player/VideoPlayer-iOS/Subviews/EqualizerView.swift b/Sources/Playback/Player/VideoPlayer-iOS/Subviews/EqualizerView.swift index cedc6d2f2..3d39b2732 100644 --- a/Sources/Playback/Player/VideoPlayer-iOS/Subviews/EqualizerView.swift +++ b/Sources/Playback/Player/VideoPlayer-iOS/Subviews/EqualizerView.swift @@ -214,7 +214,7 @@ import UIKit snapBandsLabel.text = NSLocalizedString("SNAP_BANDS", comment: "") snapBandsLabel.textAlignment = .right snapBandsLabel.setContentHuggingPriority(.required, for: .vertical) - snapBandsSwitch.isOn = UserDefaults.standard.bool(forKey: kVLCEqualizerSnapBands) + snapBandsSwitch.isOn = VLCDefaults.shared.equalizerSnapBands snapBandsSwitch.addTarget(self, action: #selector(snapBandsSwitchDidChangeValue), for: .valueChanged) snapBandsSwitch.setContentHuggingPriority(.required, for: .vertical) snapBandsStackView.addArrangedSubview(snapBandsLabel) @@ -419,7 +419,7 @@ extension EqualizerView { extension EqualizerView { @objc func snapBandsSwitchDidChangeValue(sender: UISwitch) { - UserDefaults.standard.setValue(sender.isOn, forKey: kVLCEqualizerSnapBands) + VLCDefaults.shared.equalizerSnapBands = sender.isOn } } @@ -476,7 +476,6 @@ extension EqualizerView { } @objc func resetEqualizer() { - let userDefaults = UserDefaults.standard let isEqualizerDisabled = VLCDefaults.shared.equalizerProfileDisabled let isCustomProfile = VLCDefaults.shared.customEqualizerProfileEnabled @@ -499,8 +498,6 @@ extension EqualizerView { } private func applyCustomProfile(_ index: Int) { - let userDefaults = UserDefaults.standard - guard let customProfiles = VLCDefaults.shared.customEqualizerProfiles, index < customProfiles.profiles.count else { return -- GitLab From cfeefc990d548a6373a1c08538f6b292b7d05d99 Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Wed, 26 Feb 2025 11:41:06 -0500 Subject: [PATCH 76/97] Convert kVLCSettingRotationLock --- Sources/Headers/VLCConstants.h | 1 - Sources/Helpers/VLCDefaults.swift | 11 +++++++++++ .../Player/MiniPlayer-iOS/AudioMiniPlayer.swift | 1 - .../VideoPlayer-iOS/VideoPlayerViewController.swift | 2 +- Sources/Settings/Model/SettingsSection.swift | 2 +- 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index 1005a008c..f1734a3bb 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -17,7 +17,6 @@ #define kVLCSettingSaveHTTPUploadServerStatus @"isHTTPServerOn" #define kVLCSettingSubtitlesFilePath @"sub-file" #define kVLCSubtitlesCacheFolderName @"cached-subtitles" -#define kVLCSettingRotationLock @"kVLCSettingRotationLock" #define kVLCSaveDebugLogs @"kVLCSaveDebugLogs" #define kVLCSettingNetworkSatIPChannelList @"satip-channelist" #define kVLCSettingNetworkSatIPChannelListCustom @"CustomList" diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index 316427770..972f8eb45 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -54,6 +54,7 @@ Keys.playlistPlayNextItem: true, Keys.playPauseGesture: true, Keys.restoreLastPlayedMedia: true, + Keys.rotationLock: false, Keys.seekGesture: true, Keys.showRemainingTime: false, Keys.showThumbnails: true, @@ -424,6 +425,15 @@ extension VLCDefaults { } } + @objc var rotationLock: Bool { + get { + userDefaults.bool(forKey: Keys.rotationLock) + } + set { + userDefaults.set(newValue, forKey: Keys.rotationLock) + } + } + @objc var seekGesture: Bool { get { userDefaults.bool(forKey: Keys.seekGesture) @@ -940,6 +950,7 @@ fileprivate enum Keys { static let playlistPlayNextItem = "PlaylistPlayNextItem" static let playPauseGesture = "EnablePlayPauseGesture" static let restoreLastPlayedMedia = "RestoreLastPlayedMedia" + static let rotationLock = "kVLCSettingRotationLock" static let seekGesture = "EnableSeekGesture" static let showArtworks = "ShowArtworks" static let showRemainingTime = "show-remaining-time" diff --git a/Sources/Playback/Player/MiniPlayer-iOS/AudioMiniPlayer.swift b/Sources/Playback/Player/MiniPlayer-iOS/AudioMiniPlayer.swift index 8d592e779..5eb0f534f 100644 --- a/Sources/Playback/Player/MiniPlayer-iOS/AudioMiniPlayer.swift +++ b/Sources/Playback/Player/MiniPlayer-iOS/AudioMiniPlayer.swift @@ -165,7 +165,6 @@ private extension AudioMiniPlayer { } private func applyCustomEqualizerProfileIfNeeded() { - let userDefaults = UserDefaults.standard guard VLCDefaults.shared.customEqualizerProfileEnabled else { return } diff --git a/Sources/Playback/Player/VideoPlayer-iOS/VideoPlayerViewController.swift b/Sources/Playback/Player/VideoPlayer-iOS/VideoPlayerViewController.swift index f8362f132..bab5c9a09 100644 --- a/Sources/Playback/Player/VideoPlayer-iOS/VideoPlayerViewController.swift +++ b/Sources/Playback/Player/VideoPlayer-iOS/VideoPlayerViewController.swift @@ -1527,7 +1527,7 @@ extension VideoPlayerViewController { if currentState == .opening { updateAudioInterface(with: playbackService.metadata) - if UserDefaults.standard.bool(forKey: kVLCSettingRotationLock) { + if VLCDefaults.shared.rotationLock { videoPlayerControls.handleRotationLockButton(videoPlayerControls) } } diff --git a/Sources/Settings/Model/SettingsSection.swift b/Sources/Settings/Model/SettingsSection.swift index 5cbf4942f..6c8c0209f 100644 --- a/Sources/Settings/Model/SettingsSection.swift +++ b/Sources/Settings/Model/SettingsSection.swift @@ -524,7 +524,7 @@ enum VideoOptions { static var lockRotation: SettingsItem { .toggle(title: "SETTINGS_LOCK_ROTATION", subtitle: nil, - preferenceKey: kVLCSettingRotationLock) + keyPath: \.rotationLock) } static func section() -> SettingsSection? { -- GitLab From f93735cdfc68ee2342b81c879691c9f9f01937dc Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Wed, 26 Feb 2025 12:04:03 -0500 Subject: [PATCH 77/97] Convert kVLCLastPlayedPlaylist --- Sources/Headers/VLCConstants.h | 1 - Sources/Helpers/VLCDefaults.swift | 28 +++++++++++++++++++ .../MediaCategoryViewController.swift | 9 ++---- 3 files changed, 30 insertions(+), 8 deletions(-) diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index f1734a3bb..e2de82a57 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -13,7 +13,6 @@ #define kVLCSettingPasscodeOnKey @"PasscodeProtection" #define kVLCThemeDidChangeNotification @"themeDidChangeNotfication" -#define kVLCLastPlayedPlaylist @"LastPlayedPlaylist" #define kVLCSettingSaveHTTPUploadServerStatus @"isHTTPServerOn" #define kVLCSettingSubtitlesFilePath @"sub-file" #define kVLCSubtitlesCacheFolderName @"cached-subtitles" diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index 972f8eb45..a87797033 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -719,6 +719,33 @@ extension VLCDefaults { hardwareDecoding.rawValue } + var lastPlayedPlaylist: LastPlayedPlaylistModel? { + get { + guard let encodedData = userDefaults.data(forKey: Keys.lastPlayedPlaylist) else { + return nil + } + + guard let decoded = try? NSKeyedUnarchiver(forReadingFrom: encodedData) + .decodeObject(forKey: "root") as? LastPlayedPlaylistModel else { + return nil + } + + return decoded + } + set { + guard let newValue = newValue else { + return + } + + guard let encoded = try? NSKeyedArchiver + .archivedData(withRootObject: newValue, requiringSecureCoding: false) else { + return + } + + userDefaults.setValue(encoded, forKey: Keys.lastPlayedPlaylist) + } + } + var networkCaching: NetworkCaching { get { let v = userDefaults.integer(forKey: Keys.networkCaching) @@ -925,6 +952,7 @@ fileprivate enum Keys { static let hasLaunchedBefore = "hasLaunchedBefore" static let hasNaggedThisMonth = "kVLCHasNaggedThisMonth" static let hideLibraryInFilesApp = "HideLibraryInFilesApp" + static let lastPlayedPlaylist = "LastPlayedPlaylist" static let mediaLibraryServiceDidForceRescan = "MediaLibraryDidForceRescan" static let networkCaching = "network-caching" static let networkRTSPTCP = "rtsp-tcp" diff --git a/Sources/Media Library/MediaCategories/MediaCategoryViewController.swift b/Sources/Media Library/MediaCategories/MediaCategoryViewController.swift index 4530ae11d..4785798d2 100644 --- a/Sources/Media Library/MediaCategories/MediaCategoryViewController.swift +++ b/Sources/Media Library/MediaCategories/MediaCategoryViewController.swift @@ -202,12 +202,7 @@ class MediaCategoryViewController: UICollectionViewController, UISearchBarDelega }() private var lastPlaylist: LastPlayedPlaylistModel? { - let encodedLastPlaylist = userDefaults.data(forKey: kVLCLastPlayedPlaylist) - guard let encodedData = encodedLastPlaylist, - let lastPlayed = NSKeyedUnarchiver(forReadingWith: encodedData).decodeObject(forKey: "root") as? LastPlayedPlaylistModel else { - return nil - } - return lastPlayed + return VLCDefaults.shared.lastPlayedPlaylist } // Indicating that the current chosen collection to play is playlist, useful for handling Observer @@ -1842,7 +1837,7 @@ extension MediaCategoryViewController { let lastMedia = LastPlayed(identifier: media.identifier(), title: media.title) let playlistInfo = LastPlayedPlaylistModel(identifier: playlistId, title: playlistTitle, lastPlayedMedia: lastMedia) - userDefaults.setValue(NSKeyedArchiver.archivedData(withRootObject: playlistInfo), forKey: kVLCLastPlayedPlaylist) + VLCDefaults.shared.lastPlayedPlaylist = playlistInfo } private func addPlaybackWillStopObserver() { -- GitLab From bebe1892dffaad5e11fa6beb35447ec1df4bb59d Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Wed, 26 Feb 2025 12:09:06 -0500 Subject: [PATCH 78/97] Convert kVLCSettingsDisableGrouping --- Sources/Headers/VLCConstants.h | 2 -- Sources/Helpers/VLCDefaults.swift | 12 ++++++++++++ .../MediaCategoryViewController.swift | 4 ++-- Sources/Settings/Controller/SettingsController.swift | 2 +- Sources/Settings/Model/SettingsSection.swift | 2 +- 5 files changed, 16 insertions(+), 6 deletions(-) diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index e2de82a57..9cac09b6f 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -20,8 +20,6 @@ #define kVLCSettingNetworkSatIPChannelList @"satip-channelist" #define kVLCSettingNetworkSatIPChannelListCustom @"CustomList" #define kVLCSettingsDecrapifyTitles @"MLDecrapifyTitles" -#define kVLCSettingsDisableGrouping @"MLDisableGrouping" -#define kVLCkVLCSettingsDisableGroupingDefaultValue @NO #define kVLCSettingLastUsedSubtitlesSearchLanguage @"kVLCSettingLastUsedSubtitlesSearchLanguage" #define kVLCSettingDisableSubtitles @"kVLCSettingDisableSubtitles" diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index a87797033..75996f312 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -32,6 +32,7 @@ Keys.continueAudioInBackground: true, Keys.currentlyPlayingPlaylist: false, Keys.customEqualizerProfileEnabled: false, + Keys.disableGrouping: false, Keys.downloadArtwork: true, Keys.enableMediaCellTextScrolling: false, Keys.equalizerProfileDisabled: true, @@ -225,6 +226,15 @@ extension VLCDefaults { } } + @objc var disableGrouping: Bool { + get { + userDefaults.bool(forKey: Keys.disableGrouping) + } + set { + userDefaults.set(newValue, forKey: Keys.disableGrouping) + } + } + @objc var downloadArtwork: Bool { get { userDefaults.bool(forKey: Keys.downloadArtwork) @@ -862,6 +872,7 @@ extension VLCDefaults { static let continuePlaybackKey: String = Keys.continuePlayback static let defaultPreampLevelKey: String = Keys.defaultPreampLevel static let deinterlaceKey: String = Keys.deinterlace + static let disableGroupingKey: String = Keys.disableGrouping static let hardwareDecodingKey: String = Keys.hardwareDecoding static let hideLibraryInFilesAppKey: String = Keys.hideLibraryInFilesApp static let networkCachingKey: String = Keys.networkCaching @@ -942,6 +953,7 @@ fileprivate enum Keys { static let customEqualizerProfiles = "kVLCCustomEqualizerProfiles" static let defaultPreampLevel = "pre-amp-level" static let deinterlace = "deinterlace" + static let disableGrouping = "MLDisableGrouping" static let downloadArtwork = "download-artwork" static let enableMediaCellTextScrolling = "EnableMediaCellTextScrolling" static let equalizerProfile = "EqualizerProfile" diff --git a/Sources/Media Library/MediaCategories/MediaCategoryViewController.swift b/Sources/Media Library/MediaCategories/MediaCategoryViewController.swift index 4785798d2..37cd72951 100644 --- a/Sources/Media Library/MediaCategories/MediaCategoryViewController.swift +++ b/Sources/Media Library/MediaCategories/MediaCategoryViewController.swift @@ -229,8 +229,8 @@ class MediaCategoryViewController: UICollectionViewController, UISearchBarDelega videoModel.secondName = model.name if model is MediaGroupViewModel { - self.model = userDefaults.bool(forKey: kVLCSettingsDisableGrouping) ? videoModel : model - self.secondModel = userDefaults.bool(forKey: kVLCSettingsDisableGrouping) ? model : videoModel + self.model = VLCDefaults.shared.disableGrouping ? videoModel : model + self.secondModel = VLCDefaults.shared.disableGrouping ? model : videoModel } else { self.model = model self.secondModel = videoModel diff --git a/Sources/Settings/Controller/SettingsController.swift b/Sources/Settings/Controller/SettingsController.swift index 401fa7920..cf7086793 100644 --- a/Sources/Settings/Controller/SettingsController.swift +++ b/Sources/Settings/Controller/SettingsController.swift @@ -434,7 +434,7 @@ extension SettingsController: SettingsCellDelegate { medialibraryHidingLockSwitchOn(state: isOn) case VLCDefaults.Compat.backupMediaLibraryKey: mediaLibraryBackupActivateSwitchOn(state: isOn) - case kVLCSettingsDisableGrouping: + case VLCDefaults.Compat.disableGroupingKey: medialibraryDisableGroupingSwitchOn(state: isOn) default: break diff --git a/Sources/Settings/Model/SettingsSection.swift b/Sources/Settings/Model/SettingsSection.swift index 6c8c0209f..db5e11ff8 100644 --- a/Sources/Settings/Model/SettingsSection.swift +++ b/Sources/Settings/Model/SettingsSection.swift @@ -667,7 +667,7 @@ enum MediaLibraryOptions { static var disableGrouping: SettingsItem { .toggle(title: "SETTINGS_DISABLE_GROUPING", subtitle: nil, - preferenceKey: kVLCSettingsDisableGrouping) + keyPath: \.disableGrouping) } static var showVideoThumbnails: SettingsItem { -- GitLab From 643e8155ac57d77df056aa3961d7d78f50ac32b9 Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Wed, 26 Feb 2025 12:12:54 -0500 Subject: [PATCH 79/97] Convert kVLCHasActiveSubscription --- Sources/Donation/VLCStripeController.m | 2 +- Sources/Headers/VLCConstants.h | 1 - Sources/Helpers/VLCDefaults.swift | 11 +++++++++++ .../MediaCategories/MediaCategoryViewController.swift | 2 +- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Sources/Donation/VLCStripeController.m b/Sources/Donation/VLCStripeController.m index 854d2f4fe..ed0f13bff 100644 --- a/Sources/Donation/VLCStripeController.m +++ b/Sources/Donation/VLCStripeController.m @@ -714,7 +714,7 @@ NSString *callbackURLString = @"vlcpay://3ds"; - (void)activeSubscription:(BOOL)bValue { - [[NSUserDefaults standardUserDefaults] setBool:bValue forKey:kVLCHasActiveSubscription]; + VLCDefaults.shared.hasActiveSubscription = bValue; } @end diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index 9cac09b6f..136ca0060 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -70,7 +70,6 @@ #define kVLCSortDefault @"SortDefault" #define kVLCSortDescendingDefault @"SortDescendingDefault" #define kVLCNumberOfLaunches @"kVLCNumberOfLaunches" -#define kVLCHasActiveSubscription @"kVLCHasActiveSubscription" #define kVLCGroupLayout @"kVLCGroupLayout" diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index 75996f312..c903864d5 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -38,6 +38,7 @@ Keys.equalizerProfileDisabled: true, Keys.equalizerSnapBands: false, Keys.forceSMBV1: true, + Keys.hasActiveSubscription: false, Keys.hasLaunchedBefore: false, Keys.hideLibraryInFilesApp: false, Keys.mediaLibraryServiceDidForceRescan: false, @@ -280,6 +281,15 @@ extension VLCDefaults { } } + @objc var hasActiveSubscription: Bool { + get { + userDefaults.bool(forKey: Keys.hasActiveSubscription) + } + set { + userDefaults.set(newValue, forKey: Keys.hasActiveSubscription) + } + } + var hasLaunchedBefore: Bool { userDefaults.bool(forKey: Keys.hasLaunchedBefore) } @@ -961,6 +971,7 @@ fileprivate enum Keys { static let equalizerSnapBands = "EqualizerSnapBands" static let forceSMBV1 = "smb-force-v1" static let hardwareDecoding = "codec" + static let hasActiveSubscription = "kVLCHasActiveSubscription" static let hasLaunchedBefore = "hasLaunchedBefore" static let hasNaggedThisMonth = "kVLCHasNaggedThisMonth" static let hideLibraryInFilesApp = "HideLibraryInFilesApp" diff --git a/Sources/Media Library/MediaCategories/MediaCategoryViewController.swift b/Sources/Media Library/MediaCategories/MediaCategoryViewController.swift index 37cd72951..aa9be1975 100644 --- a/Sources/Media Library/MediaCategories/MediaCategoryViewController.swift +++ b/Sources/Media Library/MediaCategories/MediaCategoryViewController.swift @@ -601,7 +601,7 @@ class MediaCategoryViewController: UICollectionViewController, UISearchBarDelega self.present(navigationController, animated: true) VLCDefaults.shared.setHasLaunchedBeforeIfNeeded() } else { - if userDefaults.bool(forKey: kVLCHasActiveSubscription) { + if VLCDefaults.shared.hasActiveSubscription { return } -- GitLab From 06209453b6eb7f57510da068fbb7fdad6eb3554a Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Wed, 26 Feb 2025 15:04:05 -0500 Subject: [PATCH 80/97] Convert kVLCNumberOfLaunches --- Sources/App/iOS/VLCAppDelegate.m | 3 +-- Sources/Headers/VLCConstants.h | 1 - Sources/Helpers/VLCDefaults.swift | 14 ++++++++++++++ .../MediaCategoryViewController.swift | 4 ++-- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/Sources/App/iOS/VLCAppDelegate.m b/Sources/App/iOS/VLCAppDelegate.m index aea0b8e50..5d359783e 100644 --- a/Sources/App/iOS/VLCAppDelegate.m +++ b/Sources/App/iOS/VLCAppDelegate.m @@ -95,8 +95,7 @@ [self configureShortCutItemsWithApplication:application]; - NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; - [defaults setInteger:([defaults integerForKey:kVLCNumberOfLaunches] + 1) forKey:kVLCNumberOfLaunches]; + [VLCDefaults.shared incrementNumberOfLaunches]; return YES; } diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index 136ca0060..1cc6c2a46 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -69,7 +69,6 @@ #define kVLCSortDefault @"SortDefault" #define kVLCSortDescendingDefault @"SortDescendingDefault" -#define kVLCNumberOfLaunches @"kVLCNumberOfLaunches" #define kVLCGroupLayout @"kVLCGroupLayout" diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index c903864d5..04ef511d8 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -74,6 +74,7 @@ Keys.deinterlace: DefaultValues.deinterlace, Keys.equalizerProfile: DefaultValues.equalizerProfile, Keys.hasNaggedThisMonth: 0, + Keys.numberOfLaunches: 0, Keys.playbackBackwardSkipLength: DefaultValues.playbackBackwardSkipLength, Keys.playbackBackwardSkipLengthSwipe: DefaultValues.playbackBackwardSkipLengthSwipe, Keys.playbackForwardSkipLength: DefaultValues.playbackForwardSkipLength, @@ -600,6 +601,18 @@ extension VLCDefaults { } } + @objc var numberOfLaunches: Int { + userDefaults.integer(forKey: Keys.numberOfLaunches) + } + + @objc func incrementNumberOfLaunches() { + userDefaults.set(numberOfLaunches + 1, forKey: Keys.numberOfLaunches) + } + + @objc func resetNumberOfLaunches() { + userDefaults.set(0, forKey: Keys.numberOfLaunches) + } + @objc var playbackBackwardSkipLength: Int { get { userDefaults.integer(forKey: Keys.playbackBackwardSkipLength) @@ -980,6 +993,7 @@ fileprivate enum Keys { static let networkCaching = "network-caching" static let networkRTSPTCP = "rtsp-tcp" static let networkSatIPChannelListUrl = "satip-channellist-url" + static let numberOfLaunches = "kVLCNumberOfLaunches" static let passcodeEnableBiometricAuth = "EnableBiometricAuth" static let pauseWhenShowingControls = "kVLCSettingPauseWhenShowingControls" static let playbackBackwardSkipLength = "playback-backward-skip-length" diff --git a/Sources/Media Library/MediaCategories/MediaCategoryViewController.swift b/Sources/Media Library/MediaCategories/MediaCategoryViewController.swift index aa9be1975..3421b30a1 100644 --- a/Sources/Media Library/MediaCategories/MediaCategoryViewController.swift +++ b/Sources/Media Library/MediaCategories/MediaCategoryViewController.swift @@ -606,7 +606,7 @@ class MediaCategoryViewController: UICollectionViewController, UISearchBarDelega } var lastNagMonth = VLCDefaults.shared.hasNaggedThisMonth - let numberOfLaunches = userDefaults.integer(forKey: kVLCNumberOfLaunches) + let numberOfLaunches = VLCDefaults.shared.numberOfLaunches let currentMonth = NSCalendar.current.component(.month, from: Date()) if lastNagMonth == 12 && currentMonth < 12 { @@ -615,7 +615,7 @@ class MediaCategoryViewController: UICollectionViewController, UISearchBarDelega if lastNagMonth < currentMonth && numberOfLaunches >= 5 { VLCDefaults.shared.hasNaggedThisMonth = currentMonth - userDefaults.setValue(0, forKey: kVLCNumberOfLaunches) + VLCDefaults.shared.resetNumberOfLaunches() let donationVC = VLCDonationNagScreenViewController(nibName: "VLCDonationNagScreenViewController", bundle: nil) let donationNC = UINavigationController(rootViewController: donationVC) donationNC.navigationBar.isHidden = true -- GitLab From 0891a1dcf0f9173c5d842aa11a611071f52fa65c Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Wed, 26 Feb 2025 17:01:55 -0500 Subject: [PATCH 81/97] Convert kVLCSortDescendingDefault --- Sources/Headers/VLCConstants.h | 2 -- Sources/Helpers/VLCDefaults.swift | 16 ++++++++++++++++ .../MediaCategoryViewController.swift | 12 ++++-------- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index 1cc6c2a46..3120eae90 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -68,8 +68,6 @@ #define kVLCWifiAuthentificationBanned 2 #define kVLCSortDefault @"SortDefault" -#define kVLCSortDescendingDefault @"SortDescendingDefault" - #define kVLCGroupLayout @"kVLCGroupLayout" #define kVLCDonationAnonymousCustomerID @"kVLCDonationAnonymousCustomerID" diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index 04ef511d8..ff6d6fc2d 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -879,6 +879,16 @@ extension VLCDefaults { func setAudioLibraryGridLayout(collectionModelName: String? = nil, name: String, isGrid: Bool) { userDefaults.set(isGrid, forKey: Keys.audioLibraryGridLayout(collectionModelName: collectionModelName, name: name)) } + + func sortDescendingDefault(name: String) -> Bool { + let k = Keys.sortDescendingDefault(name: name) + return userDefaults.bool(forKey: k) + } + + func setSortDescendingDefault(name: String, isDescending: Bool) { + let k = Keys.sortDescendingDefault(name: name) + userDefaults.set(isDescending, forKey: k) + } } // MARK: - Compatibility @@ -1043,6 +1053,12 @@ fileprivate enum Keys { "kVLCAudioLibraryGridLayout", collectionModelName, name ].compactMap { $0 }.joined() } + + static func sortDescendingDefault(name: String) -> String { + [ + "SortDescendingDefault", name + ].joined() + } } // MARK: - Default Values diff --git a/Sources/Media Library/MediaCategories/MediaCategoryViewController.swift b/Sources/Media Library/MediaCategories/MediaCategoryViewController.swift index 3421b30a1..34c38866c 100644 --- a/Sources/Media Library/MediaCategories/MediaCategoryViewController.swift +++ b/Sources/Media Library/MediaCategories/MediaCategoryViewController.swift @@ -568,7 +568,7 @@ class MediaCategoryViewController: UICollectionViewController, UISearchBarDelega } else { sortingCriteria = model.sortModel.currentSort } - let desc = UserDefaults.standard.bool(forKey: "\(kVLCSortDescendingDefault)\(model.name)") + let desc = VLCDefaults.shared.sortDescendingDefault(name: model.name) self.model.sort(by: sortingCriteria, desc: desc) } @@ -932,8 +932,7 @@ extension MediaCategoryViewController { @objc func executeSortAction(with sortingCriteria: VLCMLSortingCriteria, desc: Bool) { model.sort(by: sortingCriteria, desc: desc) - userDefaults.set(desc, - forKey: "\(kVLCSortDescendingDefault)\(model.name)") + VLCDefaults.shared.setSortDescendingDefault(name: model.name, isDescending: desc) userDefaults.set(sortingCriteria.rawValue, forKey: "\(kVLCSortDefault)\(model.name)") sortActionSheet.removeActionSheet() @@ -1565,13 +1564,10 @@ extension MediaCategoryViewController: ActionSheetSortSectionHeaderDelegate { } func actionSheetSortSectionHeader(_ header: ActionSheetSortSectionHeader, onSwitchIsOnChange: Bool, type: ActionSheetSortHeaderOptions) { - var prefix: String = "" - var suffix: String = "" if type == .descendingOrder { model.sort(by: model.sortModel.currentSort, desc: onSwitchIsOnChange) - prefix = kVLCSortDescendingDefault - suffix = model is VideoModel ? secondModel.name : model.name - userDefaults.set(onSwitchIsOnChange, forKey: "\(prefix)\(suffix)") + let name = model is VideoModel ? secondModel.name : model.name + VLCDefaults.shared.setSortDescendingDefault(name: name, isDescending: onSwitchIsOnChange) setupCollectionView() cachedCellSize = .zero collectionView?.collectionViewLayout.invalidateLayout() -- GitLab From 6915a7084b3ef4b93633cc18bbf22f8719ab7275 Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Wed, 26 Feb 2025 18:01:44 -0500 Subject: [PATCH 82/97] Convert kVLCSortDefault --- Sources/Headers/VLCConstants.h | 1 - Sources/Helpers/VLCDefaults.swift | 21 +++++++++++++++++++ .../MediaCategoryViewController.swift | 17 ++++++--------- 3 files changed, 27 insertions(+), 12 deletions(-) diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index 3120eae90..fd6163865 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -67,7 +67,6 @@ #define kVLCWifiAuthentificationFailure 1 #define kVLCWifiAuthentificationBanned 2 -#define kVLCSortDefault @"SortDefault" #define kVLCGroupLayout @"kVLCGroupLayout" #define kVLCDonationAnonymousCustomerID @"kVLCDonationAnonymousCustomerID" diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index ff6d6fc2d..87ffa33bc 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -880,6 +880,21 @@ extension VLCDefaults { userDefaults.set(isGrid, forKey: Keys.audioLibraryGridLayout(collectionModelName: collectionModelName, name: name)) } + func sortDefault(name: String) -> VLCMLSortingCriteria? { + let k = Keys.sortDefault(name: name) + + // Use data(forKey:) to determine if a value has been set at all + return userDefaults.data(forKey: k).flatMap { _ in + let v = userDefaults.integer(forKey: k) + return VLCMLSortingCriteria(rawValue: UInt(v)) + } + } + + func setSortDefault(name: String, criteria: VLCMLSortingCriteria) { + let k = Keys.sortDefault(name: name) + userDefaults.set(criteria.rawValue, forKey: k) + } + func sortDescendingDefault(name: String) -> Bool { let k = Keys.sortDescendingDefault(name: name) return userDefaults.bool(forKey: k) @@ -1054,6 +1069,12 @@ fileprivate enum Keys { ].compactMap { $0 }.joined() } + static func sortDefault(name: String) -> String { + [ + "SortDefault", name + ].joined() + } + static func sortDescendingDefault(name: String) -> String { [ "SortDescendingDefault", name diff --git a/Sources/Media Library/MediaCategories/MediaCategoryViewController.swift b/Sources/Media Library/MediaCategories/MediaCategoryViewController.swift index 34c38866c..0d4dfe56f 100644 --- a/Sources/Media Library/MediaCategories/MediaCategoryViewController.swift +++ b/Sources/Media Library/MediaCategories/MediaCategoryViewController.swift @@ -40,7 +40,6 @@ class MediaCategoryViewController: UICollectionViewController, UISearchBarDelega private var searchBarConstraint: NSLayoutConstraint? private var searchDataSource: LibrarySearchDataSource private let searchBarSize: CGFloat = 50.0 - private let userDefaults = UserDefaults.standard #if os(iOS) private var rendererButton: UIButton #endif @@ -562,12 +561,7 @@ class MediaCategoryViewController: UICollectionViewController, UISearchBarDelega } func loadSort() { - let sortingCriteria: VLCMLSortingCriteria - if let sortingCriteriaDefault = UserDefaults.standard.value(forKey: "\(kVLCSortDefault)\(model.name)") as? UInt { - sortingCriteria = VLCMLSortingCriteria(rawValue: sortingCriteriaDefault) ?? model.sortModel.currentSort - } else { - sortingCriteria = model.sortModel.currentSort - } + let sortingCriteria = VLCDefaults.shared.sortDefault(name: model.name) ?? model.sortModel.currentSort let desc = VLCDefaults.shared.sortDescendingDefault(name: model.name) self.model.sort(by: sortingCriteria, desc: desc) } @@ -933,8 +927,7 @@ extension MediaCategoryViewController { @objc func executeSortAction(with sortingCriteria: VLCMLSortingCriteria, desc: Bool) { model.sort(by: sortingCriteria, desc: desc) VLCDefaults.shared.setSortDescendingDefault(name: model.name, isDescending: desc) - userDefaults.set(sortingCriteria.rawValue, - forKey: "\(kVLCSortDefault)\(model.name)") + VLCDefaults.shared.setSortDefault(name: model.name, criteria: sortingCriteria) sortActionSheet.removeActionSheet() reloadData() } @@ -1564,7 +1557,8 @@ extension MediaCategoryViewController: ActionSheetSortSectionHeaderDelegate { } func actionSheetSortSectionHeader(_ header: ActionSheetSortSectionHeader, onSwitchIsOnChange: Bool, type: ActionSheetSortHeaderOptions) { - if type == .descendingOrder { + switch type { + case .descendingOrder: model.sort(by: model.sortModel.currentSort, desc: onSwitchIsOnChange) let name = model is VideoModel ? secondModel.name : model.name VLCDefaults.shared.setSortDescendingDefault(name: name, isDescending: onSwitchIsOnChange) @@ -1572,7 +1566,8 @@ extension MediaCategoryViewController: ActionSheetSortSectionHeaderDelegate { cachedCellSize = .zero collectionView?.collectionViewLayout.invalidateLayout() reloadData() - } else if type == .layoutChange { + + case .layoutChange: handleLayoutChange(gridLayout: onSwitchIsOnChange) } } -- GitLab From d1193105ec0544c94eb2b3dce19fadba8f9a7bc6 Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Wed, 26 Feb 2025 18:10:37 -0500 Subject: [PATCH 83/97] Convert kVLCSettingPasscodeOnKey --- Sources/Headers/VLCConstants.h | 1 - Sources/Helpers/VLCDefaults.swift | 12 ++++++++++++ Sources/Settings/Controller/SettingsController.swift | 4 ++-- Sources/Settings/Model/SettingsSection.swift | 2 +- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index fd6163865..e91c6ddd2 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -11,7 +11,6 @@ * Refer to the COPYING file of the official project for license. *****************************************************************************/ -#define kVLCSettingPasscodeOnKey @"PasscodeProtection" #define kVLCThemeDidChangeNotification @"themeDidChangeNotfication" #define kVLCSettingSaveHTTPUploadServerStatus @"isHTTPServerOn" #define kVLCSettingSubtitlesFilePath @"sub-file" diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index 87ffa33bc..ace619e65 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -44,6 +44,7 @@ Keys.mediaLibraryServiceDidForceRescan: false, Keys.networkRTSPTCP: false, Keys.passcodeEnableBiometricAuth: true, + Keys.passcodeOn: false, Keys.pauseWhenShowingControls: false, Keys.playbackForwardBackwardEqual: true, Keys.playbackLongTouchSpeedUp: true, @@ -400,6 +401,15 @@ extension VLCDefaults { } } + @objc var passcodeOn: Bool { + get { + userDefaults.bool(forKey: Keys.passcodeOn) + } + set { + userDefaults.set(newValue, forKey: Keys.passcodeOn) + } + } + @objc var playerShowPlaybackSpeedShortcut: Bool { get { userDefaults.bool(forKey: Keys.playerShowPlaybackSpeedShortcut) @@ -924,6 +934,7 @@ extension VLCDefaults { static let hardwareDecodingKey: String = Keys.hardwareDecoding static let hideLibraryInFilesAppKey: String = Keys.hideLibraryInFilesApp static let networkCachingKey: String = Keys.networkCaching + static let passcodeOnKey: String = Keys.passcodeOn static let playbackBackwardSkipLengthKey: String = Keys.playbackBackwardSkipLength static let playbackBackwardSkipLengthSwipeKey: String = Keys.playbackBackwardSkipLengthSwipe static let playbackForwardSkipLengthKey: String = Keys.playbackForwardSkipLength @@ -1020,6 +1031,7 @@ fileprivate enum Keys { static let networkSatIPChannelListUrl = "satip-channellist-url" static let numberOfLaunches = "kVLCNumberOfLaunches" static let passcodeEnableBiometricAuth = "EnableBiometricAuth" + static let passcodeOn = "PasscodeProtection" static let pauseWhenShowingControls = "kVLCSettingPauseWhenShowingControls" static let playbackBackwardSkipLength = "playback-backward-skip-length" static let playbackBackwardSkipLengthSwipe = "playback-backward-skip-length-swipe" diff --git a/Sources/Settings/Controller/SettingsController.swift b/Sources/Settings/Controller/SettingsController.swift index cf7086793..65e56d94f 100644 --- a/Sources/Settings/Controller/SettingsController.swift +++ b/Sources/Settings/Controller/SettingsController.swift @@ -428,7 +428,7 @@ extension SettingsController: MediaLibraryHidingDelegate { extension SettingsController: SettingsCellDelegate { func settingsCellDidChangeSwitchState(cell _: SettingsCell, preferenceKey: String, isOn: Bool) { switch preferenceKey { - case kVLCSettingPasscodeOnKey: + case VLCDefaults.Compat.passcodeOnKey: passcodeLockSwitchOn(state: isOn) case VLCDefaults.Compat.hideLibraryInFilesAppKey: medialibraryHidingLockSwitchOn(state: isOn) @@ -470,7 +470,7 @@ extension SettingsController { KeychainCoordinator.passcodeService.setSecret { success in // If the user cancels setting the password, the toggle should revert to the unset state. // This ensures the UI reflects the correct state. - UserDefaults.standard.set(success, forKey: kVLCSettingPasscodeOnKey) + VLCDefaults.shared.passcodeOn = success self.reloadSettingsSections() // To show/hide biometric row } } else { diff --git a/Sources/Settings/Model/SettingsSection.swift b/Sources/Settings/Model/SettingsSection.swift index db5e11ff8..21ace9d7e 100644 --- a/Sources/Settings/Model/SettingsSection.swift +++ b/Sources/Settings/Model/SettingsSection.swift @@ -298,7 +298,7 @@ enum PrivacyOptions { static var passcodeLock: SettingsItem { .toggle(title: "SETTINGS_PASSCODE_LOCK", subtitle: "SETTINGS_PASSCODE_LOCK_SUBTITLE", - preferenceKey: kVLCSettingPasscodeOnKey) + keyPath: \.passcodeOn) } static var enableBiometrics: SettingsItem? { -- GitLab From 677f7a9fa854be5a8a9b5f4c5eed04987fca9ed3 Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Wed, 26 Feb 2025 18:16:06 -0500 Subject: [PATCH 84/97] Convert kVLCSettingDisableSubtitles --- Sources/Headers/VLCConstants.h | 1 - Sources/Headers/VLCTVConstants.h | 1 - Sources/Helpers/VLCDefaults.swift | 11 +++++++++++ Sources/Playback/Control/VLCPlaybackService.m | 6 +++--- Sources/Settings/Model/SettingsSection.swift | 2 +- 5 files changed, 15 insertions(+), 6 deletions(-) diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index e91c6ddd2..68c17521d 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -20,7 +20,6 @@ #define kVLCSettingNetworkSatIPChannelListCustom @"CustomList" #define kVLCSettingsDecrapifyTitles @"MLDecrapifyTitles" #define kVLCSettingLastUsedSubtitlesSearchLanguage @"kVLCSettingLastUsedSubtitlesSearchLanguage" -#define kVLCSettingDisableSubtitles @"kVLCSettingDisableSubtitles" #define kVLCRecentURLs @"recent-urls" #define kVLCRecentURLTitles @"recent-url-titles" diff --git a/Sources/Headers/VLCTVConstants.h b/Sources/Headers/VLCTVConstants.h index 3d1093600..e3c85ebb9 100644 --- a/Sources/Headers/VLCTVConstants.h +++ b/Sources/Headers/VLCTVConstants.h @@ -36,7 +36,6 @@ #define kVLCSettingSubtitlesFilePath @"sub-file" #define kVLCSettingSaveHTTPUploadServerStatus @"isHTTPServerOn" #define kVLCSettingUseSPDIF @"kVLCSettingUseSPDIF" -#define kVLCSettingDisableSubtitles @"kVLCSettingDisableSubtitles" #define kVLCLastPlayedMediaIdentifier @"LastPlayedMediaIdentifier" diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index ace619e65..b9be77589 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -33,6 +33,7 @@ Keys.currentlyPlayingPlaylist: false, Keys.customEqualizerProfileEnabled: false, Keys.disableGrouping: false, + Keys.disableSubtitles: false, Keys.downloadArtwork: true, Keys.enableMediaCellTextScrolling: false, Keys.equalizerProfileDisabled: true, @@ -238,6 +239,15 @@ extension VLCDefaults { } } + @objc var disableSubtitles: Bool { + get { + userDefaults.bool(forKey: Keys.disableSubtitles) + } + set { + userDefaults.set(newValue, forKey: Keys.disableSubtitles) + } + } + @objc var downloadArtwork: Bool { get { userDefaults.bool(forKey: Keys.downloadArtwork) @@ -1013,6 +1023,7 @@ fileprivate enum Keys { static let defaultPreampLevel = "pre-amp-level" static let deinterlace = "deinterlace" static let disableGrouping = "MLDisableGrouping" + static let disableSubtitles = "kVLCSettingDisableSubtitles" static let downloadArtwork = "download-artwork" static let enableMediaCellTextScrolling = "EnableMediaCellTextScrolling" static let equalizerProfile = "EqualizerProfile" diff --git a/Sources/Playback/Control/VLCPlaybackService.m b/Sources/Playback/Control/VLCPlaybackService.m index bce55aa48..3c4a11366 100644 --- a/Sources/Playback/Control/VLCPlaybackService.m +++ b/Sources/Playback/Control/VLCPlaybackService.m @@ -496,13 +496,13 @@ NSString *const VLCLastPlaylistPlayedMedia = @"LastPlaylistPlayedMedia"; } } - if ([[NSUserDefaults standardUserDefaults] boolForKey:kVLCSettingDisableSubtitles]) { + if (VLCDefaults.shared.disableSubtitles) { _mediaPlayer.currentVideoSubTitleIndex = -1; } else { [self selectVideoSubtitleAtIndex:media.subtitleTrackIndex]; } #else - BOOL disableSubtitles = [[NSUserDefaults standardUserDefaults] boolForKey:kVLCSettingDisableSubtitles]; + BOOL disableSubtitles = VLCDefaults.shared.disableSubtitles; NSArray *audioTracks = _mediaPlayer.audioTracks; if (media.audioTrackIndex < audioTracks.count) { @@ -1684,7 +1684,7 @@ NSString *const VLCLastPlaylistPlayedMedia = @"LastPlaylistPlayedMedia"; - (void)disableSubtitlesIfNeeded { - if ([[NSUserDefaults standardUserDefaults] boolForKey:kVLCSettingDisableSubtitles]) { + if (VLCDefaults.shared.disableSubtitles) { [_mediaPlayer deselectAllTextTracks]; } } diff --git a/Sources/Settings/Model/SettingsSection.swift b/Sources/Settings/Model/SettingsSection.swift index 21ace9d7e..5e185b593 100644 --- a/Sources/Settings/Model/SettingsSection.swift +++ b/Sources/Settings/Model/SettingsSection.swift @@ -544,7 +544,7 @@ enum SubtitlesOptions { static var disableSubtitles: SettingsItem { .toggle(title: "SETTINGS_SUBTITLES_DISABLE", subtitle: "SETTINGS_SUBTITLES_DISABLE_LONG", - preferenceKey: kVLCSettingDisableSubtitles) + keyPath: \.disableSubtitles) } static var font: SettingsItem { -- GitLab From 194de7c78e5138188ea06617cdc51f40ff0c0db5 Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Wed, 26 Feb 2025 18:26:01 -0500 Subject: [PATCH 85/97] Convert kVLCSettingsDecrapifyTitles. Reinstate title optimization code. --- Sources/Headers/VLCConstants.h | 1 - Sources/Helpers/VLCDefaults.swift | 11 +++++++++++ .../Media Library/MediaLibraryModel/MediaModel.swift | 5 +++++ Sources/Settings/Model/SettingsSection.swift | 2 +- 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index 68c17521d..528129da7 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -18,7 +18,6 @@ #define kVLCSaveDebugLogs @"kVLCSaveDebugLogs" #define kVLCSettingNetworkSatIPChannelList @"satip-channelist" #define kVLCSettingNetworkSatIPChannelListCustom @"CustomList" -#define kVLCSettingsDecrapifyTitles @"MLDecrapifyTitles" #define kVLCSettingLastUsedSubtitlesSearchLanguage @"kVLCSettingLastUsedSubtitlesSearchLanguage" #define kVLCRecentURLs @"recent-urls" diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index b9be77589..3fa32edbe 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -32,6 +32,7 @@ Keys.continueAudioInBackground: true, Keys.currentlyPlayingPlaylist: false, Keys.customEqualizerProfileEnabled: false, + Keys.optimizeTitles: false, Keys.disableGrouping: false, Keys.disableSubtitles: false, Keys.downloadArtwork: true, @@ -230,6 +231,15 @@ extension VLCDefaults { } } + @objc var optimizeTitles: Bool { + get { + userDefaults.bool(forKey: Keys.optimizeTitles) + } + set { + userDefaults.set(newValue, forKey: Keys.optimizeTitles) + } + } + @objc var disableGrouping: Bool { get { userDefaults.bool(forKey: Keys.disableGrouping) @@ -1020,6 +1030,7 @@ fileprivate enum Keys { static let currentlyPlayingPlaylist = "isPlaylistCurrentlyPlaying" static let customEqualizerProfileEnabled = "kVLCCustomProfileEnabled" static let customEqualizerProfiles = "kVLCCustomEqualizerProfiles" + static let optimizeTitles = "MLDecrapifyTitles" static let defaultPreampLevel = "pre-amp-level" static let deinterlace = "deinterlace" static let disableGrouping = "MLDisableGrouping" diff --git a/Sources/Media Library/MediaLibraryModel/MediaModel.swift b/Sources/Media Library/MediaLibraryModel/MediaModel.swift index 2e76b447c..18b4912af 100644 --- a/Sources/Media Library/MediaLibraryModel/MediaModel.swift +++ b/Sources/Media Library/MediaLibraryModel/MediaModel.swift @@ -78,6 +78,11 @@ extension VLCMLMedia { } func title() -> String { + if VLCDefaults.shared.optimizeTitles + && ((subtype() == .albumTrack && title.isSupportedAudioMediaFormat()) + || (subtype() != .albumTrack && title.isSupportedMediaFormat())) { + return (title as NSString).deletingPathExtension + } return title } } diff --git a/Sources/Settings/Model/SettingsSection.swift b/Sources/Settings/Model/SettingsSection.swift index 5e185b593..e00f059e0 100644 --- a/Sources/Settings/Model/SettingsSection.swift +++ b/Sources/Settings/Model/SettingsSection.swift @@ -661,7 +661,7 @@ enum MediaLibraryOptions { static var optimiseItemNamesForDisplay: SettingsItem { .toggle(title: "SETTINGS_DECRAPIFY", subtitle: nil, - preferenceKey: kVLCSettingsDecrapifyTitles) + keyPath: \.optimizeTitles) } static var disableGrouping: SettingsItem { -- GitLab From 79ef19735dbc9a9af79c75d7c7aff73d4ce5ca06 Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Wed, 26 Feb 2025 20:06:18 -0500 Subject: [PATCH 86/97] Convert kVLCSaveDebugLogs --- Sources/Headers/VLCConstants.h | 1 - Sources/Headers/VLCTVConstants.h | 1 - Sources/Helpers/VLCDefaults.swift | 11 +++++++++++ .../tvOS/VLCMicroMediaLibraryService.m | 2 +- Sources/Playback/Control/VLCPlaybackService.m | 2 +- Sources/Settings/Model/SettingsSection.swift | 2 +- Sources/Settings/tvOS/VLCSettingsViewController.m | 15 +++++++-------- 7 files changed, 21 insertions(+), 13 deletions(-) diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index 528129da7..d2cec16f9 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -15,7 +15,6 @@ #define kVLCSettingSaveHTTPUploadServerStatus @"isHTTPServerOn" #define kVLCSettingSubtitlesFilePath @"sub-file" #define kVLCSubtitlesCacheFolderName @"cached-subtitles" -#define kVLCSaveDebugLogs @"kVLCSaveDebugLogs" #define kVLCSettingNetworkSatIPChannelList @"satip-channelist" #define kVLCSettingNetworkSatIPChannelListCustom @"CustomList" #define kVLCSettingLastUsedSubtitlesSearchLanguage @"kVLCSettingLastUsedSubtitlesSearchLanguage" diff --git a/Sources/Headers/VLCTVConstants.h b/Sources/Headers/VLCTVConstants.h index e3c85ebb9..7f14f526f 100644 --- a/Sources/Headers/VLCTVConstants.h +++ b/Sources/Headers/VLCTVConstants.h @@ -25,7 +25,6 @@ #define kSupportedProtocolSchemes @"(rtsp|mms|mmsh|udp|rtp|rtmp|sftp|ftp|smb)$" -#define kVLCSaveDebugLogs @"kVLCSaveDebugLogs" #define kVLCSettingNetworkSatIPChannelList @"satip-channelist" #define kVLCSettingNetworkSatIPChannelListCustom @"CustomList" diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index 3fa32edbe..649f34c33 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -60,6 +60,7 @@ Keys.playPauseGesture: true, Keys.restoreLastPlayedMedia: true, Keys.rotationLock: false, + Keys.saveDebugLogs: false, Keys.seekGesture: true, Keys.showRemainingTime: false, Keys.showThumbnails: true, @@ -485,6 +486,15 @@ extension VLCDefaults { } } + @objc var saveDebugLogs: Bool { + get { + userDefaults.bool(forKey: Keys.saveDebugLogs) + } + set { + userDefaults.set(newValue, forKey: Keys.saveDebugLogs) + } + } + @objc var seekGesture: Bool { get { userDefaults.bool(forKey: Keys.seekGesture) @@ -1075,6 +1085,7 @@ fileprivate enum Keys { static let playPauseGesture = "EnablePlayPauseGesture" static let restoreLastPlayedMedia = "RestoreLastPlayedMedia" static let rotationLock = "kVLCSettingRotationLock" + static let saveDebugLogs = "kVLCSaveDebugLogs" static let seekGesture = "EnableSeekGesture" static let showArtworks = "ShowArtworks" static let showRemainingTime = "show-remaining-time" diff --git a/Sources/Media Library/tvOS/VLCMicroMediaLibraryService.m b/Sources/Media Library/tvOS/VLCMicroMediaLibraryService.m index 3afeffb3c..fd6769ec9 100644 --- a/Sources/Media Library/tvOS/VLCMicroMediaLibraryService.m +++ b/Sources/Media Library/tvOS/VLCMicroMediaLibraryService.m @@ -113,7 +113,7 @@ ret = self.discoveredFiles.readonlycopy; } - if ([[NSUserDefaults standardUserDefaults] boolForKey:kVLCSaveDebugLogs]) { + if (VLCDefaults.shared.saveDebugLogs) { ret = [self injectLogsToMedia:ret]; } diff --git a/Sources/Playback/Control/VLCPlaybackService.m b/Sources/Playback/Control/VLCPlaybackService.m index 3c4a11366..ddd275eef 100644 --- a/Sources/Playback/Control/VLCPlaybackService.m +++ b/Sources/Playback/Control/VLCPlaybackService.m @@ -273,7 +273,7 @@ NSString *const VLCLastPlaylistPlayedMedia = @"LastPlaylistPlayedMedia"; consoleLogger.level = kVLCLogLevelDebug; [debugLoggers addObject:consoleLogger]; #endif - BOOL saveDebugLogs = [userDefaults boolForKey:kVLCSaveDebugLogs]; + BOOL saveDebugLogs = VLCDefaults.shared.saveDebugLogs; if (saveDebugLogs) { NSArray *searchPaths; #if TARGET_OS_TV diff --git a/Sources/Settings/Model/SettingsSection.swift b/Sources/Settings/Model/SettingsSection.swift index e00f059e0..45fded15c 100644 --- a/Sources/Settings/Model/SettingsSection.swift +++ b/Sources/Settings/Model/SettingsSection.swift @@ -779,7 +779,7 @@ enum Lab { static var debugLogging: SettingsItem { .toggle(title: "SETTINGS_DEBUG_LOG", subtitle: nil, - preferenceKey: kVLCSaveDebugLogs) + keyPath: \.saveDebugLogs) } static var exportLibrary: SettingsItem { diff --git a/Sources/Settings/tvOS/VLCSettingsViewController.m b/Sources/Settings/tvOS/VLCSettingsViewController.m index 74834c752..09bea9240 100644 --- a/Sources/Settings/tvOS/VLCSettingsViewController.m +++ b/Sources/Settings/tvOS/VLCSettingsViewController.m @@ -14,6 +14,7 @@ #import "IASKSettingsReader.h" #import "IASKSpecifier.h" #import "VLCAboutViewController.h" +#import "VLC-Swift.h" #define SettingsReUseIdentifier @"SettingsReUseIdentifier" @@ -45,7 +46,7 @@ self.tableView.opaque = NO; self.tableView.backgroundColor = [UIColor clearColor]; - _debugLoggingOn = [self.userDefaults boolForKey:kVLCSaveDebugLogs]; + _debugLoggingOn = VLCDefaults.shared.saveDebugLogs; } - (NSString *)title @@ -58,13 +59,11 @@ [super viewWillDisappear:animated]; /* if debug logging was disabled in this session of the settings screen, delete all the logs */ - if (_debugLoggingOn) { - if (![self.userDefaults boolForKey:kVLCSaveDebugLogs]) { - NSArray *searchPaths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES); - NSString* logFilePath = [searchPaths.firstObject stringByAppendingPathComponent:@"Logs"]; - NSFileManager *fileManager = [NSFileManager defaultManager]; - [fileManager removeItemAtPath:logFilePath error:nil]; - } + if (_debugLoggingOn && !VLCDefaults.shared.saveDebugLogs) { + NSArray *searchPaths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES); + NSString* logFilePath = [searchPaths.firstObject stringByAppendingPathComponent:@"Logs"]; + NSFileManager *fileManager = [NSFileManager defaultManager]; + [fileManager removeItemAtPath:logFilePath error:nil]; } } -- GitLab From b5bedb878c1d5405e1c242efebb4e7d7c8f6a32d Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Wed, 26 Feb 2025 20:46:47 -0500 Subject: [PATCH 87/97] Remove preferenceKey from settings toggles. --- .../Controller/SettingsController.swift | 63 +------- Sources/Settings/Model/SettingsSection.swift | 134 ++++++++---------- Sources/Settings/View/SettingsCell.swift | 9 -- 3 files changed, 64 insertions(+), 142 deletions(-) diff --git a/Sources/Settings/Controller/SettingsController.swift b/Sources/Settings/Controller/SettingsController.swift index 65e56d94f..1be78d93f 100644 --- a/Sources/Settings/Controller/SettingsController.swift +++ b/Sources/Settings/Controller/SettingsController.swift @@ -20,6 +20,7 @@ import UIKit extension Notification.Name { static let VLCDisableGroupingDidChangeNotification = Notification.Name("disableGroupingDidChangeNotfication") + static let VLCSettingsShouldReloadNotification = Notification.Name("settingsShouldReloadNotification") } class SettingsController: UITableViewController { @@ -97,6 +98,10 @@ class SettingsController: UITableViewController { selector: #selector(reloadSettingsSections), name: UserDefaults.didChangeNotification, object: nil) + notificationCenter.addObserver(self, + selector: #selector(reloadSettingsSections), + name: .VLCSettingsShouldReloadNotification, + object: nil) notificationCenter.addObserver(self, selector: #selector(themeDidChange), name: .VLCThemeDidChangeNotification, @@ -303,7 +308,8 @@ class SettingsController: UITableViewController { extension SettingsController { @objc func reloadSettingsSections() { settingsSections = SettingsSection - .sections(isLabActivated: isLabActivated, + .sections(mediaLibraryService: mediaLibraryService, + isLabActivated: isLabActivated, isBackingUp: isBackingUp, isForwardBackwardEqual: VLCDefaults.shared.playbackForwardBackwardEqual, isTapSwipeEqual: VLCDefaults.shared.playbackTapSwipeEqual) @@ -426,21 +432,6 @@ extension SettingsController: MediaLibraryHidingDelegate { // MARK: - SwitchOn Delegates extension SettingsController: SettingsCellDelegate { - func settingsCellDidChangeSwitchState(cell _: SettingsCell, preferenceKey: String, isOn: Bool) { - switch preferenceKey { - case VLCDefaults.Compat.passcodeOnKey: - passcodeLockSwitchOn(state: isOn) - case VLCDefaults.Compat.hideLibraryInFilesAppKey: - medialibraryHidingLockSwitchOn(state: isOn) - case VLCDefaults.Compat.backupMediaLibraryKey: - mediaLibraryBackupActivateSwitchOn(state: isOn) - case VLCDefaults.Compat.disableGroupingKey: - medialibraryDisableGroupingSwitchOn(state: isOn) - default: - break - } - } - func settingsCellInfoButtonPressed(cell: SettingsCell, preferenceKey: String) { guard let settingSpecifier = getSettingsSpecifier(for: preferenceKey) else { return @@ -464,46 +455,6 @@ extension SettingsController: SettingsCellDelegate { } } -extension SettingsController { - func passcodeLockSwitchOn(state: Bool) { - if state { - KeychainCoordinator.passcodeService.setSecret { success in - // If the user cancels setting the password, the toggle should revert to the unset state. - // This ensures the UI reflects the correct state. - VLCDefaults.shared.passcodeOn = success - self.reloadSettingsSections() // To show/hide biometric row - } - } else { - // When disabled any existing passcode should be removed. - // If user previously set a passcode and then disable and enable it - // the new passcode view will be showed, but if user terminates the app - // passcode will remain open even if the user doesn't set the new passcode. - // So, this may cause the app being locked. - try? KeychainCoordinator.passcodeService.removeSecret() - - reloadSettingsSections() - } - } -} - -extension SettingsController { - func medialibraryHidingLockSwitchOn(state: Bool) { - mediaLibraryService.hideMediaLibrary(state) - } -} - -extension SettingsController { - func mediaLibraryBackupActivateSwitchOn(state: Bool) { - mediaLibraryService.excludeFromDeviceBackup(state) - } -} - -extension SettingsController { - func medialibraryDisableGroupingSwitchOn(state _: Bool) { - notificationCenter.post(name: .VLCDisableGroupingDidChangeNotification, object: self) - } -} - extension SettingsController: ActionSheetSpecifierDelegate { func actionSheetSpecifierHandleToggleSwitch(for cell: ActionSheetCell, state: Bool) { switch cell.identifier { diff --git a/Sources/Settings/Model/SettingsSection.swift b/Sources/Settings/Model/SettingsSection.swift index 45fded15c..a07a94ab9 100644 --- a/Sources/Settings/Model/SettingsSection.swift +++ b/Sources/Settings/Model/SettingsSection.swift @@ -28,8 +28,6 @@ struct SettingsItem: Equatable { @available(*, deprecated, message: "access from self.action") var preferenceKey: String? { switch action { - case let .toggle(toggle): - return toggle.preferenceKey case let .showActionSheet(_, preferenceKey, _): return preferenceKey default: @@ -44,12 +42,8 @@ struct SettingsItem: Equatable { self.isTitleEmphasized = isTitleEmphasized } - static func toggle(title: String, subtitle: String?, preferenceKey: String) -> Self { - return Self(title: title, subtitle: subtitle, action: .toggle(Toggle(preferenceKey: preferenceKey))) - } - - static func toggle(title: String, subtitle: String?, keyPath: WritableKeyPath<VLCDefaults, Bool>) -> Self { - return Self(title: title, subtitle: subtitle, action: .toggle(Toggle(keyPath: keyPath))) + static func toggle(title: String, subtitle: String? = nil, keyPath: WritableKeyPath<VLCDefaults, Bool>, onChange: ((Bool) -> Void)? = nil) -> Self { + return Self(title: title, subtitle: subtitle, action: .toggle(Toggle(keyPath: keyPath, onChange: onChange))) } enum Action: Equatable { @@ -66,17 +60,11 @@ struct SettingsItem: Equatable { final class Toggle: Equatable { typealias Observer = (Bool) -> Void - let preferenceKey: String? - let keyPath: WritableKeyPath<VLCDefaults, Bool>? + private let keyPath: WritableKeyPath<VLCDefaults, Bool> + private let onChange: ((Bool) -> Void)? var isOn: Bool { - if let keyPath = keyPath { - VLCDefaults.shared[keyPath: keyPath] - } else if let preferenceKey = preferenceKey { - UserDefaults.standard.bool(forKey: preferenceKey) - } else { - fatalError() - } + VLCDefaults.shared[keyPath: keyPath] } private var observers: [Int: Observer] = [:] @@ -88,27 +76,19 @@ struct SettingsItem: Equatable { set { lock.withLock { _lastId = newValue } } } - init(preferenceKey: String) { - self.preferenceKey = preferenceKey - self.keyPath = nil - NotificationCenter.default.addObserver(self, selector: #selector(didChange), name: UserDefaults.didChangeNotification, object: nil) - } - - init(keyPath: WritableKeyPath<VLCDefaults, Bool>) { - self.preferenceKey = nil + init(keyPath: WritableKeyPath<VLCDefaults, Bool>, onChange: ((Bool) -> Void)? = nil) { self.keyPath = keyPath - NotificationCenter.default.addObserver(self, selector: #selector(didChange), name: UserDefaults.didChangeNotification, object: nil) + self.onChange = onChange + NotificationCenter.default.addObserver(self, + selector: #selector(didChange), + name: UserDefaults.didChangeNotification, + object: nil) } func set(isOn: Bool) { - if let keyPath = keyPath { - var defaults = VLCDefaults.shared - defaults[keyPath: keyPath] = isOn - } else if let preferenceKey = preferenceKey { - UserDefaults.standard.set(isOn, forKey: preferenceKey) - } else { - fatalError() - } + var defaults = VLCDefaults.shared + defaults[keyPath: keyPath] = isOn + onChange?(isOn) } // does not call out initially. @@ -128,7 +108,7 @@ struct SettingsItem: Equatable { } private func notifyObservers() { - precondition(!isNotifyingObservers, "[\(preferenceKey)] updating the toggle switch from an observer is illegal") + precondition(!isNotifyingObservers, "updating the toggle switch from an observer is illegal") isNotifyingObservers = true @@ -145,7 +125,7 @@ struct SettingsItem: Equatable { } static func == (lhs: SettingsItem.Toggle, rhs: SettingsItem.Toggle) -> Bool { - lhs.preferenceKey == rhs.preferenceKey + lhs.keyPath == rhs.keyPath } } } @@ -165,18 +145,22 @@ struct SettingsSection: Equatable { self.items = items } - static func sections(isLabActivated: Bool, isBackingUp: Bool, isForwardBackwardEqual: Bool, isTapSwipeEqual: Bool) -> [SettingsSection] { + static func sections(mediaLibraryService: MediaLibraryService, + isLabActivated: Bool, + isBackingUp: Bool, + isForwardBackwardEqual: Bool, + isTapSwipeEqual: Bool) -> [SettingsSection] { [ MainOptions.section(), DonationOptions.section(), GenericOptions.section(), - PrivacyOptions.section(), + PrivacyOptions.section(mediaLibraryService: mediaLibraryService), GestureControlOptions.section(isForwardBackwardEqual: isForwardBackwardEqual, isTapSwipeEqual: isTapSwipeEqual), VideoOptions.section(), SubtitlesOptions.section(), AudioOptions.section(), CastingOptions.section(), - MediaLibraryOptions.section(isBackingUp: isBackingUp), + MediaLibraryOptions.section(mediaLibraryService: mediaLibraryService, isBackingUp: isBackingUp), NetworkOptions.section(), Accessibility.section(), Lab.section(isLabActivated: isLabActivated), @@ -242,7 +226,6 @@ enum GenericOptions { static var playVideoInFullScreen: SettingsItem { .toggle(title: "SETTINGS_VIDEO_FULLSCREEN", - subtitle: nil, keyPath: \.videoFullscreenPlayback) } @@ -262,19 +245,16 @@ enum GenericOptions { static var enableTextScrollingInMediaList: SettingsItem { .toggle(title: "SETTINGS_ENABLE_MEDIA_CELL_TEXT_SCROLLING", - subtitle: nil, keyPath: \.enableMediaCellTextScrolling) } static var rememberPlayerState: SettingsItem { .toggle(title: "SETTINGS_REMEMBER_PLAYER_STATE", - subtitle: nil, keyPath: \.playerShouldRememberState) } static var restoreLastPlayedMedia: SettingsItem { .toggle(title: "SETTINGS_RESTORE_LAST_PLAYED_MEDIA", - subtitle: nil, keyPath: \.restoreLastPlayedMedia) } @@ -298,7 +278,25 @@ enum PrivacyOptions { static var passcodeLock: SettingsItem { .toggle(title: "SETTINGS_PASSCODE_LOCK", subtitle: "SETTINGS_PASSCODE_LOCK_SUBTITLE", - keyPath: \.passcodeOn) + keyPath: \.passcodeOn) { isOn in + if isOn { + KeychainCoordinator.passcodeService.setSecret { success in + // If the user cancels setting the password, the toggle should revert to the unset state. + // This ensures the UI reflects the correct state. + VLCDefaults.shared.passcodeOn = success + NotificationCenter.default.post(name: .VLCSettingsShouldReloadNotification, object: nil) // To show/hide biometric row + } + } else { + // When disabled any existing passcode should be removed. + // If user previously set a passcode and then disable and enable it + // the new passcode view will be showed, but if user terminates the app + // passcode will remain open even if the user doesn't set the new passcode. + // So, this may cause the app being locked. + try? KeychainCoordinator.passcodeService.removeSecret() + + NotificationCenter.default.post(name: .VLCSettingsShouldReloadNotification, object: nil) + } + } } static var enableBiometrics: SettingsItem? { @@ -308,15 +306,12 @@ enum PrivacyOptions { switch authContext.biometryType { case .touchID: return .toggle(title: "SETTINGS_PASSCODE_LOCK_ALLOWTOUCHID", - subtitle: nil, keyPath: \.passcodeEnableBiometricAuth) case .faceID: return .toggle(title: "SETTINGS_PASSCODE_LOCK_ALLOWFACEID", - subtitle: nil, keyPath: \.passcodeEnableBiometricAuth) case .opticID: return .toggle(title: "SETTINGS_PASSCODE_LOCK_ALLOWOPTICID", - subtitle: nil, keyPath: \.passcodeEnableBiometricAuth) case .none: fallthrough @@ -328,17 +323,19 @@ enum PrivacyOptions { return nil } - static var hideLibraryInFilesApp: SettingsItem { + static func hideLibraryInFilesApp(mediaLibraryService: MediaLibraryService) -> SettingsItem { .toggle(title: "SETTINGS_HIDE_LIBRARY_IN_FILES_APP", subtitle: "SETTINGS_HIDE_LIBRARY_IN_FILES_APP_SUBTITLE", - keyPath: \.hideLibraryInFilesApp) + keyPath: \.hideLibraryInFilesApp) { isOn in + mediaLibraryService.hideMediaLibrary(isOn) + } } - static func section() -> SettingsSection? { + static func section(mediaLibraryService: MediaLibraryService) -> SettingsSection? { .init(title: "SETTINGS_PRIVACY_TITLE", items: [ passcodeLock, enableBiometrics, - hideLibraryInFilesApp, + hideLibraryInFilesApp(mediaLibraryService: mediaLibraryService), ].compactMap { $0 }) } } @@ -348,43 +345,36 @@ enum PrivacyOptions { enum GestureControlOptions { static var swipeUpDownForVolume: SettingsItem { .toggle(title: "SETTINGS_GESTURES_VOLUME", - subtitle: nil, keyPath: \.volumeGesture) } static var twoFingerTap: SettingsItem { .toggle(title: "SETTINGS_GESTURES_PLAYPAUSE", - subtitle: nil, keyPath: \.playPauseGesture) } static var swipeUpDownForBrightness: SettingsItem { .toggle(title: "SETTINGS_GESTURES_BRIGHTNESS", - subtitle: nil, keyPath: \.brightnessGesture) } static var swipeRightLeftToSeek: SettingsItem { .toggle(title: "SETTINGS_GESTURES_SEEK", - subtitle: nil, keyPath: \.seekGesture) } static var pinchToClose: SettingsItem { .toggle(title: "SETTINGS_GESTURES_CLOSE", - subtitle: nil, keyPath: \.closeGesture) } static var forwardBackwardEqual: SettingsItem { .toggle(title: "SETTINGS_GESTURES_FORWARD_BACKWARD_EQUAL", - subtitle: nil, keyPath: \.playbackForwardBackwardEqual) } static var tapSwipeEqual: SettingsItem { .toggle(title: "SETTINGS_GESTURES_TAP_SWIPE_EQUAL", - subtitle: nil, keyPath: \.playbackTapSwipeEqual) } @@ -418,7 +408,6 @@ enum GestureControlOptions { static var longTouchToSpeedUp: SettingsItem { .toggle(title: "SETINGS_LONG_TOUCH_SPEED_UP", - subtitle: nil, keyPath: \.playbackLongTouchSpeedUp) } @@ -517,13 +506,11 @@ enum VideoOptions { static var rememberPlayerBrightness: SettingsItem { .toggle(title: "SETTINGS_REMEMBER_PLAYER_BRIGHTNESS", - subtitle: nil, keyPath: \.playerShouldRememberBrightness) } static var lockRotation: SettingsItem { .toggle(title: "SETTINGS_LOCK_ROTATION", - subtitle: nil, keyPath: \.rotationLock) } @@ -563,7 +550,6 @@ enum SubtitlesOptions { static var useBoldFont: SettingsItem { .toggle(title: "SETTINGS_SUBTITLES_BOLDFONT", - subtitle: nil, keyPath: \.subtitlesBoldFont) } @@ -635,7 +621,6 @@ enum AudioOptions { static var audioPlaybackInBackground: SettingsItem { .toggle(title: "SETTINGS_BACKGROUND_AUDIO", - subtitle: nil, keyPath: \.continueAudioInBackgroundKey) } @@ -660,32 +645,31 @@ enum MediaLibraryOptions { static var optimiseItemNamesForDisplay: SettingsItem { .toggle(title: "SETTINGS_DECRAPIFY", - subtitle: nil, keyPath: \.optimizeTitles) } static var disableGrouping: SettingsItem { .toggle(title: "SETTINGS_DISABLE_GROUPING", - subtitle: nil, - keyPath: \.disableGrouping) + keyPath: \.disableGrouping) { isOn in + NotificationCenter.default.post(name: .VLCDisableGroupingDidChangeNotification, object: nil) + } } static var showVideoThumbnails: SettingsItem { .toggle(title: "SETTINGS_SHOW_THUMBNAILS", - subtitle: nil, keyPath: \.showThumbnails) } static var showAudioArtworks: SettingsItem { .toggle(title: "SETTINGS_SHOW_ARTWORKS", - subtitle: nil, keyPath: \.showArtworks) } - static var includeMediaLibInDeviceBackup: SettingsItem { + static func includeMediaLibInDeviceBackup(mediaLibraryService: MediaLibraryService) -> SettingsItem { .toggle(title: "SETTINGS_BACKUP_MEDIA_LIBRARY", - subtitle: nil, - keyPath: \.backupMediaLibrary) + keyPath: \.backupMediaLibrary) { isOn in + mediaLibraryService.excludeFromDeviceBackup(isOn) + } } static var includeMediaLibInDeviceBackupWhenBackingUp: SettingsItem { @@ -694,7 +678,7 @@ enum MediaLibraryOptions { action: .isLoading) } - static func section(isBackingUp: Bool) -> SettingsSection? { + static func section(mediaLibraryService: MediaLibraryService, isBackingUp: Bool) -> SettingsSection? { var options = [forceVLCToRescanTheMediaLibrary, optimiseItemNamesForDisplay, disableGrouping, @@ -704,7 +688,7 @@ enum MediaLibraryOptions { if isBackingUp { options.append(includeMediaLibInDeviceBackupWhenBackingUp) } else { - options.append(includeMediaLibInDeviceBackup) + options.append(includeMediaLibInDeviceBackup(mediaLibraryService: mediaLibraryService)) } return .init(title: "SETTINGS_MEDIA_LIBRARY", items: options) @@ -723,7 +707,6 @@ enum NetworkOptions { static var ipv6SupportForWiFiSharing: SettingsItem { .toggle(title: "SETTINGS_WIFISHARING_IPv6", - subtitle: nil, keyPath: \.wifiSharingIPv6) } @@ -735,7 +718,6 @@ enum NetworkOptions { static var rtspctp: SettingsItem { .toggle(title: "SETTINGS_RTSP_TCP", - subtitle: nil, keyPath: \.networkRTSPTCP) } @@ -761,7 +743,6 @@ enum Accessibility { static var pauseWhenShowingControls: SettingsItem { .toggle(title: "SETTINGS_PAUSE_WHEN_SHOWING_CONTROLS", - subtitle: nil, keyPath: \.pauseWhenShowingControls) } @@ -778,7 +759,6 @@ enum Accessibility { enum Lab { static var debugLogging: SettingsItem { .toggle(title: "SETTINGS_DEBUG_LOG", - subtitle: nil, keyPath: \.saveDebugLogs) } diff --git a/Sources/Settings/View/SettingsCell.swift b/Sources/Settings/View/SettingsCell.swift index c67c32751..29ba2e8b2 100644 --- a/Sources/Settings/View/SettingsCell.swift +++ b/Sources/Settings/View/SettingsCell.swift @@ -12,11 +12,6 @@ import UIKit protocol SettingsCellDelegate: AnyObject { - /// Implementations should only perform side effects on - /// specific preferences; updating the preference itself - /// is handled by the cell. - func settingsCellDidChangeSwitchState(cell: SettingsCell, preferenceKey: String, isOn: Bool) - func settingsCellInfoButtonPressed(cell: SettingsCell, preferenceKey: String) } @@ -288,10 +283,6 @@ class SettingsCell: UITableViewCell { switch settingsItem.action { case let .toggle(toggle): toggle.set(isOn: sender.isOn) - // TODO: we should get rid of the delegate entirely, and perform side effects within SettingSection - if let preferenceKey = toggle.preferenceKey { - delegate?.settingsCellDidChangeSwitchState(cell: self, preferenceKey: preferenceKey, isOn: sender.isOn) - } default: // we should never get here; only toggles have a switch -- GitLab From 21fc89c1807141c38813dc5ec12a618b5d72c33c Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Wed, 26 Feb 2025 21:24:16 -0500 Subject: [PATCH 88/97] Make VLCDefaults observable --- Sources/Helpers/VLCDefaults.swift | 16 +++++++++++++++- Sources/Playback/Control/VLCPlaybackService.m | 1 - .../Settings/Controller/SettingsController.swift | 2 +- Sources/Settings/Model/SettingsSection.swift | 6 +++--- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index 649f34c33..7d821efab 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -10,12 +10,22 @@ * Refer to the COPYING file of the official project for license. *****************************************************************************/ +extension Notification.Name { + static let VLCDefaultsDidUpdate = Notification.Name("VLCDefaultsDidUpdate") +} + @objc final class VLCDefaults: NSObject { @objc static let shared = VLCDefaults() private let userDefaults = UserDefaults.standard - private override init() {} + private override init() { + super.init() + NotificationCenter.default.addObserver(self, + selector: #selector(defaultsDidChange), + name: UserDefaults.didChangeNotification, + object: nil) + } @objc func registerDefaults() { var dict: [String: Any] = [ @@ -116,6 +126,10 @@ let appDomain = Bundle.main.bundleIdentifier! UserDefaults().removePersistentDomain(forName: appDomain) } + + @objc private func defaultsDidChange(_: Notification) { + NotificationCenter.default.post(name: .VLCDefaultsDidUpdate, object: self) + } } // MARK: - Defaults diff --git a/Sources/Playback/Control/VLCPlaybackService.m b/Sources/Playback/Control/VLCPlaybackService.m index ddd275eef..c213c9641 100644 --- a/Sources/Playback/Control/VLCPlaybackService.m +++ b/Sources/Playback/Control/VLCPlaybackService.m @@ -243,7 +243,6 @@ NSString *const VLCLastPlaylistPlayedMedia = @"LastPlaylistPlayedMedia"; /* the chromecast and audio options cannot be set per media, so we need to set it per * media player instance however, potentially initialising an additional library instance * for this is costly, so this should be done only if needed */ - NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults]; BOOL audioTimeStretch = VLCDefaults.shared.stretchAudio; NSMutableArray *libVLCOptions = [NSMutableArray array]; #if TARGET_OS_IOS diff --git a/Sources/Settings/Controller/SettingsController.swift b/Sources/Settings/Controller/SettingsController.swift index 1be78d93f..ae8935ae7 100644 --- a/Sources/Settings/Controller/SettingsController.swift +++ b/Sources/Settings/Controller/SettingsController.swift @@ -96,7 +96,7 @@ class SettingsController: UITableViewController { private func addObservers() { notificationCenter.addObserver(self, selector: #selector(reloadSettingsSections), - name: UserDefaults.didChangeNotification, + name: .VLCDefaultsDidUpdate, object: nil) notificationCenter.addObserver(self, selector: #selector(reloadSettingsSections), diff --git a/Sources/Settings/Model/SettingsSection.swift b/Sources/Settings/Model/SettingsSection.swift index a07a94ab9..0738f29da 100644 --- a/Sources/Settings/Model/SettingsSection.swift +++ b/Sources/Settings/Model/SettingsSection.swift @@ -80,8 +80,8 @@ struct SettingsItem: Equatable { self.keyPath = keyPath self.onChange = onChange NotificationCenter.default.addObserver(self, - selector: #selector(didChange), - name: UserDefaults.didChangeNotification, + selector: #selector(defaultsDidUpdate), + name: .VLCDefaultsDidUpdate, object: nil) } @@ -103,7 +103,7 @@ struct SettingsItem: Equatable { observers.removeValue(forKey: Int) } - @objc private func didChange(_: Notification) { + @objc private func defaultsDidUpdate(_: Notification) { notifyObservers() } -- GitLab From 380433bbb67c68786be272e5125d0f3606149228 Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Wed, 26 Feb 2025 21:35:38 -0500 Subject: [PATCH 89/97] Add name to a few file headers --- Sources/Settings/Controller/SettingsController.swift | 2 +- Sources/Settings/Model/SettingsSection.swift | 1 + Sources/Settings/View/SettingsCell.swift | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Sources/Settings/Controller/SettingsController.swift b/Sources/Settings/Controller/SettingsController.swift index ae8935ae7..14ccd5584 100644 --- a/Sources/Settings/Controller/SettingsController.swift +++ b/Sources/Settings/Controller/SettingsController.swift @@ -11,6 +11,7 @@ * Diogo Simao Marques <dogo@videolabs.io> * Felix Paul Kühne <fkuehne # videolan.org> * Andrew Breckenridge <asbreckenridge@me.com> + * Craig Reyenga <craig.reyenga # gmail.com> * * Refer to the COPYING file of the official project for license. *****************************************************************************/ @@ -27,7 +28,6 @@ class SettingsController: UITableViewController { private let cellReuseIdentifier = "settingsCell" private let sectionHeaderReuseIdentifier = "sectionHeaderReuseIdentifier" private let sectionFooterReuseIdentifier = "sectionFooterReuseIdentifier" - private let userDefaults = UserDefaults.standard private let notificationCenter = NotificationCenter.default private let actionSheet = ActionSheet() private let specifierManager = ActionSheetSpecifier() diff --git a/Sources/Settings/Model/SettingsSection.swift b/Sources/Settings/Model/SettingsSection.swift index 0738f29da..41b978613 100644 --- a/Sources/Settings/Model/SettingsSection.swift +++ b/Sources/Settings/Model/SettingsSection.swift @@ -10,6 +10,7 @@ * Diogo Simao Marques <dogo@videolabs.io> * Felix Paul Kühne <fkuehne # videolan.org> * Eshan Singh <eeeshan789@icloud.com> + * Craig Reyenga <craig.reyenga # gmail.com> * * Refer to the COPYING file of the official project for license. *****************************************************************************/ diff --git a/Sources/Settings/View/SettingsCell.swift b/Sources/Settings/View/SettingsCell.swift index 29ba2e8b2..c244d7c33 100644 --- a/Sources/Settings/View/SettingsCell.swift +++ b/Sources/Settings/View/SettingsCell.swift @@ -5,6 +5,7 @@ * Copyright (c) 2020 VideoLAN. All rights reserved. * * Authors: Swapnanil Dhol <swapnanildhol # gmail.com> + * Craig Reyenga <craig.reyenga # gmail.com> * * Refer to the COPYING file of the official project for license. *****************************************************************************/ -- GitLab From 8971bde418c599a2be1ec0b8b2482d160c1690ad Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Wed, 26 Feb 2025 21:43:20 -0500 Subject: [PATCH 90/97] Fix visionOS and tvOS builds. --- Sources/Helpers/VLCDefaults.swift | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index 7d821efab..be2c0eb9d 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -762,6 +762,7 @@ extension VLCDefaults { appTheme == .system } +#if os(iOS) || os(visionOS) var customEqualizerProfiles: CustomEqualizerProfiles? { get { guard let encodedData = userDefaults.data(forKey: Keys.customEqualizerProfiles) else { @@ -788,6 +789,7 @@ extension VLCDefaults { userDefaults.setValue(encoded, forKey: Keys.customEqualizerProfiles) } } +#endif var hardwareDecoding: HardwareDecoding { get { @@ -806,6 +808,7 @@ extension VLCDefaults { hardwareDecoding.rawValue } +#if os(iOS) || os(visionOS) var lastPlayedPlaylist: LastPlayedPlaylistModel? { get { guard let encodedData = userDefaults.data(forKey: Keys.lastPlayedPlaylist) else { @@ -832,6 +835,7 @@ extension VLCDefaults { userDefaults.setValue(encoded, forKey: Keys.lastPlayedPlaylist) } } +#endif var networkCaching: NetworkCaching { get { @@ -934,6 +938,7 @@ extension VLCDefaults { userDefaults.set(isGrid, forKey: Keys.audioLibraryGridLayout(collectionModelName: collectionModelName, name: name)) } +#if os(iOS) || os(visionOS) func sortDefault(name: String) -> VLCMLSortingCriteria? { let k = Keys.sortDefault(name: name) @@ -958,6 +963,7 @@ extension VLCDefaults { let k = Keys.sortDescendingDefault(name: name) userDefaults.set(isDescending, forKey: k) } +#endif } // MARK: - Compatibility -- GitLab From 37eca7d78ebdf0d0aa3d95293ab527653319db0b Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Thu, 27 Feb 2025 08:48:01 -0500 Subject: [PATCH 91/97] Reinstate feature lost during recent rebase. --- Sources/Helpers/VLCDefaults.swift | 24 +++++++++++++++++++ .../OS Integration/VLCRemoteControlService.m | 11 ++++----- Sources/Settings/Model/SettingsSection.swift | 4 ++-- 3 files changed, 31 insertions(+), 8 deletions(-) diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index be2c0eb9d..dbef59f51 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -53,6 +53,7 @@ extension Notification.Name { Keys.hasActiveSubscription: false, Keys.hasLaunchedBefore: false, Keys.hideLibraryInFilesApp: false, + Keys.lockscreenSkip: false, Keys.mediaLibraryServiceDidForceRescan: false, Keys.networkRTSPTCP: false, Keys.passcodeEnableBiometricAuth: true, @@ -68,6 +69,7 @@ extension Notification.Name { Keys.playerUIShouldHide: false, Keys.playlistPlayNextItem: true, Keys.playPauseGesture: true, + Keys.remoteControlSkip: false, Keys.restoreLastPlayedMedia: true, Keys.rotationLock: false, Keys.saveDebugLogs: false, @@ -346,6 +348,15 @@ extension VLCDefaults { } } + @objc var lockscreenSkip: Bool { + get { + userDefaults.bool(forKey: Keys.lockscreenSkip) + } + set { + userDefaults.set(newValue, forKey: Keys.lockscreenSkip) + } + } + @objc var mediaLibraryServiceDidForceRescan: Bool { get { userDefaults.bool(forKey: Keys.mediaLibraryServiceDidForceRescan) @@ -491,6 +502,15 @@ extension VLCDefaults { } } + @objc var remoteControlSkip: Bool { + get { + userDefaults.bool(forKey: Keys.remoteControlSkip) + } + set { + userDefaults.set(newValue, forKey: Keys.remoteControlSkip) + } + } + @objc var rotationLock: Bool { get { userDefaults.bool(forKey: Keys.rotationLock) @@ -983,6 +1003,7 @@ extension VLCDefaults { static let disableGroupingKey: String = Keys.disableGrouping static let hardwareDecodingKey: String = Keys.hardwareDecoding static let hideLibraryInFilesAppKey: String = Keys.hideLibraryInFilesApp + static let lockscreenSkipKey: String = Keys.lockscreenSkip static let networkCachingKey: String = Keys.networkCaching static let passcodeOnKey: String = Keys.passcodeOn static let playbackBackwardSkipLengthKey: String = Keys.playbackBackwardSkipLength @@ -991,6 +1012,7 @@ extension VLCDefaults { static let playbackForwardSkipLengthSwipeKey: String = Keys.playbackForwardSkipLengthSwipe static let playbackSpeedDefaultValueKey: String = Keys.playbackSpeedDefaultValue static let playerControlDurationKey: String = Keys.playerControlDuration + static let remoteControlSkipKey: String = Keys.remoteControlSkip static let skipLoopFilterKey: String = Keys.skipLoopFilter static let subtitlesFontColorKey: String = Keys.subtitlesFontColor static let subtitlesFontKey: String = Keys.subtitlesFont @@ -1077,6 +1099,7 @@ fileprivate enum Keys { static let hasNaggedThisMonth = "kVLCHasNaggedThisMonth" static let hideLibraryInFilesApp = "HideLibraryInFilesApp" static let lastPlayedPlaylist = "LastPlayedPlaylist" + static let lockscreenSkip = "playback-lockscreen-skip" static let mediaLibraryServiceDidForceRescan = "MediaLibraryDidForceRescan" static let networkCaching = "network-caching" static let networkRTSPTCP = "rtsp-tcp" @@ -1103,6 +1126,7 @@ fileprivate enum Keys { static let playerUIShouldHide = "PlayerUIShouldHide" static let playlistPlayNextItem = "PlaylistPlayNextItem" static let playPauseGesture = "EnablePlayPauseGesture" + static let remoteControlSkip = "playback-remote-control-skip" static let restoreLastPlayedMedia = "RestoreLastPlayedMedia" static let rotationLock = "kVLCSettingRotationLock" static let saveDebugLogs = "kVLCSaveDebugLogs" diff --git a/Sources/Playback/OS Integration/VLCRemoteControlService.m b/Sources/Playback/OS Integration/VLCRemoteControlService.m index 43bc9cd96..639925104 100644 --- a/Sources/Playback/OS Integration/VLCRemoteControlService.m +++ b/Sources/Playback/OS Integration/VLCRemoteControlService.m @@ -56,13 +56,12 @@ static inline NSArray * RemoteCommandCenterCommandsToHandle(void) - (void)playbackStarted:(NSNotification *)aNotification { MPRemoteCommandCenter *commandCenter = [MPRemoteCommandCenter sharedCommandCenter]; - NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; /* Since the control center and lockscreen shows only either skipForward/Backward * or next/previousTrack buttons but prefers skip buttons, * we only enable skip buttons if we have no medialist */ - BOOL alwaysEnableSkip = [defaults boolForKey:kVLCSettingPlaybackLockscreenSkip]; + BOOL alwaysEnableSkip = VLCDefaults.shared.lockscreenSkip; BOOL enableSkip = alwaysEnableSkip || [VLCPlaybackService sharedInstance].mediaList.count <= 1; commandCenter.skipForwardCommand.enabled = enableSkip; commandCenter.skipBackwardCommand.enabled = enableSkip; @@ -123,8 +122,8 @@ static inline NSArray * RemoteCommandCenterCommandsToHandle(void) return MPRemoteCommandHandlerStatusSuccess; } if (event.command == cc.nextTrackCommand) { - if ([defaults boolForKey:kVLCSettingPlaybackRemoteControlSkip]) { - NSInteger interval = [defaults integerForKey:kVLCSettingPlaybackForwardSkipLength]; + if (VLCDefaults.shared.remoteControlSkip) { + NSInteger interval = VLCDefaults.shared.playbackForwardSkipLength; [vps jumpForward:(int)interval]; return MPRemoteCommandHandlerStatusSuccess; } else { @@ -133,8 +132,8 @@ static inline NSArray * RemoteCommandCenterCommandsToHandle(void) } } if (event.command == cc.previousTrackCommand) { - if ([defaults boolForKey:kVLCSettingPlaybackRemoteControlSkip]) { - NSInteger interval = [defaults integerForKey:kVLCSettingPlaybackBackwardSkipLength]; + if (VLCDefaults.shared.remoteControlSkip) { + NSInteger interval = VLCDefaults.shared.playbackBackwardSkipLength; [vps jumpBackward:(int)interval]; return MPRemoteCommandHandlerStatusSuccess; diff --git a/Sources/Settings/Model/SettingsSection.swift b/Sources/Settings/Model/SettingsSection.swift index 41b978613..5283340e1 100644 --- a/Sources/Settings/Model/SettingsSection.swift +++ b/Sources/Settings/Model/SettingsSection.swift @@ -413,14 +413,14 @@ enum GestureControlOptions { } static var lockScreenSkip: SettingsItem { - let k = kVLCSettingPlaybackLockscreenSkip + let k = VLCDefaults.Compat.lockscreenSkipKey return .init(title: "SETTINGS_PLAYBACK_LOCKSCREEN_SKIP", subtitle: Localizer.getSubtitle(for: k), action: .showActionSheet(title: "SETTINGS_PLAYBACK_LOCKSCREEN_SKIP", preferenceKey: k, hasInfo: false)) } static var externalControlsSkip: SettingsItem { - let k = kVLCSettingPlaybackRemoteControlSkip + let k = VLCDefaults.Compat.remoteControlSkipKey return .init(title: "SETTINGS_PLAYBACK_EXTERNAL_CONTROLS_SKIP", subtitle: Localizer.getSubtitle(for: k), action: .showActionSheet(title: "SETTINGS_PLAYBACK_EXTERNAL_CONTROLS_SKIP", preferenceKey: k, hasInfo: false)) -- GitLab From c0825e25e775b5b75e61ae58919867da6aafdd7f Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Mon, 3 Mar 2025 12:56:56 -0500 Subject: [PATCH 92/97] Fix missing default playback speed, fix crash on fresh install. Fix some issues found in Root.inApp.plist. --- .../iOS/Settings.bundle/Root.inApp.plist | 12 +- Sources/Helpers/VLCDefaults.swift | 174 ++++++++++-------- Sources/UI Elements/PresentationTheme.swift | 2 +- 3 files changed, 106 insertions(+), 82 deletions(-) diff --git a/Resources/iOS/Settings.bundle/Root.inApp.plist b/Resources/iOS/Settings.bundle/Root.inApp.plist index 2172d720b..614adcb10 100644 --- a/Resources/iOS/Settings.bundle/Root.inApp.plist +++ b/Resources/iOS/Settings.bundle/Root.inApp.plist @@ -49,7 +49,7 @@ <integer>0</integer> <integer>1</integer> <integer>2</integer> - <string>3</string> + <integer>3</integer> </array> </dict> <dict> @@ -163,6 +163,8 @@ <string>SETTINGS_NETWORK_PLAY_ALL</string> <key>Type</key> <string>PSMultiValueSpecifier</string> + <key>DefaultValue</key> + <false/> <key>Titles</key> <array> <string>SETTINGS_PLAY_ALL</string> @@ -170,8 +172,8 @@ </array> <key>Values</key> <array> - <integer>0</integer> - <integer>1</integer> + <false/> + <true/> </array> </dict> <dict> @@ -522,7 +524,7 @@ <key>Key</key> <string>avcodec-skiploopfilter</string> <key>DefaultValue</key> - <string>1</string> + <integer>1</integer> <key>Titles</key> <array> <string>SETTINGS_SKIP_LOOP_FILTER_NONE</string> @@ -557,7 +559,7 @@ <array> <integer>1</integer> <integer>0</integer> - <string>-1</string> + <integer>-1</integer> </array> </dict> <dict> diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index dbef59f51..b22e12aa2 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -95,6 +95,7 @@ extension Notification.Name { Keys.playbackBackwardSkipLengthSwipe: DefaultValues.playbackBackwardSkipLengthSwipe, Keys.playbackForwardSkipLength: DefaultValues.playbackForwardSkipLength, Keys.playbackForwardSkipLengthSwipe: DefaultValues.playbackForwardSkipLengthSwipe, + Keys.playbackSpeedDefaultValue: DefaultValues.playbackSpeedDefaultValue, Keys.playerControlDuration: DefaultValues.playerControlDuration, Keys.tabBarIndex: 0, @@ -132,6 +133,26 @@ extension Notification.Name { @objc private func defaultsDidChange(_: Notification) { NotificationCenter.default.post(name: .VLCDefaultsDidUpdate, object: self) } + + // These methods are not strictly necessary, however, they help prevent a + // programmer error whereby attempts to write invalid data types will get + // past the compiler, but will cause a crash at runtime. + + fileprivate func set(bool b: Bool, forKey key: String) { + userDefaults.set(b, forKey: key) + } + + fileprivate func set(float f: Float, forKey key: String) { + userDefaults.set(f, forKey: key) + } + + fileprivate func set(integer i: Int, forKey key: String) { + userDefaults.set(i, forKey: key) + } + + fileprivate func set(string s: String, forKey key: String) { + userDefaults.set(s, forKey: key) + } } // MARK: - Defaults @@ -145,7 +166,7 @@ extension VLCDefaults { userDefaults.bool(forKey: Keys.alwaysPlayURLs) } set { - userDefaults.set(newValue, forKey: Keys.alwaysPlayURLs) + set(bool: newValue, forKey: Keys.alwaysPlayURLs) } } @@ -154,7 +175,7 @@ extension VLCDefaults { userDefaults.bool(forKey: Keys.appThemeBlack) } set { - userDefaults.set(newValue, forKey: Keys.appThemeBlack) + set(bool: newValue, forKey: Keys.appThemeBlack) } } @@ -163,7 +184,7 @@ extension VLCDefaults { userDefaults.bool(forKey: Keys.audioLibraryHideFeatArtists) } set { - userDefaults.set(newValue, forKey: Keys.audioLibraryHideFeatArtists) + set(bool: newValue, forKey: Keys.audioLibraryHideFeatArtists) } } @@ -172,7 +193,7 @@ extension VLCDefaults { userDefaults.bool(forKey: Keys.audioLibraryHideTrackNumbers) } set { - userDefaults.set(newValue, forKey: Keys.audioLibraryHideTrackNumbers) + set(bool: newValue, forKey: Keys.audioLibraryHideTrackNumbers) } } @@ -181,7 +202,7 @@ extension VLCDefaults { userDefaults.bool(forKey: Keys.automaticallyPlayNextItem) } set { - userDefaults.set(newValue, forKey: Keys.automaticallyPlayNextItem) + set(bool: newValue, forKey: Keys.automaticallyPlayNextItem) } } @@ -190,7 +211,7 @@ extension VLCDefaults { userDefaults.bool(forKey: Keys.backupMediaLibrary) } set { - userDefaults.set(newValue, forKey: Keys.backupMediaLibrary) + set(bool: newValue, forKey: Keys.backupMediaLibrary) } } @@ -199,7 +220,7 @@ extension VLCDefaults { userDefaults.bool(forKey: Keys.brightnessGesture) } set { - userDefaults.set(newValue, forKey: Keys.brightnessGesture) + set(bool: newValue, forKey: Keys.brightnessGesture) } } @@ -208,7 +229,7 @@ extension VLCDefaults { userDefaults.bool(forKey: Keys.castingAudioPassthrough) } set { - userDefaults.set(newValue, forKey: Keys.castingAudioPassthrough) + set(bool: newValue, forKey: Keys.castingAudioPassthrough) } } @@ -217,7 +238,7 @@ extension VLCDefaults { userDefaults.bool(forKey: Keys.closeGesture) } set { - userDefaults.set(newValue, forKey: Keys.closeGesture) + set(bool: newValue, forKey: Keys.closeGesture) } } @@ -226,7 +247,7 @@ extension VLCDefaults { userDefaults.bool(forKey: Keys.continueAudioInBackground) } set { - userDefaults.set(newValue, forKey: Keys.continueAudioInBackground) + set(bool: newValue, forKey: Keys.continueAudioInBackground) } } @@ -235,7 +256,7 @@ extension VLCDefaults { userDefaults.bool(forKey: Keys.currentlyPlayingPlaylist) } set { - userDefaults.set(newValue, forKey: Keys.currentlyPlayingPlaylist) + set(bool: newValue, forKey: Keys.currentlyPlayingPlaylist) } } @@ -244,7 +265,7 @@ extension VLCDefaults { userDefaults.bool(forKey: Keys.customEqualizerProfileEnabled) } set { - userDefaults.set(newValue, forKey: Keys.customEqualizerProfileEnabled) + set(bool: newValue, forKey: Keys.customEqualizerProfileEnabled) } } @@ -253,7 +274,7 @@ extension VLCDefaults { userDefaults.bool(forKey: Keys.optimizeTitles) } set { - userDefaults.set(newValue, forKey: Keys.optimizeTitles) + set(bool: newValue, forKey: Keys.optimizeTitles) } } @@ -262,7 +283,7 @@ extension VLCDefaults { userDefaults.bool(forKey: Keys.disableGrouping) } set { - userDefaults.set(newValue, forKey: Keys.disableGrouping) + set(bool: newValue, forKey: Keys.disableGrouping) } } @@ -271,7 +292,7 @@ extension VLCDefaults { userDefaults.bool(forKey: Keys.disableSubtitles) } set { - userDefaults.set(newValue, forKey: Keys.disableSubtitles) + set(bool: newValue, forKey: Keys.disableSubtitles) } } @@ -280,7 +301,7 @@ extension VLCDefaults { userDefaults.bool(forKey: Keys.downloadArtwork) } set { - userDefaults.set(newValue, forKey: Keys.downloadArtwork) + set(bool: newValue, forKey: Keys.downloadArtwork) } } @@ -289,7 +310,7 @@ extension VLCDefaults { userDefaults.bool(forKey: Keys.enableMediaCellTextScrolling) } set { - userDefaults.set(newValue, forKey: Keys.enableMediaCellTextScrolling) + set(bool: newValue, forKey: Keys.enableMediaCellTextScrolling) } } @@ -298,7 +319,7 @@ extension VLCDefaults { userDefaults.bool(forKey: Keys.equalizerProfileDisabled) } set { - userDefaults.set(newValue, forKey: Keys.equalizerProfileDisabled) + set(bool: newValue, forKey: Keys.equalizerProfileDisabled) } } @@ -307,7 +328,7 @@ extension VLCDefaults { userDefaults.bool(forKey: Keys.equalizerSnapBands) } set { - userDefaults.set(newValue, forKey: Keys.equalizerSnapBands) + set(bool: newValue, forKey: Keys.equalizerSnapBands) } } @@ -316,7 +337,7 @@ extension VLCDefaults { userDefaults.bool(forKey: Keys.forceSMBV1) } set { - userDefaults.set(newValue, forKey: Keys.forceSMBV1) + set(bool: newValue, forKey: Keys.forceSMBV1) } } @@ -325,7 +346,7 @@ extension VLCDefaults { userDefaults.bool(forKey: Keys.hasActiveSubscription) } set { - userDefaults.set(newValue, forKey: Keys.hasActiveSubscription) + set(bool: newValue, forKey: Keys.hasActiveSubscription) } } @@ -344,7 +365,7 @@ extension VLCDefaults { userDefaults.bool(forKey: Keys.hideLibraryInFilesApp) } set { - userDefaults.set(newValue, forKey: Keys.hideLibraryInFilesApp) + set(bool: newValue, forKey: Keys.hideLibraryInFilesApp) } } @@ -353,7 +374,7 @@ extension VLCDefaults { userDefaults.bool(forKey: Keys.lockscreenSkip) } set { - userDefaults.set(newValue, forKey: Keys.lockscreenSkip) + set(bool: newValue, forKey: Keys.lockscreenSkip) } } @@ -362,7 +383,7 @@ extension VLCDefaults { userDefaults.bool(forKey: Keys.mediaLibraryServiceDidForceRescan) } set { - userDefaults.set(newValue, forKey: Keys.mediaLibraryServiceDidForceRescan) + set(bool: newValue, forKey: Keys.mediaLibraryServiceDidForceRescan) } } @@ -371,7 +392,7 @@ extension VLCDefaults { userDefaults.bool(forKey: Keys.networkRTSPTCP) } set { - userDefaults.set(newValue, forKey: Keys.networkRTSPTCP) + set(bool: newValue, forKey: Keys.networkRTSPTCP) } } @@ -380,7 +401,7 @@ extension VLCDefaults { userDefaults.bool(forKey: Keys.pauseWhenShowingControls) } set { - userDefaults.set(newValue, forKey: Keys.pauseWhenShowingControls) + set(bool: newValue, forKey: Keys.pauseWhenShowingControls) } } @@ -389,7 +410,7 @@ extension VLCDefaults { userDefaults.bool(forKey: Keys.playbackForwardBackwardEqual) } set { - userDefaults.set(newValue, forKey: Keys.playbackForwardBackwardEqual) + set(bool: newValue, forKey: Keys.playbackForwardBackwardEqual) } } @@ -398,7 +419,7 @@ extension VLCDefaults { userDefaults.bool(forKey: Keys.playbackLongTouchSpeedUp) } set { - userDefaults.set(newValue, forKey: Keys.playbackLongTouchSpeedUp) + set(bool: newValue, forKey: Keys.playbackLongTouchSpeedUp) } } @@ -407,7 +428,7 @@ extension VLCDefaults { userDefaults.bool(forKey: Keys.playbackTapSwipeEqual) } set { - userDefaults.set(newValue, forKey: Keys.playbackTapSwipeEqual) + set(bool: newValue, forKey: Keys.playbackTapSwipeEqual) } } @@ -416,7 +437,7 @@ extension VLCDefaults { userDefaults.bool(forKey: Keys.playerIsShuffleEnabled) } set { - userDefaults.set(newValue, forKey: Keys.playerIsShuffleEnabled) + set(bool: newValue, forKey: Keys.playerIsShuffleEnabled) } } @@ -425,7 +446,7 @@ extension VLCDefaults { userDefaults.bool(forKey: Keys.playerShouldRememberBrightness) } set { - userDefaults.set(newValue, forKey: Keys.playerShouldRememberBrightness) + set(bool: newValue, forKey: Keys.playerShouldRememberBrightness) } } @@ -434,7 +455,7 @@ extension VLCDefaults { userDefaults.bool(forKey: Keys.playerShouldRememberState) } set { - userDefaults.set(newValue, forKey: Keys.playerShouldRememberState) + set(bool: newValue, forKey: Keys.playerShouldRememberState) } } @@ -443,7 +464,7 @@ extension VLCDefaults { userDefaults.bool(forKey: Keys.passcodeEnableBiometricAuth) } set { - userDefaults.set(newValue, forKey: Keys.passcodeEnableBiometricAuth) + set(bool: newValue, forKey: Keys.passcodeEnableBiometricAuth) } } @@ -452,7 +473,7 @@ extension VLCDefaults { userDefaults.bool(forKey: Keys.passcodeOn) } set { - userDefaults.set(newValue, forKey: Keys.passcodeOn) + set(bool: newValue, forKey: Keys.passcodeOn) } } @@ -461,7 +482,7 @@ extension VLCDefaults { userDefaults.bool(forKey: Keys.playerShowPlaybackSpeedShortcut) } set { - userDefaults.set(newValue, forKey: Keys.playerShowPlaybackSpeedShortcut) + set(bool: newValue, forKey: Keys.playerShowPlaybackSpeedShortcut) } } @@ -471,7 +492,7 @@ extension VLCDefaults { userDefaults.bool(forKey: Keys.playerUIShouldHide) } set { - userDefaults.set(newValue, forKey: Keys.playerUIShouldHide) + set(bool: newValue, forKey: Keys.playerUIShouldHide) } } @@ -480,7 +501,7 @@ extension VLCDefaults { userDefaults.bool(forKey: Keys.playlistPlayNextItem) } set { - userDefaults.set(newValue, forKey: Keys.playlistPlayNextItem) + set(bool: newValue, forKey: Keys.playlistPlayNextItem) } } @@ -489,7 +510,7 @@ extension VLCDefaults { userDefaults.bool(forKey: Keys.playPauseGesture) } set { - userDefaults.set(newValue, forKey: Keys.playPauseGesture) + set(bool: newValue, forKey: Keys.playPauseGesture) } } @@ -498,7 +519,7 @@ extension VLCDefaults { userDefaults.bool(forKey: Keys.restoreLastPlayedMedia) } set { - userDefaults.set(newValue, forKey: Keys.restoreLastPlayedMedia) + set(bool: newValue, forKey: Keys.restoreLastPlayedMedia) } } @@ -507,7 +528,7 @@ extension VLCDefaults { userDefaults.bool(forKey: Keys.remoteControlSkip) } set { - userDefaults.set(newValue, forKey: Keys.remoteControlSkip) + set(bool: newValue, forKey: Keys.remoteControlSkip) } } @@ -516,7 +537,7 @@ extension VLCDefaults { userDefaults.bool(forKey: Keys.rotationLock) } set { - userDefaults.set(newValue, forKey: Keys.rotationLock) + set(bool: newValue, forKey: Keys.rotationLock) } } @@ -525,7 +546,7 @@ extension VLCDefaults { userDefaults.bool(forKey: Keys.saveDebugLogs) } set { - userDefaults.set(newValue, forKey: Keys.saveDebugLogs) + set(bool: newValue, forKey: Keys.saveDebugLogs) } } @@ -534,7 +555,7 @@ extension VLCDefaults { userDefaults.bool(forKey: Keys.seekGesture) } set { - userDefaults.set(newValue, forKey: Keys.seekGesture) + set(bool: newValue, forKey: Keys.seekGesture) } } @@ -543,7 +564,7 @@ extension VLCDefaults { userDefaults.bool(forKey: Keys.showArtworks) } set { - userDefaults.set(newValue, forKey: Keys.showArtworks) + set(bool: newValue, forKey: Keys.showArtworks) } } @@ -552,7 +573,7 @@ extension VLCDefaults { userDefaults.bool(forKey: Keys.showRemainingTime) } set { - userDefaults.set(newValue, forKey: Keys.showRemainingTime) + set(bool: newValue, forKey: Keys.showRemainingTime) } } @@ -561,7 +582,7 @@ extension VLCDefaults { userDefaults.bool(forKey: Keys.showThumbnails) } set { - userDefaults.set(newValue, forKey: Keys.showThumbnails) + set(bool: newValue, forKey: Keys.showThumbnails) } } @@ -570,7 +591,7 @@ extension VLCDefaults { userDefaults.bool(forKey: Keys.stretchAudio) } set { - userDefaults.set(newValue, forKey: Keys.stretchAudio) + set(bool: newValue, forKey: Keys.stretchAudio) } } @@ -579,7 +600,7 @@ extension VLCDefaults { userDefaults.bool(forKey: Keys.subtitlesBoldFont) } set { - userDefaults.set(newValue, forKey: Keys.subtitlesBoldFont) + set(bool: newValue, forKey: Keys.subtitlesBoldFont) } } @@ -588,7 +609,7 @@ extension VLCDefaults { userDefaults.bool(forKey: Keys.videoFullscreenPlayback) } set { - userDefaults.set(newValue, forKey: Keys.videoFullscreenPlayback) + set(bool: newValue, forKey: Keys.videoFullscreenPlayback) } } @@ -597,7 +618,7 @@ extension VLCDefaults { userDefaults.bool(forKey: Keys.volumeGesture) } set { - userDefaults.set(newValue, forKey: Keys.volumeGesture) + set(bool: newValue, forKey: Keys.volumeGesture) } } @@ -606,7 +627,7 @@ extension VLCDefaults { userDefaults.bool(forKey: Keys.wifiSharingIPv6) } set { - userDefaults.set(newValue, forKey: Keys.wifiSharingIPv6) + set(bool: newValue, forKey: Keys.wifiSharingIPv6) } } @@ -617,7 +638,7 @@ extension VLCDefaults { userDefaults.integer(forKey: Keys.castingConversionQuality) } set { - userDefaults.set(newValue, forKey: Keys.castingConversionQuality) + set(integer: newValue, forKey: Keys.castingConversionQuality) } } @@ -626,7 +647,7 @@ extension VLCDefaults { userDefaults.integer(forKey: Keys.continueAudioPlayback) } set { - userDefaults.set(newValue, forKey: Keys.continueAudioPlayback) + set(integer: newValue, forKey: Keys.continueAudioPlayback) } } @@ -635,7 +656,7 @@ extension VLCDefaults { userDefaults.integer(forKey: Keys.continuePlayback) } set { - userDefaults.set(newValue, forKey: Keys.continuePlayback) + set(integer: newValue, forKey: Keys.continuePlayback) } } @@ -644,7 +665,7 @@ extension VLCDefaults { userDefaults.float(forKey: Keys.defaultPreampLevel) } set { - userDefaults.set(newValue, forKey: Keys.defaultPreampLevel) + set(float: newValue, forKey: Keys.defaultPreampLevel) } } @@ -653,7 +674,7 @@ extension VLCDefaults { userDefaults.integer(forKey: Keys.deinterlace) } set { - userDefaults.set(newValue, forKey: Keys.deinterlace) + set(integer: newValue, forKey: Keys.deinterlace) } } @@ -662,7 +683,7 @@ extension VLCDefaults { userDefaults.integer(forKey: Keys.equalizerProfile) } set { - userDefaults.set(newValue, forKey: Keys.equalizerProfile) + set(integer: newValue, forKey: Keys.equalizerProfile) } } @@ -671,7 +692,7 @@ extension VLCDefaults { userDefaults.integer(forKey: Keys.hasNaggedThisMonth) } set { - userDefaults.set(newValue, forKey: Keys.hasNaggedThisMonth) + set(integer: newValue, forKey: Keys.hasNaggedThisMonth) } } @@ -692,7 +713,7 @@ extension VLCDefaults { userDefaults.integer(forKey: Keys.playbackBackwardSkipLength) } set { - userDefaults.set(newValue, forKey: Keys.playbackBackwardSkipLength) + set(integer: newValue, forKey: Keys.playbackBackwardSkipLength) } } @@ -701,7 +722,7 @@ extension VLCDefaults { userDefaults.integer(forKey: Keys.playbackBackwardSkipLengthSwipe) } set { - userDefaults.set(newValue, forKey: Keys.playbackBackwardSkipLengthSwipe) + set(integer: newValue, forKey: Keys.playbackBackwardSkipLengthSwipe) } } @@ -710,7 +731,7 @@ extension VLCDefaults { userDefaults.integer(forKey: Keys.playbackForwardSkipLength) } set { - userDefaults.set(newValue, forKey: Keys.playbackForwardSkipLength) + set(integer: newValue, forKey: Keys.playbackForwardSkipLength) } } @@ -719,7 +740,7 @@ extension VLCDefaults { userDefaults.integer(forKey: Keys.playbackForwardSkipLengthSwipe) } set { - userDefaults.set(newValue, forKey: Keys.playbackForwardSkipLengthSwipe) + set(integer: newValue, forKey: Keys.playbackForwardSkipLengthSwipe) } } @@ -728,7 +749,7 @@ extension VLCDefaults { userDefaults.float(forKey: Keys.playbackSpeedDefaultValue) } set { - userDefaults.set(newValue, forKey: Keys.playbackSpeedDefaultValue) + set(float: newValue, forKey: Keys.playbackSpeedDefaultValue) } } @@ -741,7 +762,7 @@ extension VLCDefaults { } set { if let newValue = newValue { - userDefaults.set(newValue, forKey: Keys.playerBrightness) + set(float: newValue, forKey: Keys.playerBrightness) } else { userDefaults.removeObject(forKey: Keys.playerBrightness) } @@ -753,7 +774,7 @@ extension VLCDefaults { userDefaults.integer(forKey: Keys.playerControlDuration) } set { - userDefaults.set(newValue, forKey: Keys.playerControlDuration) + set(integer: newValue, forKey: Keys.playerControlDuration) } } @@ -762,7 +783,7 @@ extension VLCDefaults { userDefaults.integer(forKey: Keys.tabBarIndex) } set { - userDefaults.set(newValue, forKey: Keys.tabBarIndex) + set(integer: newValue, forKey: Keys.tabBarIndex) } } @@ -774,7 +795,7 @@ extension VLCDefaults { return AppTheme(rawValue: v) ?? DefaultValues.appTheme } set { - userDefaults.set(newValue.rawValue, forKey: Keys.appTheme) + set(integer: newValue.rawValue, forKey: Keys.appTheme) } } @@ -820,7 +841,7 @@ extension VLCDefaults { return HardwareDecoding(rawValue: v) ?? .hardware } set { - userDefaults.set(newValue.rawValue, forKey: Keys.hardwareDecoding) + set(string: newValue.rawValue, forKey: Keys.hardwareDecoding) } } @@ -863,7 +884,7 @@ extension VLCDefaults { return NetworkCaching(rawValue: v) ?? .normal } set { - userDefaults.set(newValue.rawValue, forKey: Keys.networkCaching) + set(integer: newValue.rawValue, forKey: Keys.networkCaching) } } @@ -876,7 +897,7 @@ extension VLCDefaults { userDefaults.string(forKey: Keys.networkSatIPChannelListUrl) ?? DefaultValues.networkSatIPChannelListUrl } set { - userDefaults.set(newValue, forKey: Keys.networkSatIPChannelListUrl) + set(string: newValue, forKey: Keys.networkSatIPChannelListUrl) } } @@ -886,7 +907,7 @@ extension VLCDefaults { return VLCRepeatMode(rawValue: v) ?? DefaultValues.playerRepeatMode } set { - userDefaults.set(newValue, forKey: Keys.playerIsRepeatEnabled) + set(integer: newValue.rawValue, forKey: Keys.playerIsRepeatEnabled) } } @@ -895,7 +916,7 @@ extension VLCDefaults { userDefaults.string(forKey: Keys.textEncoding) ?? DefaultValues.textEncoding } set { - userDefaults.set(newValue, forKey: Keys.textEncoding) + set(string: newValue, forKey: Keys.textEncoding) } } @@ -905,7 +926,7 @@ extension VLCDefaults { return SkipLoopFilter(rawValue: v) ?? DefaultValues.skipLoopFilter } set { - userDefaults.set(newValue, forKey: Keys.skipLoopFilter) + set(integer: newValue.rawValue, forKey: Keys.skipLoopFilter) } } @@ -920,7 +941,7 @@ extension VLCDefaults { userDefaults.string(forKey: Keys.subtitlesFont) ?? DefaultValues.subtitlesFont } set { - userDefaults.set(newValue, forKey: Keys.subtitlesFont) + set(string: newValue, forKey: Keys.subtitlesFont) } } @@ -929,7 +950,7 @@ extension VLCDefaults { userDefaults.string(forKey: Keys.subtitlesFontColor) ?? DefaultValues.subtitlesFontColor } set { - userDefaults.set(newValue, forKey: Keys.subtitlesFontColor) + set(string: newValue, forKey: Keys.subtitlesFontColor) } } @@ -938,7 +959,7 @@ extension VLCDefaults { userDefaults.string(forKey: Keys.subtitlesFontSize) ?? DefaultValues.subtitlesFontSize } set { - userDefaults.set(newValue, forKey: Keys.subtitlesFontSize) + set(string: newValue, forKey: Keys.subtitlesFontSize) } } @@ -1032,6 +1053,7 @@ extension VLCDefaults { case bright = 0 case dark = 1 case system = 2 + case black = 3 } } diff --git a/Sources/UI Elements/PresentationTheme.swift b/Sources/UI Elements/PresentationTheme.swift index 6ecf715e8..bbf2e92f1 100644 --- a/Sources/UI Elements/PresentationTheme.swift +++ b/Sources/UI Elements/PresentationTheme.swift @@ -107,7 +107,7 @@ enum PresentationThemeType: Int { static func from(appTheme: VLCDefaults.AppTheme) -> PresentationThemeType { switch appTheme { - case .dark: + case .dark, .black: return .dark case .bright: return .bright -- GitLab From ffe706a64e83f7e2695ee2441ae7642de161bb36 Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Mon, 3 Mar 2025 20:07:44 -0500 Subject: [PATCH 93/97] MR feedback. --- Sources/Headers/VLCConstants.h | 3 ++- Sources/Headers/VLCTVConstants.h | 3 ++- Sources/Helpers/VLCDefaults.swift | 4 ++-- .../General/VLCLocalNetworkServiceBrowserMediaDiscoverer.m | 2 +- Sources/Playback/Control/VLCPlaybackService.m | 4 ++-- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index d2cec16f9..55b3a1856 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -17,6 +17,7 @@ #define kVLCSubtitlesCacheFolderName @"cached-subtitles" #define kVLCSettingNetworkSatIPChannelList @"satip-channelist" #define kVLCSettingNetworkSatIPChannelListCustom @"CustomList" +#define kVLCSettingNetworkSatIPChannelListUrl @"satip-channellist-url" #define kVLCSettingLastUsedSubtitlesSearchLanguage @"kVLCSettingLastUsedSubtitlesSearchLanguage" #define kVLCRecentURLs @"recent-urls" @@ -24,7 +25,7 @@ #define kVLCPrivateWebStreaming @"private-streaming" #define kVLChttpScanSubtitle @"http-scan-subtitle" #define kVLCHTTPUploadDirectory @"Upload" - +#define kVLCSettingStretchAudio @"audio-time-stretch" #define kVLCLastPlayedMediaIdentifier @"LastPlayedMediaIdentifier" #define kVLCPlayerOpenInMiniPlayer @"OpenInMiniPlayer" diff --git a/Sources/Headers/VLCTVConstants.h b/Sources/Headers/VLCTVConstants.h index 7f14f526f..124bc9d73 100644 --- a/Sources/Headers/VLCTVConstants.h +++ b/Sources/Headers/VLCTVConstants.h @@ -28,7 +28,6 @@ #define kVLCSettingNetworkSatIPChannelList @"satip-channelist" #define kVLCSettingNetworkSatIPChannelListCustom @"CustomList" -/* deprecated */ #define kVLCSettingNetworkSatIPChannelListUrl @"satip-channellist-url" #define kVLCSubtitlesCacheFolderName @"cached-subtitles" @@ -36,6 +35,8 @@ #define kVLCSettingSaveHTTPUploadServerStatus @"isHTTPServerOn" #define kVLCSettingUseSPDIF @"kVLCSettingUseSPDIF" +#define kVLCSettingStretchAudio @"audio-time-stretch" + #define kVLCLastPlayedMediaIdentifier @"LastPlayedMediaIdentifier" #define kVLCPlayerOpenInMiniPlayer @"OpenInMiniPlayer" diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index b22e12aa2..cad88791c 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -1125,7 +1125,7 @@ fileprivate enum Keys { static let mediaLibraryServiceDidForceRescan = "MediaLibraryDidForceRescan" static let networkCaching = "network-caching" static let networkRTSPTCP = "rtsp-tcp" - static let networkSatIPChannelListUrl = "satip-channellist-url" + static let networkSatIPChannelListUrl = kVLCSettingNetworkSatIPChannelListUrl static let numberOfLaunches = "kVLCNumberOfLaunches" static let passcodeEnableBiometricAuth = "EnableBiometricAuth" static let passcodeOn = "PasscodeProtection" @@ -1157,7 +1157,7 @@ fileprivate enum Keys { static let showRemainingTime = "show-remaining-time" static let showThumbnails = "ShowThumbnails" static let skipLoopFilter = "avcodec-skiploopfilter" - static let stretchAudio = "audio-time-stretch" + static let stretchAudio = kVLCSettingStretchAudio static let subtitlesBoldFont = "quartztext-bold" static let subtitlesFont = "quartztext-font" static let subtitlesFontColor = "quartztext-color" diff --git a/Sources/Network/Server Browsing/Data/Protocols/General/VLCLocalNetworkServiceBrowserMediaDiscoverer.m b/Sources/Network/Server Browsing/Data/Protocols/General/VLCLocalNetworkServiceBrowserMediaDiscoverer.m index 3aa41d261..94ccdc73b 100644 --- a/Sources/Network/Server Browsing/Data/Protocols/General/VLCLocalNetworkServiceBrowserMediaDiscoverer.m +++ b/Sources/Network/Server Browsing/Data/Protocols/General/VLCLocalNetworkServiceBrowserMediaDiscoverer.m @@ -46,7 +46,7 @@ NSString *satipURLstring = VLCDefaults.shared.networkSatIPChannelListUrl; NSMutableArray *libVLCOptions = [NSMutableArray array]; if (satipURLstring.length > 0) { - [libVLCOptions addObject:[NSString stringWithFormat:@"--satip-channellist-url=%@", satipURLstring]]; + [libVLCOptions addObject:[NSString stringWithFormat:@"--%@=%@", kVLCSettingNetworkSatIPChannelListUrl, satipURLstring]]; [libVLCOptions addObject:[NSString stringWithFormat:@"--%@=%@", kVLCSettingNetworkSatIPChannelList, kVLCSettingNetworkSatIPChannelListCustom]]; } NSString *multicastInterfaceName = [[[VLCAppCoordinator sharedInstance] httpUploaderController] nameOfUsedNetworkInterface]; diff --git a/Sources/Playback/Control/VLCPlaybackService.m b/Sources/Playback/Control/VLCPlaybackService.m index c213c9641..2461fd098 100644 --- a/Sources/Playback/Control/VLCPlaybackService.m +++ b/Sources/Playback/Control/VLCPlaybackService.m @@ -256,7 +256,7 @@ NSString *const VLCLastPlaylistPlayedMedia = @"LastPlaylistPlayedMedia"; } #endif if (!audioTimeStretch) { - [libVLCOptions addObject:@"--no-audio-time-stretch"]; + [libVLCOptions addObject:[NSString stringWithFormat:@"--no-%@", kVLCSettingStretchAudio]]; } if (libVLCOptions.count > 0) { _listPlayer = [[VLCMediaListPlayer alloc] initWithOptions:libVLCOptions @@ -315,7 +315,7 @@ NSString *const VLCLastPlaylistPlayedMedia = @"LastPlaylistPlayedMedia"; CGFloat defaultPlaybackSpeed = VLCDefaults.shared.playbackSpeedDefaultValue; if (defaultPlaybackSpeed != 0.) [_mediaPlayer setRate: defaultPlaybackSpeed]; - int deinterlace = VLCDefaults.shared.deinterlace; + int deinterlace = (int)VLCDefaults.shared.deinterlace; [_mediaPlayer setDeinterlace:deinterlace withFilter:@"blend"]; [_listPlayer setMediaList:self.mediaList]; -- GitLab From 2b1ca490180711836259da7bf60dc7047665feac Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Mon, 3 Mar 2025 20:23:15 -0500 Subject: [PATCH 94/97] Fix a missed case from the previous commit. --- Sources/Headers/VLCConstants.h | 3 ++- Sources/Headers/VLCTVConstants.h | 3 +++ Sources/Helpers/VLCDefaults.swift | 2 +- Sources/Playback/Control/VLCPlaybackService.m | 4 ++-- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index 55b3a1856..442157ed1 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -19,7 +19,8 @@ #define kVLCSettingNetworkSatIPChannelListCustom @"CustomList" #define kVLCSettingNetworkSatIPChannelListUrl @"satip-channellist-url" #define kVLCSettingLastUsedSubtitlesSearchLanguage @"kVLCSettingLastUsedSubtitlesSearchLanguage" - +#define kVLCSettingCastingAudioPassthrough @"sout-chromecast-audio-passthrough" +#define kVLCSettingCastingConversionQuality @"sout-chromecast-conversion-quality" #define kVLCRecentURLs @"recent-urls" #define kVLCRecentURLTitles @"recent-url-titles" #define kVLCPrivateWebStreaming @"private-streaming" diff --git a/Sources/Headers/VLCTVConstants.h b/Sources/Headers/VLCTVConstants.h index 124bc9d73..e2c9d0997 100644 --- a/Sources/Headers/VLCTVConstants.h +++ b/Sources/Headers/VLCTVConstants.h @@ -43,6 +43,9 @@ #define kVLCSettingLastUsedSubtitlesSearchLanguage @"kVLCSettingLastUsedSubtitlesSearchLanguage" +#define kVLCSettingCastingAudioPassthrough @"sout-chromecast-audio-passthrough" +#define kVLCSettingCastingConversionQuality @"sout-chromecast-conversion-quality" + #define kVLCfortvOSMovieDBKey @"" #define kVLCStoredServerList @"kVLCStoredServerList" diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index cad88791c..ddf63b8b3 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -1096,7 +1096,7 @@ fileprivate enum Keys { static let backupMediaLibrary = "BackupMediaLibrary" static let brightnessGesture = "EnableBrightnessGesture" static let castingAudioPassthrough = "sout-chromecast-audio-passthrough" - static let castingConversionQuality = "sout-chromecast-conversion-quality" + static let castingConversionQuality = kVLCSettingCastingConversionQuality static let closeGesture = "EnableCloseGesture" static let continueAudioInBackground = "BackgroundAudioPlayback" static let continueAudioPlayback = "ContinueAudioPlayback" diff --git a/Sources/Playback/Control/VLCPlaybackService.m b/Sources/Playback/Control/VLCPlaybackService.m index 2461fd098..85d8ffb85 100644 --- a/Sources/Playback/Control/VLCPlaybackService.m +++ b/Sources/Playback/Control/VLCPlaybackService.m @@ -249,10 +249,10 @@ NSString *const VLCLastPlaylistPlayedMedia = @"LastPlaylistPlayedMedia"; BOOL chromecastPassthrough = VLCDefaults.shared.castingAudioPassthrough; int chromecastQuality = (int)VLCDefaults.shared.castingConversionQuality; if (chromecastPassthrough) { - [libVLCOptions addObject:@"--sout-chromecast-audio-passthrough"]; + [libVLCOptions addObject:[@"--" stringByAppendingString:kVLCSettingCastingAudioPassthrough]]; } if (chromecastQuality != 2) { - [libVLCOptions addObject:[NSString stringWithFormat:@"--sout-chromecast-conversion-quality=%i", chromecastQuality]]; + [libVLCOptions addObject:[NSString stringWithFormat:@"--%@=%i", kVLCSettingCastingConversionQuality, chromecastQuality]]; } #endif if (!audioTimeStretch) { -- GitLab From 107d023cb729f370b9d1bb78dc5af04b101c7969 Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Fri, 7 Mar 2025 14:25:13 -0500 Subject: [PATCH 95/97] Improve feedback email body text generation --- Sources/About/AboutController.swift | 23 ++++++++++++++++++++--- Sources/Helpers/VLCDefaults.swift | 11 ++++++++++- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/Sources/About/AboutController.swift b/Sources/About/AboutController.swift index 5c833d849..e5d5c6955 100644 --- a/Sources/About/AboutController.swift +++ b/Sources/About/AboutController.swift @@ -182,7 +182,24 @@ class AboutController: UIViewController, MFMailComposeViewControllerDelegate, UI let bundleShortVersionString = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as! String let device = UIDevice.current let locale = NSLocale.autoupdatingCurrent - let prefilledFeedback = String(format: "\n\n\n----------------------------------------\n%@\nDevice: %@\nOS: %@ - %@\nLocale: %@ (%@)\nVLC app version: %@\nlibvlc version: %@\nhardware decoding: %i\nnetwork caching level: %i\nskip loop filter: %i\nRTSP over TCP: %i\nAudio time stretching: %i", + let messageFormat = """ + + + + ---------------------------------------- + %@ + Device: %@ + OS: %@ - %@ + Locale: %@ (%@) + VLC app version: %@ + libvlc version: %@ + hardware decoding: %@ + network caching level: %i + skip loop filter: %i + RTSP over TCP: %i + Audio time stretching: %i + """ + let prefilledFeedback = String(format: messageFormat, NSLocalizedString("FEEDBACK_EMAIL_BODY", comment: ""), generateDeviceIdentifier(), device.systemName, @@ -191,11 +208,11 @@ class AboutController: UIViewController, MFMailComposeViewControllerDelegate, UI locale.regionCode!, bundleShortVersionString, VLCLibrary.shared().changeset, - VLCDefaults.shared.hardwareDecoding == .hardware ? 0 : 1, // TODO: unsure + VLCDefaults.shared.hardwareDecoding.description, VLCDefaults.shared.networkCaching.rawValue, VLCDefaults.shared.skipLoopFilter.rawValue, VLCDefaults.shared.networkRTSPTCP ? 1 : 0, - VLCDefaults.shared.stretchAudio ? 1 : 0) // TODO: unsure + VLCDefaults.shared.stretchAudio ? 1 : 0) return prefilledFeedback } diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index ddf63b8b3..a06b4cc3b 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -1058,9 +1058,18 @@ extension VLCDefaults { } extension VLCDefaults { - enum HardwareDecoding: String { + enum HardwareDecoding: String, CustomStringConvertible { case software = "avcodec,all" case hardware = "" + + var description: String { + switch self { + case .software: + return "Software" + case .hardware: + return "Hardware" + } + } } } -- GitLab From 00d5e5fe668dfe56e7a4c4d175f04af59e8e8bed Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Fri, 7 Mar 2025 14:32:12 -0500 Subject: [PATCH 96/97] Use local variable for defaults --- Sources/About/AboutController.swift | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Sources/About/AboutController.swift b/Sources/About/AboutController.swift index e5d5c6955..8175dcec6 100644 --- a/Sources/About/AboutController.swift +++ b/Sources/About/AboutController.swift @@ -182,6 +182,7 @@ class AboutController: UIViewController, MFMailComposeViewControllerDelegate, UI let bundleShortVersionString = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as! String let device = UIDevice.current let locale = NSLocale.autoupdatingCurrent + let defaults = VLCDefaults.shared let messageFormat = """ @@ -208,11 +209,11 @@ class AboutController: UIViewController, MFMailComposeViewControllerDelegate, UI locale.regionCode!, bundleShortVersionString, VLCLibrary.shared().changeset, - VLCDefaults.shared.hardwareDecoding.description, - VLCDefaults.shared.networkCaching.rawValue, - VLCDefaults.shared.skipLoopFilter.rawValue, - VLCDefaults.shared.networkRTSPTCP ? 1 : 0, - VLCDefaults.shared.stretchAudio ? 1 : 0) + defaults.hardwareDecoding.description, + defaults.networkCaching.rawValue, + defaults.skipLoopFilter.rawValue, + defaults.networkRTSPTCP ? 1 : 0, + defaults.stretchAudio ? 1 : 0) return prefilledFeedback } -- GitLab From a96b4775745b7078a8360433c1fc0eb940d4900e Mon Sep 17 00:00:00 2001 From: Craig Reyenga <craig.reyenga@gmail.com> Date: Sun, 9 Mar 2025 11:10:39 -0400 Subject: [PATCH 97/97] Use constant for castingAudioPassthrough --- Sources/Helpers/VLCDefaults.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Helpers/VLCDefaults.swift b/Sources/Helpers/VLCDefaults.swift index a06b4cc3b..27b6fdbcc 100644 --- a/Sources/Helpers/VLCDefaults.swift +++ b/Sources/Helpers/VLCDefaults.swift @@ -1104,7 +1104,7 @@ fileprivate enum Keys { static let automaticallyPlayNextItem = "AutomaticallyPlayNextItem" static let backupMediaLibrary = "BackupMediaLibrary" static let brightnessGesture = "EnableBrightnessGesture" - static let castingAudioPassthrough = "sout-chromecast-audio-passthrough" + static let castingAudioPassthrough = kVLCSettingCastingAudioPassthrough static let castingConversionQuality = kVLCSettingCastingConversionQuality static let closeGesture = "EnableCloseGesture" static let continueAudioInBackground = "BackgroundAudioPlayback" -- GitLab