-
Notifications
You must be signed in to change notification settings - Fork 30
[Fix]Livestream participants count #736
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
169dee4
dec35a3
8d901f1
f27ea4f
6c20bd7
56ff280
72596c3
705a994
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -81,94 +81,15 @@ public struct LivestreamPlayer<Factory: ViewFactory>: View { | |
| public var body: some View { | ||
| ZStack { | ||
| if viewModel.errorShown { | ||
| Text(L10n.Call.Livestream.error) | ||
| errorView | ||
| } else if viewModel.loading { | ||
| ProgressView() | ||
| loadingView | ||
| } else if state.backstage { | ||
| Text(L10n.Call.Livestream.notStarted) | ||
| notStartedView | ||
| } else { | ||
| ZStack { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No changes here, just moving things around, right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It adds also some background when the state is loading,error or backstage because currently the text just overlays the CallScreen. it also shows the controls show that in any state the user can leave the call. |
||
| GeometryReader { reader in | ||
| if let participant = state.participants.first(where: { $0.track != nil }) { | ||
| VideoCallParticipantView( | ||
| viewFactory: viewFactory, | ||
| participant: participant, | ||
| availableFrame: reader.frame(in: .global), | ||
| contentMode: .scaleAspectFit, | ||
| customData: [:], | ||
| call: viewModel.call | ||
| ) | ||
| .onTapGesture { | ||
| viewModel.update(controlsShown: true) | ||
| } | ||
| .overlay( | ||
| viewModel.controlsShown ? LivestreamPlayPauseButton( | ||
| viewModel: viewModel | ||
| ) { | ||
| participant.track?.isEnabled = | ||
| !viewModel.streamPaused | ||
| if !viewModel.streamPaused { | ||
| viewModel.update(controlsShown: false) | ||
| } | ||
| } : nil | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| if viewModel.controlsShown || !viewModel.fullScreen { | ||
| VStack { | ||
| Spacer() | ||
| HStack(spacing: 8) { | ||
| LiveIndicator() | ||
| if viewModel.showParticipantCount { | ||
| LivestreamParticipantsView( | ||
| participantsCount: | ||
| Int( | ||
| viewModel.call.state | ||
| .participantCount | ||
| ) | ||
| ) | ||
| } | ||
| Spacer() | ||
| LivestreamButton( | ||
| imageName: !viewModel.muted | ||
| ? "speaker.wave.2.fill" | ||
| : "speaker.slash.fill" | ||
| ) { | ||
| viewModel.toggleAudioOutput() | ||
| } | ||
| LivestreamButton(imageName: "viewfinder") { | ||
| viewModel.update( | ||
| fullScreen: | ||
| !viewModel.fullScreen | ||
| ) | ||
| } | ||
| if showsLeaveCallButton { | ||
| LivestreamButton( | ||
| imageName: "phone.down.fill" | ||
| ) { | ||
| viewModel.leaveLivestream() | ||
| } | ||
| } | ||
| } | ||
| .padding() | ||
| .background( | ||
| colors.livestreamBackground | ||
| .edgesIgnoringSafeArea(.all) | ||
| ) | ||
| .foregroundColor(colors.livestreamCallControlsColor) | ||
| .overlay( | ||
| LivestreamDurationView( | ||
| duration: viewModel.duration(from: state) | ||
| ) | ||
| ) | ||
| } | ||
| } | ||
| } | ||
| .onChange(of: viewModel.fullScreen) { newValue in | ||
| onFullScreenStateChange?(newValue) | ||
| } | ||
| videoRenderer | ||
| } | ||
| livestreamControls | ||
| } | ||
| .onChange(of: state.participants, perform: { newValue in | ||
| if viewModel.muted && newValue.first?.track != nil { | ||
|
|
@@ -192,6 +113,107 @@ public struct LivestreamPlayer<Factory: ViewFactory>: View { | |
| } | ||
| } | ||
| } | ||
|
|
||
| // MARK: - Private | ||
|
|
||
| @ViewBuilder | ||
| private var errorView: some View { | ||
| Color(colors.callBackground).ignoresSafeArea() | ||
| Text(L10n.Call.Livestream.error) | ||
| } | ||
|
|
||
| @ViewBuilder | ||
| private var loadingView: some View { | ||
| Color(colors.callBackground).ignoresSafeArea() | ||
| ProgressView() | ||
| } | ||
|
|
||
| @ViewBuilder | ||
| private var notStartedView: some View { | ||
| Color(colors.callBackground).ignoresSafeArea() | ||
| Text(L10n.Call.Livestream.notStarted) | ||
| } | ||
|
|
||
| @ViewBuilder | ||
| private var videoRenderer: some View { | ||
| GeometryReader { reader in | ||
| if let participant = state.participants.first(where: { $0.track != nil }) { | ||
| VideoCallParticipantView( | ||
| viewFactory: viewFactory, | ||
| participant: participant, | ||
| availableFrame: reader.frame(in: .global), | ||
| contentMode: .scaleAspectFit, | ||
| customData: [:], | ||
| call: viewModel.call | ||
| ) | ||
| .onTapGesture { | ||
| viewModel.update(controlsShown: true) | ||
| } | ||
| .overlay( | ||
| viewModel.controlsShown ? LivestreamPlayPauseButton( | ||
| viewModel: viewModel | ||
| ) { | ||
| participant.track?.isEnabled = | ||
| !viewModel.streamPaused | ||
| if !viewModel.streamPaused { | ||
| viewModel.update(controlsShown: false) | ||
| } | ||
| } : nil | ||
| ) | ||
| } | ||
| } | ||
| .onChange(of: viewModel.fullScreen) { onFullScreenStateChange?($0) } | ||
| } | ||
|
|
||
| @ViewBuilder | ||
| private var livestreamControls: some View { | ||
| if viewModel.controlsShown || !viewModel.fullScreen { | ||
| VStack { | ||
| Spacer() | ||
| HStack(spacing: 8) { | ||
| LiveIndicator() | ||
| if viewModel.showParticipantCount { | ||
| LivestreamParticipantsView( | ||
| participantsCount: | ||
| Int(state.participantCount) | ||
| ) | ||
| } | ||
| Spacer() | ||
| LivestreamButton( | ||
| imageName: !viewModel.muted | ||
| ? "speaker.wave.2.fill" | ||
| : "speaker.slash.fill" | ||
| ) { | ||
| viewModel.toggleAudioOutput() | ||
| } | ||
| LivestreamButton(imageName: "viewfinder") { | ||
| viewModel.update( | ||
| fullScreen: | ||
| !viewModel.fullScreen | ||
| ) | ||
| } | ||
| if showsLeaveCallButton { | ||
| LivestreamButton( | ||
| imageName: "phone.down.fill" | ||
| ) { | ||
| viewModel.leaveLivestream() | ||
| } | ||
| } | ||
| } | ||
| .padding() | ||
| .background( | ||
| colors.livestreamBackground | ||
| .edgesIgnoringSafeArea(.all) | ||
| ) | ||
| .foregroundColor(colors.livestreamCallControlsColor) | ||
| .overlay( | ||
| LivestreamDurationView( | ||
| duration: viewModel.duration(from: state) | ||
| ) | ||
| ) | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| struct LiveIndicator: View { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.