1212
1313namespace Infrastructure . Services ;
1414
15- public class NetCordAudioPlayerService (
15+ public class AudioPlayerService (
1616 INativePlaceMusicProcessorService ffmpegProcessService ,
1717 IServiceProvider serviceProvider ,
18- ILogger < NetCordAudioPlayerService > logger ,
18+ ILogger < AudioPlayerService > logger ,
1919 PlayerState < VoiceClient > playerState ,
2020 IMusicQueueService queue ) : INetCordAudioPlayerService
2121{
@@ -85,8 +85,8 @@ async Task HandleVoiceStream()
8585 var radioSourceService = scope . ServiceProvider
8686 . GetRequiredService < IRadioSourceService > ( ) ;
8787
88- var selectedValue = _currentTrack . Context . SelectedValues [ 0 ] ;
89- var sourceUrl = await GetSourceUrl ( selectedValue , radioSourceService , youTubeService , _currentTrack ) ;
88+ var selectedValue = _currentTrack . VideoUrl ?? _currentTrack . Context . SelectedValues [ 0 ] ;
89+ var sourceUrl = await GetSourceUrl ( selectedValue , radioSourceService , youTubeService , _currentTrack . Context . User . Id , _currentTrack . Context . User . Username , _currentTrack . Context . User . GlobalName ) ;
9090
9191 await StartFfmpegStream ( sourceUrl , stream ) ;
9292 }
@@ -160,7 +160,7 @@ await ffmpeg.StandardOutput.BaseStream.CopyToAsync(stream,
160160 }
161161
162162 private async Task < string > GetSourceUrl ( string selectedValue , IRadioSourceService radioSourceService ,
163- IStreamService youTubeService , PlayRequest < StringMenuInteractionContext > currentTrack )
163+ IStreamService youTubeService , ulong userId , string userName , string ? globalName )
164164 {
165165 string sourceUrl ;
166166
@@ -186,22 +186,21 @@ private async Task<string> GetSourceUrl(string selectedValue, IRadioSourceServic
186186 Url = selectedValue ,
187187 Title = await youTubeService . GetVideoTitleAsync ( selectedValue ,
188188 playerState . SkipCts . Token ) ,
189- UserId = currentTrack . Context . User . Id
189+ UserId = userId
190190 } ;
191- ffmpegProcessService . OnProcessStart += ( ) => HandleOnProcessStartAsync ( song , currentTrack . Context ) ;
191+ ffmpegProcessService . OnProcessStart += ( ) => HandleOnProcessStartAsync ( song , userId , userName , globalName ) ;
192192 }
193193
194194 return sourceUrl ;
195195 }
196196
197- private async Task HandleOnProcessStartAsync ( SongDtoBase song , StringMenuInteractionContext currentContext )
197+ private async Task HandleOnProcessStartAsync ( SongDtoBase song , ulong userId , string userName , string ? globalName )
198198 {
199199 using var scope = serviceProvider . CreateScope ( ) ;
200200 var statisticsService = scope . ServiceProvider
201201 . GetRequiredService < IStatisticsService > ( ) ;
202202 await statisticsService
203- . LogSongPlayAsync ( currentContext . User . Id , currentContext . User . Username ,
204- currentContext . User . GlobalName ?? string . Empty , song )
203+ . LogSongPlayAsync ( userId , userName , globalName ?? string . Empty , song )
205204 . ConfigureAwait ( false ) ;
206205
207206 playerState . CurrentAction = PlayerAction . Play ;
0 commit comments