From 88cc1e2022547f9f8ce67e18d3e6c557f12fccdf Mon Sep 17 00:00:00 2001 From: Ethan Pippin Date: Wed, 18 Aug 2021 00:24:14 -0600 Subject: [PATCH] Conform to Defaults.Serializable --- JellyfinPlayer/VideoPlayer.swift | 6 ++---- Shared/Extensions/DefaultsExtension.swift | 4 ++-- Shared/Objects/VideoPlayerJumpLength.swift | 3 ++- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/JellyfinPlayer/VideoPlayer.swift b/JellyfinPlayer/VideoPlayer.swift index b809bd6a..cb76ed87 100644 --- a/JellyfinPlayer/VideoPlayer.swift +++ b/JellyfinPlayer/VideoPlayer.swift @@ -77,12 +77,10 @@ class PlayerViewController: UIViewController, GCKDiscoveryManagerListener, GCKRe var audioTrackArray: [AudioTrack] = [] let playbackSpeeds: [Float] = [0.25, 0.5, 0.75, 1.0, 1.25, 1.5, 1.75, 2.0] var jumpForwardLength: VideoPlayerJumpLength { - let storedJumpForwardLength = Defaults[.videoPlayerJumpForward] - return VideoPlayerJumpLength(rawValue: storedJumpForwardLength)! + return Defaults[.videoPlayerJumpForward] } var jumpBackwardLength: VideoPlayerJumpLength { - let storedJumpBackwardLength = Defaults[.videoPlayerJumpBackward] - return VideoPlayerJumpLength(rawValue: storedJumpBackwardLength)! + return Defaults[.videoPlayerJumpBackward] } var manifest: BaseItemDto = BaseItemDto() diff --git a/Shared/Extensions/DefaultsExtension.swift b/Shared/Extensions/DefaultsExtension.swift index 246775d8..a3c30e46 100644 --- a/Shared/Extensions/DefaultsExtension.swift +++ b/Shared/Extensions/DefaultsExtension.swift @@ -17,6 +17,6 @@ extension Defaults.Keys { static let autoSelectSubtitlesLangCode = Key("AutoSelectSubtitlesLangCode", default: "Auto") static let autoSelectAudioLangCode = Key("AutoSelectAudioLangCode", default: "Auto") static let appAppearance = Key("appAppearance", default: AppAppearance.system.rawValue) - static let videoPlayerJumpForward = Key("videoPlayerJumpForward", default: VideoPlayerJumpLength.thirty.rawValue) - static let videoPlayerJumpBackward = Key("videoPlayerJumpBackward", default: VideoPlayerJumpLength.thirty.rawValue) + static let videoPlayerJumpForward = Key("videoPlayerJumpForward", default: .thirty) + static let videoPlayerJumpBackward = Key("videoPlayerJumpBackward", default: .thirty) } diff --git a/Shared/Objects/VideoPlayerJumpLength.swift b/Shared/Objects/VideoPlayerJumpLength.swift index 394ec551..7f2e9008 100644 --- a/Shared/Objects/VideoPlayerJumpLength.swift +++ b/Shared/Objects/VideoPlayerJumpLength.swift @@ -8,8 +8,9 @@ */ import UIKit +import Defaults -enum VideoPlayerJumpLength: Int32, CaseIterable { +enum VideoPlayerJumpLength: Int32, CaseIterable, Defaults.Serializable { case thirty = 30 case fifteen = 15 case ten = 10