diff --git a/Sources/DolbyIORTSUIKit/Private/ViewModels/StreamViewModel.swift b/Sources/DolbyIORTSUIKit/Private/ViewModels/StreamViewModel.swift index ae0eaa9..619b88a 100644 --- a/Sources/DolbyIORTSUIKit/Private/ViewModels/StreamViewModel.swift +++ b/Sources/DolbyIORTSUIKit/Private/ViewModels/StreamViewModel.swift @@ -56,6 +56,7 @@ final class StreamViewModel: ObservableObject { let streamDetail: StreamDetail let settingsMode: SettingsMode + let listViewPrimaryVideoQuality: VideoQuality @Published private(set) var state: State = .loading @@ -87,13 +88,15 @@ final class StreamViewModel: ObservableObject { } init( - streamDetail: StreamDetail, + context: StreamingScreen.Context, + listViewPrimaryVideoQuality: VideoQuality, streamOrchestrator: StreamOrchestrator = .shared, settingsManager: SettingsManager = .shared ) { self.streamOrchestrator = streamOrchestrator self.settingsManager = settingsManager - self.streamDetail = streamDetail + self.streamDetail = context.streamDetail + self.listViewPrimaryVideoQuality = context.listViewPrimaryVideoQuality self.settingsMode = .stream(streamName: streamDetail.streamName, accountID: streamDetail.accountID) startObservers() @@ -179,6 +182,7 @@ final class StreamViewModel: ObservableObject { case .list: let secondaryVideoSources = secondaryVideoSources(sources, matchingSource) let showSourceLabels = settings.showSourceLabels + let primaryVideoQuality = matchingSource.videoQualityList.contains(listViewPrimaryVideoQuality) ? listViewPrimaryVideoQuality : .auto let listViewModel = ListViewModel( primaryVideoViewModel: VideoRendererViewModel( @@ -187,7 +191,7 @@ final class StreamViewModel: ObservableObject { isSelectedAudioSource: matchingSource.id == selectedAudioSource?.id, showSourceLabel: showSourceLabels, showAudioIndicator: matchingSource.id == selectedAudioSource?.id, - videoQuality: .auto + videoQuality: primaryVideoQuality ), secondaryVideoViewModels: secondaryVideoSources.map { VideoRendererViewModel( @@ -312,6 +316,7 @@ final class StreamViewModel: ObservableObject { case .list: let secondaryVideoSources = sortedSources.filter { $0.id != selectedVideoSource.id } let showSourceLabels = settings.showSourceLabels + let primaryVideoQuality = selectedVideoSource.videoQualityList.contains(listViewPrimaryVideoQuality) ? listViewPrimaryVideoQuality : .auto let listViewModel = ListViewModel( primaryVideoViewModel: VideoRendererViewModel( @@ -320,7 +325,7 @@ final class StreamViewModel: ObservableObject { isSelectedAudioSource: selectedVideoSource.id == selectedAudioSource?.id, showSourceLabel: showSourceLabels, showAudioIndicator: selectedVideoSource.id == selectedAudioSource?.id, - videoQuality: .auto + videoQuality: primaryVideoQuality ), secondaryVideoViewModels: secondaryVideoSources.map { VideoRendererViewModel( diff --git a/Sources/DolbyIORTSUIKit/Public/Screens/Media/StreamingScreen.swift b/Sources/DolbyIORTSUIKit/Public/Screens/Media/StreamingScreen.swift index 9aa3483..7691cfc 100644 --- a/Sources/DolbyIORTSUIKit/Public/Screens/Media/StreamingScreen.swift +++ b/Sources/DolbyIORTSUIKit/Public/Screens/Media/StreamingScreen.swift @@ -7,6 +7,18 @@ import DolbyIORTSCore import DolbyIOUIKit public struct StreamingScreen: View { + + public struct Context: Identifiable { + public let id = UUID() + public let streamDetail: StreamDetail + public let listViewPrimaryVideoQuality: VideoQuality + + public init(streamName: String, accountID: String, listViewPrimaryVideoQuality: VideoQuality) { + self.streamDetail = StreamDetail(streamName: streamName, accountID: accountID) + self.listViewPrimaryVideoQuality = listViewPrimaryVideoQuality + } + } + @StateObject private var viewModel: StreamViewModel @State private var isShowingSingleViewScreen: Bool = false @State private var isShowingSettingsScreen: Bool = false @@ -15,9 +27,18 @@ public struct StreamingScreen: View { private let onClose: () -> Void private var theme: Theme { themeManager.theme } - - public init(streamDetail: StreamDetail, onClose: @escaping () -> Void) { - _viewModel = StateObject(wrappedValue: .init(streamDetail: streamDetail)) + + public init( + context: Context, + listViewPrimaryVideoQuality: VideoQuality = .auto, + onClose: @escaping () -> Void + ) { + _viewModel = StateObject( + wrappedValue: .init( + context: context, + listViewPrimaryVideoQuality: listViewPrimaryVideoQuality + ) + ) self.onClose = onClose }