mirror of
https://github.com/jellyfin/Swiftfin.git
synced 2024-11-23 14:10:01 +00:00
swiftformat
This commit is contained in:
parent
dd7ac40aaf
commit
bf79902b42
@ -26,7 +26,7 @@ final class LiveTVChannelsCoordinator: NavigationCoordinatable {
|
||||
}
|
||||
|
||||
func makeVideoPlayer(viewModel: VideoPlayerViewModel) -> NavigationViewCoordinator<VideoPlayerCoordinator> {
|
||||
NavigationViewCoordinator(VideoPlayerCoordinator(viewModel: viewModel))
|
||||
NavigationViewCoordinator(VideoPlayerCoordinator(viewModel: viewModel))
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
|
@ -21,7 +21,7 @@ final class LiveTVProgramsCoordinator: NavigationCoordinatable {
|
||||
var videoPlayer = makeVideoPlayer
|
||||
|
||||
func makeVideoPlayer(viewModel: VideoPlayerViewModel) -> NavigationViewCoordinator<VideoPlayerCoordinator> {
|
||||
NavigationViewCoordinator(VideoPlayerCoordinator(viewModel: viewModel))
|
||||
NavigationViewCoordinator(VideoPlayerCoordinator(viewModel: viewModel))
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
|
@ -189,18 +189,18 @@ final class LiveTVChannelsViewModel: ViewModel {
|
||||
func stopScheduleCheckTimer() {
|
||||
timer?.invalidate()
|
||||
}
|
||||
|
||||
func fetchVideoPlayerViewModel(item: BaseItemDto, completion: @escaping (VideoPlayerViewModel)->Void) {
|
||||
item.createVideoPlayerViewModel()
|
||||
.sink { completion in
|
||||
self.handleAPIRequestError(completion: completion)
|
||||
} receiveValue: { videoPlayerViewModels in
|
||||
if let viewModel = videoPlayerViewModels.first {
|
||||
completion(viewModel)
|
||||
}
|
||||
}
|
||||
.store(in: &self.cancellables)
|
||||
}
|
||||
|
||||
func fetchVideoPlayerViewModel(item: BaseItemDto, completion: @escaping (VideoPlayerViewModel) -> Void) {
|
||||
item.createVideoPlayerViewModel()
|
||||
.sink { completion in
|
||||
self.handleAPIRequestError(completion: completion)
|
||||
} receiveValue: { videoPlayerViewModels in
|
||||
if let viewModel = videoPlayerViewModels.first {
|
||||
completion(viewModel)
|
||||
}
|
||||
}
|
||||
.store(in: &self.cancellables)
|
||||
}
|
||||
}
|
||||
|
||||
extension Array {
|
||||
|
@ -197,16 +197,16 @@ final class LiveTVProgramsViewModel: ViewModel {
|
||||
})
|
||||
.store(in: &cancellables)
|
||||
}
|
||||
|
||||
func fetchVideoPlayerViewModel(item: BaseItemDto, completion: @escaping (VideoPlayerViewModel)->Void) {
|
||||
item.createVideoPlayerViewModel()
|
||||
.sink { completion in
|
||||
self.handleAPIRequestError(completion: completion)
|
||||
} receiveValue: { videoPlayerViewModels in
|
||||
if let viewModel = videoPlayerViewModels.first {
|
||||
completion(viewModel)
|
||||
}
|
||||
}
|
||||
.store(in: &self.cancellables)
|
||||
}
|
||||
|
||||
func fetchVideoPlayerViewModel(item: BaseItemDto, completion: @escaping (VideoPlayerViewModel) -> Void) {
|
||||
item.createVideoPlayerViewModel()
|
||||
.sink { completion in
|
||||
self.handleAPIRequestError(completion: completion)
|
||||
} receiveValue: { videoPlayerViewModels in
|
||||
if let viewModel = videoPlayerViewModels.first {
|
||||
completion(viewModel)
|
||||
}
|
||||
}
|
||||
.store(in: &self.cancellables)
|
||||
}
|
||||
}
|
||||
|
@ -140,7 +140,7 @@ final class VideoPlayerViewModel: ViewModel {
|
||||
// MARK: Current Time
|
||||
|
||||
var currentSeconds: Double {
|
||||
let runTimeTicks = item.runTimeTicks ?? 0
|
||||
let runTimeTicks = item.runTimeTicks ?? 0
|
||||
let videoDuration = Double(runTimeTicks / 10_000_000)
|
||||
return round(sliderPercentage * videoDuration)
|
||||
}
|
||||
@ -257,7 +257,7 @@ final class VideoPlayerViewModel: ViewModel {
|
||||
}
|
||||
|
||||
private func sliderPercentageChanged(newValue: Double) {
|
||||
let runTimeTicks = item.runTimeTicks ?? 0
|
||||
let runTimeTicks = item.runTimeTicks ?? 0
|
||||
let videoDuration = Double(runTimeTicks / 10_000_000)
|
||||
let secondsScrubbedRemaining = videoDuration - currentSeconds
|
||||
|
||||
|
@ -55,9 +55,9 @@ struct LiveTVChannelsView: View {
|
||||
let channel = item.channel
|
||||
if channel.type != "Folder" {
|
||||
Button {
|
||||
self.viewModel.fetchVideoPlayerViewModel(item: channel) { playerViewModel in
|
||||
self.router.route(to: \.videoPlayer, playerViewModel)
|
||||
}
|
||||
self.viewModel.fetchVideoPlayerViewModel(item: channel) { playerViewModel in
|
||||
self.router.route(to: \.videoPlayer, playerViewModel)
|
||||
}
|
||||
} label: {
|
||||
LiveTVChannelItemElement(channel: channel,
|
||||
program: item.program,
|
||||
|
@ -33,9 +33,9 @@ struct LiveTVProgramsView: View {
|
||||
if let chanId = item.channelId,
|
||||
let chan = viewModel.findChannel(id: chanId)
|
||||
{
|
||||
self.viewModel.fetchVideoPlayerViewModel(item: chan) { playerViewModel in
|
||||
self.programsRouter.route(to: \.videoPlayer, playerViewModel)
|
||||
}
|
||||
self.viewModel.fetchVideoPlayerViewModel(item: chan) { playerViewModel in
|
||||
self.programsRouter.route(to: \.videoPlayer, playerViewModel)
|
||||
}
|
||||
}
|
||||
} label: {
|
||||
LandscapeItemElement(item: item)
|
||||
@ -61,9 +61,9 @@ struct LiveTVProgramsView: View {
|
||||
if let chanId = item.channelId,
|
||||
let chan = viewModel.findChannel(id: chanId)
|
||||
{
|
||||
self.viewModel.fetchVideoPlayerViewModel(item: chan) { playerViewModel in
|
||||
self.programsRouter.route(to: \.videoPlayer, playerViewModel)
|
||||
}
|
||||
self.viewModel.fetchVideoPlayerViewModel(item: chan) { playerViewModel in
|
||||
self.programsRouter.route(to: \.videoPlayer, playerViewModel)
|
||||
}
|
||||
}
|
||||
} label: {
|
||||
LandscapeItemElement(item: item)
|
||||
@ -89,9 +89,9 @@ struct LiveTVProgramsView: View {
|
||||
if let chanId = item.channelId,
|
||||
let chan = viewModel.findChannel(id: chanId)
|
||||
{
|
||||
self.viewModel.fetchVideoPlayerViewModel(item: chan) { playerViewModel in
|
||||
self.programsRouter.route(to: \.videoPlayer, playerViewModel)
|
||||
}
|
||||
self.viewModel.fetchVideoPlayerViewModel(item: chan) { playerViewModel in
|
||||
self.programsRouter.route(to: \.videoPlayer, playerViewModel)
|
||||
}
|
||||
}
|
||||
} label: {
|
||||
LandscapeItemElement(item: item)
|
||||
@ -117,9 +117,9 @@ struct LiveTVProgramsView: View {
|
||||
if let chanId = item.channelId,
|
||||
let chan = viewModel.findChannel(id: chanId)
|
||||
{
|
||||
self.viewModel.fetchVideoPlayerViewModel(item: chan) { playerViewModel in
|
||||
self.programsRouter.route(to: \.videoPlayer, playerViewModel)
|
||||
}
|
||||
self.viewModel.fetchVideoPlayerViewModel(item: chan) { playerViewModel in
|
||||
self.programsRouter.route(to: \.videoPlayer, playerViewModel)
|
||||
}
|
||||
}
|
||||
} label: {
|
||||
LandscapeItemElement(item: item)
|
||||
@ -145,9 +145,9 @@ struct LiveTVProgramsView: View {
|
||||
if let chanId = item.channelId,
|
||||
let chan = viewModel.findChannel(id: chanId)
|
||||
{
|
||||
self.viewModel.fetchVideoPlayerViewModel(item: chan) { playerViewModel in
|
||||
self.programsRouter.route(to: \.videoPlayer, playerViewModel)
|
||||
}
|
||||
self.viewModel.fetchVideoPlayerViewModel(item: chan) { playerViewModel in
|
||||
self.programsRouter.route(to: \.videoPlayer, playerViewModel)
|
||||
}
|
||||
}
|
||||
} label: {
|
||||
LandscapeItemElement(item: item)
|
||||
@ -173,9 +173,9 @@ struct LiveTVProgramsView: View {
|
||||
if let chanId = item.channelId,
|
||||
let chan = viewModel.findChannel(id: chanId)
|
||||
{
|
||||
self.viewModel.fetchVideoPlayerViewModel(item: chan) { playerViewModel in
|
||||
self.programsRouter.route(to: \.videoPlayer, playerViewModel)
|
||||
}
|
||||
self.viewModel.fetchVideoPlayerViewModel(item: chan) { playerViewModel in
|
||||
self.programsRouter.route(to: \.videoPlayer, playerViewModel)
|
||||
}
|
||||
}
|
||||
} label: {
|
||||
LandscapeItemElement(item: item)
|
||||
|
@ -450,7 +450,7 @@ extension VLCPlayerViewController {
|
||||
|
||||
if startPercentage > 0 {
|
||||
if viewModel.resumeOffset {
|
||||
let runTimeTicks = viewModel.item.runTimeTicks ?? 0
|
||||
let runTimeTicks = viewModel.item.runTimeTicks ?? 0
|
||||
let videoDurationSeconds = Double(runTimeTicks / 10_000_000)
|
||||
var startSeconds = round((startPercentage / 100) * videoDurationSeconds)
|
||||
startSeconds = startSeconds.subtract(5, floor: 0)
|
||||
@ -523,7 +523,7 @@ extension VLCPlayerViewController {
|
||||
// Necessary math as VLCMediaPlayer doesn't work well
|
||||
// by just setting the position
|
||||
let videoPosition = Double(vlcMediaPlayer.time.intValue / 1000)
|
||||
let runTimeTicks = viewModel.item.runTimeTicks ?? 0
|
||||
let runTimeTicks = viewModel.item.runTimeTicks ?? 0
|
||||
let videoDuration = Double(runTimeTicks / 10_000_000)
|
||||
let secondsScrubbedTo = round(viewModel.sliderPercentage * videoDuration)
|
||||
let newPositionOffset = secondsScrubbedTo - videoPosition
|
||||
|
@ -410,7 +410,7 @@ extension VLCPlayerViewController {
|
||||
|
||||
if startPercentage > 0 {
|
||||
if viewModel.resumeOffset {
|
||||
let runTimeTicks = item.runTimeTicks ?? 0
|
||||
let runTimeTicks = item.runTimeTicks ?? 0
|
||||
let videoDurationSeconds = Double(runTimeTicks / 10_000_000)
|
||||
var startSeconds = round((startPercentage / 100) * videoDurationSeconds)
|
||||
startSeconds = startSeconds.subtract(5, floor: 0)
|
||||
@ -491,7 +491,7 @@ extension VLCPlayerViewController {
|
||||
func setMediaPlayerTimeAtCurrentSlider() {
|
||||
// Necessary math as VLCMediaPlayer doesn't work well
|
||||
// by just setting the position
|
||||
let runTimeTicks = item.runTimeTicks ?? 0
|
||||
let runTimeTicks = item.runTimeTicks ?? 0
|
||||
let videoPosition = Double(vlcMediaPlayer.time.intValue / 1000)
|
||||
let videoDuration = Double(runTimeTicks / 10_000_000)
|
||||
let secondsScrubbedTo = round(viewModel.sliderPercentage * videoDuration)
|
||||
|
Loading…
Reference in New Issue
Block a user