diff --git a/JellyfinPlayer/ConnectToServerView.swift b/JellyfinPlayer/ConnectToServerView.swift index 4be78c01..690a3d65 100644 --- a/JellyfinPlayer/ConnectToServerView.swift +++ b/JellyfinPlayer/ConnectToServerView.swift @@ -274,7 +274,7 @@ struct ConnectToServerView: View { ForEach(publicUsers, id: \.id) { publicUser in HStack { Button() { - if (publicUser.hasPassword ?? true) { + if publicUser.hasPassword ?? true { lastPublicUsers = publicUsers username = publicUser.name ?? "" usernameDisabled = true diff --git a/JellyfinPlayer/ContentView.swift b/JellyfinPlayer/ContentView.swift index ed5e2e46..716fa533 100644 --- a/JellyfinPlayer/ContentView.swift +++ b/JellyfinPlayer/ContentView.swift @@ -147,7 +147,7 @@ struct ContentView: View { .environmentObject(globalData) } else { if !jsi.did { - if(isLoading) { + if isLoading { ProgressView() } else { VStack { @@ -158,7 +158,7 @@ struct ContentView: View { Spacer().frame(height: orientationInfo.orientation == .portrait ? 0 : 16) ContinueWatchingView() NextUpView() - + ForEach(librariesShowRecentlyAdded, id: \.self) { library_id in VStack(alignment: .leading) { HStack { @@ -169,7 +169,7 @@ struct ContentView: View { LibraryView(usingParentID: library_id, title: library_names[library_id] ?? "", usingFilters: recentFilterSet) }) { - HStack() { + HStack { Text("See All").font(.subheadline).fontWeight(.bold) Image(systemName: "chevron.right").font(Font.subheadline.bold()) } @@ -178,7 +178,7 @@ struct ContentView: View { LatestMediaView(usingParentID: library_id) }.padding(EdgeInsets(top: 4, leading: 0, bottom: 0, trailing: 0)) } - + Spacer().frame(height: UIDevice.current.userInterfaceIdiom == .phone ? 20 : 30) } .navigationTitle("Home") diff --git a/JellyfinPlayer/LatestMediaView.swift b/JellyfinPlayer/LatestMediaView.swift index 21140641..80c53009 100644 --- a/JellyfinPlayer/LatestMediaView.swift +++ b/JellyfinPlayer/LatestMediaView.swift @@ -61,7 +61,7 @@ struct LatestMediaView: View { .fontWeight(.semibold) .foregroundColor(.primary) .lineLimit(1) - if(item.productionYear != nil) { + if item.productionYear != nil { Text(String(item.productionYear ?? 0)) .foregroundColor(.secondary) .font(.caption) diff --git a/JellyfinPlayer/LibrarySearchView.swift b/JellyfinPlayer/LibrarySearchView.swift index 25adb040..df315d70 100644 --- a/JellyfinPlayer/LibrarySearchView.swift +++ b/JellyfinPlayer/LibrarySearchView.swift @@ -84,7 +84,7 @@ struct LibrarySearchView: View { .fontWeight(.semibold) .foregroundColor(.primary) .lineLimit(1) - if(item.productionYear != nil) { + if item.productionYear != nil { Text(String(item.productionYear ?? 0)) .foregroundColor(.secondary) .font(.caption) diff --git a/JellyfinPlayer/LibraryView.swift b/JellyfinPlayer/LibraryView.swift index fdfcd64a..c7babc28 100644 --- a/JellyfinPlayer/LibraryView.swift +++ b/JellyfinPlayer/LibraryView.swift @@ -122,7 +122,7 @@ struct LibraryView: View { .fontWeight(.semibold) .foregroundColor(.primary) .lineLimit(1) - if(item.productionYear != nil) { + if item.productionYear != nil { Text(String(item.productionYear ?? 0)) .foregroundColor(.secondary) .font(.caption) diff --git a/JellyfinPlayer/MovieItemView.swift b/JellyfinPlayer/MovieItemView.swift index 742203d1..f3f54dbe 100644 --- a/JellyfinPlayer/MovieItemView.swift +++ b/JellyfinPlayer/MovieItemView.swift @@ -96,7 +96,7 @@ struct MovieItemView: View { .fixedSize(horizontal: false, vertical: true) .offset(y: -4) HStack { - if(item.productionYear != nil) { + if item.productionYear != nil { Text(String(item.productionYear ?? 0)).font(.subheadline) .fontWeight(.medium) .foregroundColor(.secondary) @@ -313,7 +313,7 @@ struct MovieItemView: View { .offset(x: 14, y: 0) Spacer().frame(height: 1) HStack { - if(item.productionYear != nil) { + if item.productionYear != nil { Text(String(item.productionYear ?? 0)).font(.subheadline) .fontWeight(.medium) .foregroundColor(.secondary) diff --git a/JellyfinPlayer/SeasonItemView.swift b/JellyfinPlayer/SeasonItemView.swift index 62853887..82d6165f 100644 --- a/JellyfinPlayer/SeasonItemView.swift +++ b/JellyfinPlayer/SeasonItemView.swift @@ -296,7 +296,7 @@ struct SeasonItemView: View { } var body: some View { - if(isLoading) { + if isLoading { ProgressView() .onAppear(perform: onAppear) } else { diff --git a/JellyfinPlayer/SeriesItemView.swift b/JellyfinPlayer/SeriesItemView.swift index e44d0125..3e14daa5 100644 --- a/JellyfinPlayer/SeriesItemView.swift +++ b/JellyfinPlayer/SeriesItemView.swift @@ -51,7 +51,7 @@ struct SeriesItemView: View { @State private var tracks: [GridItem] = [] var body: some View { - if(isLoading) { + if isLoading { ProgressView() .onAppear(perform: onAppear) } else { diff --git a/JellyfinPlayer/VideoPlayer.swift b/JellyfinPlayer/VideoPlayer.swift index 419d5920..6c89fdae 100644 --- a/JellyfinPlayer/VideoPlayer.swift +++ b/JellyfinPlayer/VideoPlayer.swift @@ -262,7 +262,7 @@ class PlayerViewController: UIViewController, VLCMediaDelegate, VLCMediaPlayerDe // View has loaded. // Rotate to landscape only if necessary - + UIViewController.attemptRotationToDeviceOrientation() mediaPlayer.perform(Selector(("setTextRendererFontSize:")), with: 14) @@ -310,7 +310,7 @@ class PlayerViewController: UIViewController, VLCMediaDelegate, VLCMediaPlayerDe for stream in mediaSource.mediaStreams! { if stream.type == .subtitle { var deliveryUrl: URL? - if(stream.deliveryMethod == .external) { + if stream.deliveryMethod == .external { deliveryUrl = URL(string: "\(globalData.server.baseURI!)\(stream.deliveryUrl!)")! } else { deliveryUrl = nil @@ -351,7 +351,7 @@ class PlayerViewController: UIViewController, VLCMediaDelegate, VLCMediaPlayerDe for stream in mediaSource.mediaStreams! { if stream.type == .subtitle { var deliveryUrl: URL? - if(stream.deliveryMethod == .external) { + if stream.deliveryMethod == .external { deliveryUrl = URL(string: "\(globalData.server.baseURI!)\(stream.deliveryUrl!)")! } else { deliveryUrl = nil @@ -381,26 +381,26 @@ class PlayerViewController: UIViewController, VLCMediaDelegate, VLCMediaPlayerDe mediaPlayer.media = VLCMedia(url: playbackItem.videoUrl) mediaPlayer.play() - - //1 second = 10,000,000 ticks - + + // 1 second = 10,000,000 ticks + let startTicks = round(Double(manifest.userData?.playbackPositionTicks ?? 0), toNearest: 10_000_000) let startSeconds = Int32(startTicks) / 10_000_000 mediaPlayer.jumpForward(startSeconds) - - //Pause and load captions into memory. + + // Pause and load captions into memory. mediaPlayer.pause() subtitleTrackArray.forEach { sub in if sub.id != -1 && sub.delivery == .external && sub.codec != "subrip" { mediaPlayer.addPlaybackSlave(sub.url!, type: .subtitle, enforce: false) } } - - //Wait for captions to load + + // Wait for captions to load delegate?.showLoadingView(self) while mediaPlayer.numberOfSubtitlesTracks != subtitleTrackArray.count - 1 {} - - //Select default track & resume playback + + // Select default track & resume playback mediaPlayer.currentVideoSubTitleIndex = selectedCaptionTrack mediaPlayer.pause() mediaPlayer.play() diff --git a/Shared/Extensions/APIExtensions.swift b/Shared/Extensions/APIExtensions.swift index 8ebc990f..3e086420 100644 --- a/Shared/Extensions/APIExtensions.swift +++ b/Shared/Extensions/APIExtensions.swift @@ -52,7 +52,7 @@ extension BaseItemDto { if self.primaryImageAspectRatio ?? 0.0 < 1.0 { imageType = "Backdrop" - if(!(self.backdropImageTags?.isEmpty ?? true)) { + if !(self.backdropImageTags?.isEmpty ?? true) { imageTag = (self.backdropImageTags ?? [""])[0] } } else { @@ -62,11 +62,11 @@ extension BaseItemDto { if imageTag == "" { imageType = "Backdrop" - if(!(self.parentBackdropImageTags?.isEmpty ?? true)) { + if !(self.parentBackdropImageTags?.isEmpty ?? true) { imageTag = (self.parentBackdropImageTags ?? [""])[0] } } - + let x = UIScreen.main.nativeScale * CGFloat(maxWidth) let urlString = "\(baseURL)/Items/\(self.id ?? "")/Images/\(imageType)?maxWidth=\(String(Int(x)))&quality=60&tag=\(imageTag)" return URL(string: urlString)!