@@ -40,6 +40,7 @@ public partial class VideoPlayerViewModel(IJellyfinClient jellyfinClient,
4040
4141
4242 public TrickplayViewModel TrickplayViewModel { get ; } = trickplayViewModel ;
43+ public IJellyfinClient JellyfinClient { get ; } = jellyfinClient ;
4344
4445
4546 [ ObservableProperty ]
@@ -78,15 +79,14 @@ public async Task OnNavigatedFrom()
7879 NativeMethods . AllowSleep ( ) ;
7980
8081 taskBarProgress . Clear ( ) ;
81- await jellyfinClient . Stop ( ) ;
82+ await JellyfinClient . Stop ( ) ;
8283
8384 if ( MediaPlayer is null )
8485 {
8586 return ;
8687 }
8788
88- MediaPlayer . Pause ( ) ;
89- MediaPlayer . Dispose ( ) ;
89+ MediaPlayer . Stop ( ) ;
9090 }
9191
9292 public async Task OnNavigatedTo ( object parameter )
@@ -121,7 +121,7 @@ public async Task OnNavigatedTo(object parameter)
121121 . Subscribe ( async mp =>
122122 {
123123 _keyboardController ? . UnsubscribeEvents ( ) ;
124- _keyboardController = new KeyboardMediaPlayerController ( mp , jellyfinClient , Skip , ToggleFullScreen ) ;
124+ _keyboardController = new KeyboardMediaPlayerController ( mp , JellyfinClient , Skip , ToggleFullScreen ) ;
125125
126126 if ( _playQueueUpdate is null )
127127 {
@@ -132,7 +132,7 @@ public async Task OnNavigatedTo(object parameter)
132132 Playlist . SelectedItem = Playlist . Items . FirstOrDefault ( ) ;
133133 }
134134
135- await jellyfinClient . Playing ( Dto ) ;
135+ await JellyfinClient . Playing ( Dto ) ;
136136 } ) ;
137137
138138 Observable . Timer ( TimeSpan . FromSeconds ( 1 ) , TimeSpan . FromSeconds ( 20 ) )
@@ -149,7 +149,7 @@ private async Task Initialize(Guid? id)
149149 return ;
150150 }
151151
152- Dto = await jellyfinClient . GetItem ( id . Value ) ;
152+ Dto = await JellyfinClient . GetItem ( id . Value ) ;
153153
154154 if ( Dto is null )
155155 {
@@ -159,9 +159,9 @@ private async Task Initialize(Guid? id)
159159 Playlist = Dto . Type switch
160160 {
161161 BaseItemDto_Type . Movie => PlaylistViewModel . FromMovie ( Dto ) ,
162- BaseItemDto_Type . Episode => await PlaylistViewModel . FromEpisode ( jellyfinClient , Dto ) ,
163- BaseItemDto_Type . Series => await PlaylistViewModel . FromSeries ( jellyfinClient , Dto ) ,
164- BaseItemDto_Type . Season => await PlaylistViewModel . FromSeason ( jellyfinClient , Dto ) ,
162+ BaseItemDto_Type . Episode => await PlaylistViewModel . FromEpisode ( JellyfinClient , Dto ) ,
163+ BaseItemDto_Type . Series => await PlaylistViewModel . FromSeries ( JellyfinClient , Dto ) ,
164+ BaseItemDto_Type . Season => await PlaylistViewModel . FromSeason ( JellyfinClient , Dto ) ,
165165 _ => new PlaylistViewModel ( )
166166 } ;
167167 }
@@ -174,7 +174,7 @@ private async Task InitializeForSyncPlay(PlayQueueUpdate pqu)
174174 }
175175
176176 var id = pqu . Playlist [ pqu . PlayingItemIndex ] . ItemId ;
177- Dto = await jellyfinClient . GetItem ( id ) ;
177+ Dto = await JellyfinClient . GetItem ( id ) ;
178178 Playlist = PlaylistViewModel . FromSyncPlay ( pqu . Playlist ) ;
179179 }
180180
@@ -198,7 +198,7 @@ private async Task Skip()
198198
199199 if ( _playQueueUpdate is not null )
200200 {
201- await jellyfinClient . SignalSeekForSyncPlay ( endPosition ) ;
201+ await JellyfinClient . SignalSeekForSyncPlay ( endPosition ) ;
202202 }
203203
204204 MediaPlayer . SeekTo ( endPosition ) ;
@@ -223,7 +223,7 @@ private async void OnPlaylistPropertyChanged(object? sender, System.ComponentMod
223223
224224 MediaPlayer . Stop ( ) ;
225225
226- var full = await jellyfinClient . GetItem ( selectedItem . Dto . Id ?? Guid . Empty ) ;
226+ var full = await JellyfinClient . GetItem ( selectedItem . Dto . Id ?? Guid . Empty ) ;
227227
228228 if ( full is null )
229229 {
@@ -238,7 +238,7 @@ private async void OnPlaylistPropertyChanged(object? sender, System.ComponentMod
238238 }
239239
240240
241- await jellyfinClient . Stop ( ) ;
241+ await JellyfinClient . Stop ( ) ;
242242 TrickplayViewModel . SetItem ( full ) ;
243243
244244 var defaultSubtitleIndex = mediaResponse . MediaSourceInfo . DefaultSubtitleStreamIndex ;
@@ -277,7 +277,7 @@ private void OpenSubtitles(IMediaPlayerController mp, MediaResponse response, Me
277277 {
278278 if ( stream . IsExternal == true )
279279 {
280- var url = HttpUtility . UrlDecode ( jellyfinClient . BaseUrl . AppendPathSegment ( stream . DeliveryUrl ) . ToString ( ) ) ;
280+ var url = HttpUtility . UrlDecode ( JellyfinClient . BaseUrl . AppendPathSegment ( stream . DeliveryUrl ) . ToString ( ) ) ;
281281 mp . OpenExternalSubtitleTrack ( url ) ;
282282 }
283283 else
@@ -297,14 +297,14 @@ private void OpenSubtitles(IMediaPlayerController mp, MediaResponse response, Me
297297
298298 private async Task < MediaResponse ? > GetMediaUrl ( BaseItemDto dto )
299299 {
300- var segments = await jellyfinClient . GetMediaSegments ( dto , [ MediaSegmentType . Intro , MediaSegmentType . Outro ] ) ;
300+ var segments = await JellyfinClient . GetMediaSegments ( dto , [ MediaSegmentType . Intro , MediaSegmentType . Outro ] ) ;
301301
302302 if ( segments is { Items : not null } )
303303 {
304304 Segments = segments . Items ;
305305 }
306306
307- return await jellyfinClient . GetMediaUrl ( dto ) ;
307+ return await JellyfinClient . GetMediaUrl ( dto ) ;
308308 }
309309
310310 private async Task UpdateStatus ( )
@@ -348,7 +348,7 @@ private async Task UpdateStatus()
348348
349349 taskBarProgress . SetProgressPercent ( ( int ) ( ( MediaPlayer . Position . TotalSeconds / _duration . TotalSeconds ) * 100 ) ) ;
350350
351- await jellyfinClient . Progress ( _playbackProgressInfo ) ;
351+ await JellyfinClient . Progress ( _playbackProgressInfo ) ;
352352 }
353353
354354 private void SubscribeEvents ( IMediaPlayerController mp )
@@ -359,11 +359,11 @@ private void SubscribeEvents(IMediaPlayerController mp)
359359 taskBarProgress . Clear ( ) ;
360360 Playlist . SelectNext ( ) ;
361361 } ) ;
362- mp . Stopped . Subscribe ( async _ => await jellyfinClient . Stop ( ) ) ;
362+ mp . Stopped . Subscribe ( async _ => await JellyfinClient . Stop ( ) ) ;
363363 mp . Errored . Subscribe ( async _ =>
364364 {
365365 logger . LogError ( "An error occurred while playing media" ) ;
366- await jellyfinClient . Stop ( ) ;
366+ await JellyfinClient . Stop ( ) ;
367367 } ) ;
368368 mp . PositionChanged
369369 . Where ( _ => MediaPlayer ? . State == MediaPlayerState . Playing )
@@ -376,7 +376,7 @@ private void SubscribeEvents(IMediaPlayerController mp)
376376
377377 mp . MediaLoaded
378378 . Where ( _ => _playQueueUpdate is not null )
379- . SelectMany ( _ => jellyfinClient . SignalReadyForSyncPlay ( new ReadyRequestDto
379+ . SelectMany ( _ => JellyfinClient . SignalReadyForSyncPlay ( new ReadyRequestDto
380380 {
381381 When = TimeProvider . System . GetUtcNow ( ) ,
382382 IsPlaying = mp . IsPlaying ,
@@ -397,7 +397,6 @@ private void SubscribeWebsocketMessage()
397397 return ;
398398 }
399399
400-
401400 switch ( message )
402401 {
403402 case PlayStateMessage { Data . Command : PlaystateCommand . PlayPause } :
@@ -406,7 +405,7 @@ private void SubscribeWebsocketMessage()
406405 break ;
407406 case PlayStateMessage { Data . Command : PlaystateCommand . Stop } :
408407 MediaPlayer . Stop ( ) ;
409- await jellyfinClient . Stop ( ) ;
408+ await JellyfinClient . Stop ( ) ;
410409 navigationService . NavigateTo < HomeViewModel > ( new ( ) ) ;
411410 break ;
412411 case SyncPlayCommandMessage { Data : not null } syncPlay :
@@ -445,7 +444,7 @@ private async Task SchedulePause(SyncPlaySendCommand command, IMediaPlayerContro
445444 return ;
446445 }
447446
448- var currentTime = await jellyfinClient . SyncTime ( ) ;
447+ var currentTime = await JellyfinClient . SyncTime ( ) ;
449448 var commandTime = command . When ;
450449
451450 mp . SeekTo ( new TimeSpan ( command . PositionTicks ) ) ;
@@ -467,7 +466,7 @@ private async Task SchedulePlay(SyncPlaySendCommand command, IMediaPlayerControl
467466 return ;
468467 }
469468
470- var currentTime = await jellyfinClient . SyncTime ( ) ;
469+ var currentTime = await JellyfinClient . SyncTime ( ) ;
471470 var commandTime = command . When ;
472471
473472 if ( commandTime > currentTime )
0 commit comments