@@ -44,6 +44,8 @@ static void AMEvent()
4444 var playingStatus = false ;
4545 AutomationElement parent = null ;
4646 AutomationElement [ ] listeningInfo = null ;
47+ AutomationElement LCDInf = null ;
48+ AutomationElement audioBadge = null ;
4749 AutomationElement playButton = null ;
4850 AutomationElement slider = null ;
4951
@@ -81,8 +83,9 @@ static void AMEvent()
8183 }
8284 parent = window . FindFirstChild ( cf => cf . ByClassName ( "Microsoft.UI.Content.DesktopChildSiteBridge" ) ) . FindFirstChild ( ) . FindFirstChild ( ) . FindFirstChild ( cf => cf . ByAutomationId ( "TransportBar" ) ) ;
8385 playButton = parent . FindFirstChild ( cf => cf . ByAutomationId ( "TransportControl_PlayPauseStop" ) ) ;
84- listeningInfo = parent . FindFirstChild ( cf => cf . ByAutomationId ( "LCD" ) ) . FindAllChildren ( ) . Where ( x => ( x . ControlType == ControlType . Pane ) ) . ToArray ( ) ;
85- slider = parent . FindFirstChild ( cf => cf . ByAutomationId ( "LCD" ) ) . FindFirstChild ( cf => cf . ByAutomationId ( "LCDScrubber" ) ) ;
86+ LCDInf = parent . FindFirstChild ( cf => cf . ByAutomationId ( "LCD" ) ) ;
87+ listeningInfo = LCDInf . FindAllChildren ( ) . Where ( x => ( x . ControlType == ControlType . Pane ) ) . ToArray ( ) ;
88+ slider = LCDInf . FindFirstChild ( cf => cf . ByAutomationId ( "LCDScrubber" ) ) ;
8689 if ( slider == null ) throw new FieldAccessException ( "Slider not found" ) ;
8790 playingStatus = true ;
8891 }
@@ -109,6 +112,7 @@ static void AMEvent()
109112 {
110113 string previousSong = string . Empty ;
111114 string previousArtistAlbum = string . Empty ;
115+ int audioStatus = 3 ;
112116 bool resetStatus = false ;
113117 double oldValue = 0 ;
114118
@@ -126,6 +130,7 @@ static void AMEvent()
126130 DateTime startTime = currentTime . Subtract ( TimeSpan . FromSeconds ( slider . AsSlider ( ) . Value + 1 ) ) ;
127131 DateTime endTime = currentTime . AddSeconds ( slider . AsSlider ( ) . Maximum ) . Subtract ( TimeSpan . FromSeconds ( slider . AsSlider ( ) . Value + 1 ) ) ;
128132 bool isSingle = dashSplit [ dashSplit . Length - 1 ] . Contains ( "Single" ) ;
133+ audioBadge = LCDInf . FindFirstChild ( cf => cf . ByAutomationId ( "AudioBadgeButton" ) ) ;
129134
130135 if ( ! playButton . IsEnabled && playButton ? . Name != null && localizedPlay == null )
131136 {
@@ -153,8 +158,24 @@ static void AMEvent()
153158 // sometimes discord doesn't register rich presence idk why i tried everything...
154159 previousArtistAlbum = currentArtistAlbum ;
155160 previousSong = currentSong ;
161+ if ( audioBadge != null )
162+ {
163+ switch ( audioBadge ? . Name )
164+ {
165+ case "Lossless" :
166+ audioStatus = 0 ;
167+ break ;
168+ case "Dolby Atmos" :
169+ audioStatus = 1 ;
170+ break ;
171+ default :
172+ audioStatus = 3 ;
173+ break ;
174+ }
175+ }
176+ else audioStatus = 3 ;
156177 oldValue = 0 ;
157- AMSongDataEvent . SongChange ( new SongData ( currentSong , ( isSingle ) ? string . Join ( "-" , dashSplit . Take ( dashSplit . Length - 1 ) . ToArray ( ) ) : currentArtistAlbum , currentArtistAlbum . Split ( '—' ) . Length <= 1 , startTime , endTime ) ) ;
178+ AMSongDataEvent . SongChange ( new SongData ( currentSong , ( isSingle ) ? string . Join ( "-" , dashSplit . Take ( dashSplit . Length - 1 ) . ToArray ( ) ) : currentArtistAlbum , currentArtistAlbum . Split ( '—' ) . Length <= 1 , startTime , endTime , audioStatus ) ) ;
158179 }
159180
160181 if ( playButton ? . Name != null && ( localizedPlay != null && localizedPlay == playButton ? . Name || localizedStop != null && localizedStop != playButton ? . Name ) )
0 commit comments