enable playback on programs view
This commit is contained in:
parent
58cd96c815
commit
dd7ac40aaf
|
@ -27,7 +27,6 @@ final class LiveTVChannelsCoordinator: NavigationCoordinatable {
|
|||
|
||||
func makeVideoPlayer(viewModel: VideoPlayerViewModel) -> NavigationViewCoordinator<VideoPlayerCoordinator> {
|
||||
NavigationViewCoordinator(VideoPlayerCoordinator(viewModel: viewModel))
|
||||
// NavigationViewCoordinator(EmptyViewCoordinator())
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
|
|
|
@ -20,9 +20,8 @@ final class LiveTVProgramsCoordinator: NavigationCoordinatable {
|
|||
@Route(.fullScreen)
|
||||
var videoPlayer = makeVideoPlayer
|
||||
|
||||
func makeVideoPlayer(item: BaseItemDto) -> NavigationViewCoordinator<EmptyViewCoordinator> {
|
||||
// NavigationViewCoordinator(VideoPlayerCoordinator(item: item))
|
||||
NavigationViewCoordinator(EmptyViewCoordinator())
|
||||
func makeVideoPlayer(viewModel: VideoPlayerViewModel) -> NavigationViewCoordinator<VideoPlayerCoordinator> {
|
||||
NavigationViewCoordinator(VideoPlayerCoordinator(viewModel: viewModel))
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
|
|
|
@ -197,4 +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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,9 @@ struct LiveTVProgramsView: View {
|
|||
if let chanId = item.channelId,
|
||||
let chan = viewModel.findChannel(id: chanId)
|
||||
{
|
||||
self.programsRouter.route(to: \.videoPlayer, chan)
|
||||
self.viewModel.fetchVideoPlayerViewModel(item: chan) { playerViewModel in
|
||||
self.programsRouter.route(to: \.videoPlayer, playerViewModel)
|
||||
}
|
||||
}
|
||||
} label: {
|
||||
LandscapeItemElement(item: item)
|
||||
|
@ -59,7 +61,9 @@ struct LiveTVProgramsView: View {
|
|||
if let chanId = item.channelId,
|
||||
let chan = viewModel.findChannel(id: chanId)
|
||||
{
|
||||
self.programsRouter.route(to: \.videoPlayer, chan)
|
||||
self.viewModel.fetchVideoPlayerViewModel(item: chan) { playerViewModel in
|
||||
self.programsRouter.route(to: \.videoPlayer, playerViewModel)
|
||||
}
|
||||
}
|
||||
} label: {
|
||||
LandscapeItemElement(item: item)
|
||||
|
@ -85,7 +89,9 @@ struct LiveTVProgramsView: View {
|
|||
if let chanId = item.channelId,
|
||||
let chan = viewModel.findChannel(id: chanId)
|
||||
{
|
||||
self.programsRouter.route(to: \.videoPlayer, chan)
|
||||
self.viewModel.fetchVideoPlayerViewModel(item: chan) { playerViewModel in
|
||||
self.programsRouter.route(to: \.videoPlayer, playerViewModel)
|
||||
}
|
||||
}
|
||||
} label: {
|
||||
LandscapeItemElement(item: item)
|
||||
|
@ -111,7 +117,9 @@ struct LiveTVProgramsView: View {
|
|||
if let chanId = item.channelId,
|
||||
let chan = viewModel.findChannel(id: chanId)
|
||||
{
|
||||
self.programsRouter.route(to: \.videoPlayer, chan)
|
||||
self.viewModel.fetchVideoPlayerViewModel(item: chan) { playerViewModel in
|
||||
self.programsRouter.route(to: \.videoPlayer, playerViewModel)
|
||||
}
|
||||
}
|
||||
} label: {
|
||||
LandscapeItemElement(item: item)
|
||||
|
@ -137,7 +145,9 @@ struct LiveTVProgramsView: View {
|
|||
if let chanId = item.channelId,
|
||||
let chan = viewModel.findChannel(id: chanId)
|
||||
{
|
||||
self.programsRouter.route(to: \.videoPlayer, chan)
|
||||
self.viewModel.fetchVideoPlayerViewModel(item: chan) { playerViewModel in
|
||||
self.programsRouter.route(to: \.videoPlayer, playerViewModel)
|
||||
}
|
||||
}
|
||||
} label: {
|
||||
LandscapeItemElement(item: item)
|
||||
|
@ -163,7 +173,9 @@ struct LiveTVProgramsView: View {
|
|||
if let chanId = item.channelId,
|
||||
let chan = viewModel.findChannel(id: chanId)
|
||||
{
|
||||
self.programsRouter.route(to: \.videoPlayer, chan)
|
||||
self.viewModel.fetchVideoPlayerViewModel(item: chan) { playerViewModel in
|
||||
self.programsRouter.route(to: \.videoPlayer, playerViewModel)
|
||||
}
|
||||
}
|
||||
} label: {
|
||||
LandscapeItemElement(item: item)
|
||||
|
|
Loading…
Reference in New Issue