Skip to content

Commit cf24221

Browse files
committed
add syncplay commands in transport controls
1 parent 813b4bc commit cf24221

2 files changed

Lines changed: 36 additions & 4 deletions

File tree

FluentFin.Core/Services/JellyfinClient_SyncPlay.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ public async Task LeaveSyncPlayGroup()
6565

6666
public async Task SignalReadyForSyncPlay(ReadyRequestDto request)
6767
{
68+
if (SessionInfo.GroupId is null)
69+
{
70+
return;
71+
}
72+
6873
try
6974
{
7075
await _jellyfinApiClient.SyncPlay.Ready.PostAsync(request);
@@ -78,6 +83,11 @@ public async Task SignalReadyForSyncPlay(ReadyRequestDto request)
7883

7984
public async Task SignalPauseForSyncPlay()
8085
{
86+
if (SessionInfo.GroupId is null)
87+
{
88+
return;
89+
}
90+
8191
try
8292
{
8393
await _jellyfinApiClient.SyncPlay.Pause.PostAsync();
@@ -91,6 +101,11 @@ public async Task SignalPauseForSyncPlay()
91101

92102
public async Task SignalUnpauseForSyncPlay()
93103
{
104+
if (SessionInfo.GroupId is null)
105+
{
106+
return;
107+
}
108+
94109
try
95110
{
96111
await _jellyfinApiClient.SyncPlay.Unpause.PostAsync();
@@ -104,6 +119,11 @@ public async Task SignalUnpauseForSyncPlay()
104119

105120
public async Task SignalSeekForSyncPlay(TimeSpan position)
106121
{
122+
if(SessionInfo.GroupId is null)
123+
{
124+
return;
125+
}
126+
107127
try
108128
{
109129
await _jellyfinApiClient.SyncPlay.Seek.PostAsync(new SeekRequestDto

FluentFin/Controls/TransportControls.xaml.cs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,16 +152,18 @@ private static string TimeRemaining(TimeSpan currentTime, TimeSpan duration)
152152
return (duration - currentTime).ToString("hh\\:mm\\:ss");
153153
}
154154

155-
private void SkipBackwardButton_Click(object sender, RoutedEventArgs e)
155+
private async void SkipBackwardButton_Click(object sender, RoutedEventArgs e)
156156
{
157157
var ts = Player.Position - TimeSpan.FromSeconds(10);
158158
Player.SeekTo(ts);
159-
}
159+
await App.GetService<IJellyfinClient>().SignalSeekForSyncPlay(ts);
160+
}
160161

161-
private void SkipForwardButton_Click(object sender, RoutedEventArgs e)
162+
private async void SkipForwardButton_Click(object sender, RoutedEventArgs e)
162163
{
163164
var ts = Player.Position + TimeSpan.FromSeconds(30);
164165
Player.SeekTo(ts);
166+
await App.GetService<IJellyfinClient>().SignalSeekForSyncPlay(ts);
165167
}
166168

167169
private void TimeSlider_PointerEntered(object sender, Microsoft.UI.Xaml.Input.PointerRoutedEventArgs e)
@@ -189,9 +191,19 @@ private void Grid_PointerMoved(object sender, Microsoft.UI.Xaml.Input.PointerRou
189191
TrickplayTip.IsOpen = false;
190192
}
191193

192-
private void PlayPauseButton_Click(object sender, RoutedEventArgs e)
194+
private async void PlayPauseButton_Click(object sender, RoutedEventArgs e)
193195
{
194196
Player.TogglePlayPlause();
197+
198+
var client = App.GetService<IJellyfinClient>();
199+
if (Player.State == MediaPlayerState.Playing)
200+
{
201+
await client.SignalUnpauseForSyncPlay();
202+
}
203+
else
204+
{
205+
await client.SignalPauseForSyncPlay();
206+
}
195207
}
196208

197209
private async void CastButton_Click(object sender, RoutedEventArgs e)

0 commit comments

Comments
 (0)