543543 } ) ;
544544 listed = true ;
545545 audioOutputSelect . focus ( ) ;
546-
547- } ) . catch ( function ( ) {
548- document . getElementById ( "messageDiv" ) . innerHTML = "Failed to list available output devices\n\nPlease ensure you allowed the microphone permissions." ;
546+
547+ } ) . catch ( function ( err ) {
548+ var errorMessage = "Failed to list available audio devices\n\n" ;
549+ if ( err && err . name === "NotFoundError" ) {
550+ errorMessage += "No microphone detected. Please connect a microphone and refresh." ;
551+ } else if ( err && err . name === "NotAllowedError" ) {
552+ errorMessage += "Microphone permission denied. Please allow microphone access." ;
553+ } else if ( err && err . name === "NotReadableError" ) {
554+ errorMessage += "Microphone is in use by another application." ;
555+ } else {
556+ errorMessage += "Please ensure you have a microphone connected and allowed permissions." ;
557+ }
558+ document . getElementById ( "messageDiv" ) . innerHTML = errorMessage ;
549559 document . getElementById ( "messageDiv" ) . style . display = "block" ;
550560 setTimeout ( function ( ) { document . getElementById ( "messageDiv" ) . style . opacity = "1.0" ; } , 0 ) ;
551-
552- } ) ;
561+ } ) ;
553562}
554563
555564function gotDevices ( deviceInfos ) {
637646 } ;
638647}
639648
649+ function checkForAsioDevices ( ) {
650+ if ( navigator . userAgent . toLowerCase ( ) . indexOf ( ' electron/' ) > - 1 ) {
651+ try {
652+ // Try async first (works in sandbox mode)
653+ if ( window . electronApi && window . electronApi . isAsioAvailableAsync ) {
654+ window . electronApi . isAsioAvailableAsync ( ) . then ( function ( available ) {
655+ if ( ! available ) return ;
656+ window . electronApi . getAsioDevicesAsync ( ) . then ( function ( asioDevices ) {
657+ if ( asioDevices && asioDevices . length > 0 ) {
658+ createAsioNotice ( asioDevices ) ;
659+ }
660+ } ) . catch ( function ( e ) { console . warn ( "ASIO devices check failed:" , e ) ; } ) ;
661+ } ) . catch ( function ( e ) { console . warn ( "ASIO availability check failed:" , e ) ; } ) ;
662+ }
663+ // Fallback to sync (works when --node flag used)
664+ else if ( window . electronApi && window . electronApi . isAsioAvailable && window . electronApi . isAsioAvailable ( ) ) {
665+ var asioDevices = window . electronApi . getAsioDevices ( ) ;
666+ if ( asioDevices && asioDevices . length > 0 ) {
667+ createAsioNotice ( asioDevices ) ;
668+ }
669+ }
670+ } catch ( e ) {
671+ console . warn ( "ASIO detection check failed:" , e ) ;
672+ }
673+ }
674+ }
675+
676+ function createAsioNotice ( asioDevices ) {
677+ var noticeText = asioDevices . length === 1
678+ ? "ASIO: " + asioDevices [ 0 ] . name
679+ : "ASIO: " + asioDevices . length + " devices" ;
680+
681+ var notice = document . createElement ( 'div' ) ;
682+ notice . id = 'asioNotice' ;
683+ notice . style . position = 'fixed' ;
684+ notice . style . bottom = '45px' ;
685+ notice . style . left = '50%' ;
686+ notice . style . transform = 'translateX(-50%)' ;
687+ notice . style . backgroundColor = 'rgba(0, 40, 0, 0.8)' ;
688+ notice . style . color = '#6f6' ;
689+ notice . style . padding = '8px 12px' ;
690+ notice . style . borderRadius = '20px' ;
691+ notice . style . fontSize = '14px' ;
692+ notice . style . textDecoration = 'none' ;
693+ notice . style . opacity = '0' ;
694+ notice . style . transition = 'opacity 2s ease-in-out' ;
695+ notice . style . boxShadow = '0 2px 5px rgba(0,0,0,0.2)' ;
696+ notice . style . fontFamily = 'Arial, sans-serif' ;
697+ notice . title = "Professional low-latency audio input available via ASIO" ;
698+
699+ var textSpan = document . createElement ( 'span' ) ;
700+ textSpan . textContent = noticeText ;
701+
702+ var linkSpan = document . createElement ( 'span' ) ;
703+ linkSpan . textContent = ' - ' ;
704+
705+ var link = document . createElement ( 'a' ) ;
706+ link . href = 'https://github.com/steveseguin/electroncapture#asio-audio-capture-windows-only' ;
707+ link . target = '_blank' ;
708+ link . textContent = 'Low-latency pro audio available' ;
709+ link . style . color = '#0ff' ;
710+
711+ notice . appendChild ( textSpan ) ;
712+ notice . appendChild ( linkSpan ) ;
713+ notice . appendChild ( link ) ;
714+
715+ document . body . appendChild ( notice ) ;
716+ setTimeout ( ( ) => notice . style . opacity = '1' , 100 ) ;
717+
718+ console . log ( "ASIO devices available:" , asioDevices . map ( function ( d ) { return d . name ; } ) ) ;
719+ }
640720function normalizeDeviceLabel ( deviceName ) {
641721 return String ( deviceName ) . replace ( / [ \W ] + / g, "_" ) . toLowerCase ( ) ;
642722}
654734 } ) ;
655735 listed = true ;
656736 audioOutputSelect . focus ( ) ;
657-
658- } ) . catch ( function ( ) {
659- document . getElementById ( "messageDiv" ) . innerHTML = "Failed to list available audio devices\n\nPlease ensure you allowed the microphone permissions." ;
737+
738+ } ) . catch ( function ( err ) {
739+ var errorMessage = "Failed to list available audio devices\n\n" ;
740+ if ( err && err . name === "NotFoundError" ) {
741+ errorMessage += "No microphone detected. Please connect a microphone and refresh." ;
742+ } else if ( err && err . name === "NotAllowedError" ) {
743+ errorMessage += "Microphone permission denied. Please allow microphone access." ;
744+ } else if ( err && err . name === "NotReadableError" ) {
745+ errorMessage += "Microphone is in use by another application." ;
746+ } else {
747+ errorMessage += "Please ensure you have a microphone connected and allowed permissions." ;
748+ }
749+ document . getElementById ( "messageDiv" ) . innerHTML = errorMessage ;
660750 document . getElementById ( "messageDiv" ) . style . display = "block" ;
661751 setTimeout ( function ( ) { document . getElementById ( "messageDiv" ) . style . opacity = "1.0" ; } , 0 ) ;
662752 } ) ;
687777 document . addEventListener ( 'DOMContentLoaded' , ( ) => {
688778 getPermssions ( ) ;
689779 checkForSpecialVideoDevices ( ) ;
780+ checkForAsioDevices ( ) ;
690781 setTimeout ( lazyPreloadCSS , 2000 ) ;
691782 } ) ;
692783}
814905getPermssions ( ) ;
815906</ script >
816907</ body >
817- </ html >
908+ </ html >
0 commit comments