@@ -2,7 +2,14 @@ import type HangPublish from "@moq/hang/publish/element";
22import type { JSX } from "solid-js" ;
33import { createContext , createEffect , createSignal } from "solid-js" ;
44
5- type PublishStatus = "no-url" | "disconnected" | "connecting" | "live" | "audio-only" | "video-only" | "select-source" ;
5+ export type PublishStatus =
6+ | "no-url"
7+ | "disconnected"
8+ | "connecting"
9+ | "live"
10+ | "audio-only"
11+ | "video-only"
12+ | "select-source" ;
613
714type PublishUIContextValue = {
815 hangPublish : HangPublish ;
@@ -43,7 +50,7 @@ export default function PublishUIContextProvider(props: PublishUIContextProvider
4350 const setFile = ( file : File ) => {
4451 props . hangPublish . source . set ( file ) ;
4552 props . hangPublish . invisible . set ( false ) ;
46- props . hangPublish . muted . set ( false ) ;
53+ props . hangPublish . muted . set ( true ) ;
4754 } ;
4855
4956 const value : PublishUIContextValue = {
@@ -64,6 +71,11 @@ export default function PublishUIContextProvider(props: PublishUIContextProvider
6471 createEffect ( ( ) => {
6572 const publish = props . hangPublish ;
6673
74+ // Initialize with "nothing" active on page load
75+ publish . muted . set ( true ) ;
76+ publish . invisible . set ( true ) ;
77+ publish . source . set ( undefined ) ;
78+
6779 publish . signals . effect ( ( effect ) => {
6880 const clearCameraDevices = ( ) => setCameraMediaDevices ( [ ] ) ;
6981 const video = effect . get ( publish . video ) ;
@@ -107,8 +119,11 @@ export default function PublishUIContextProvider(props: PublishUIContextProvider
107119 } ) ;
108120
109121 publish . signals . effect ( ( effect ) => {
110- const selectedSource = effect . get ( publish . source ) ;
111- setNothingActive ( selectedSource === undefined ) ;
122+ const source = effect . get ( publish . source ) ;
123+ const muted = effect . get ( publish . muted ) ;
124+ const invisible = effect . get ( publish . invisible ) ;
125+
126+ setNothingActive ( source === undefined && muted && invisible ) ;
112127 } ) ;
113128
114129 publish . signals . effect ( ( effect ) => {
@@ -153,8 +168,13 @@ export default function PublishUIContextProvider(props: PublishUIContextProvider
153168 publish . signals . effect ( ( effect ) => {
154169 const url = effect . get ( publish . connection . url ) ;
155170 const status = effect . get ( publish . connection . status ) ;
156- const audio = effect . get ( publish . broadcast . audio . source ) ;
157- const video = effect . get ( publish . broadcast . video . source ) ;
171+ const audioSource = effect . get ( publish . broadcast . audio . source ) ;
172+ const videoSource = effect . get ( publish . broadcast . video . source ) ;
173+ const muted = effect . get ( publish . muted ) ;
174+ const invisible = effect . get ( publish . invisible ) ;
175+
176+ const audio = audioSource && ! muted ;
177+ const video = videoSource && ! invisible ;
158178
159179 if ( ! url ) {
160180 setPublishStatus ( "no-url" ) ;
0 commit comments