Compare commits

..

No commits in common. "741007322480b108753648d101768650eb9d5230" and "72b4a1637837e6235a1cde14d776cbde3e022e8d" have entirely different histories.

5 changed files with 43 additions and 66 deletions

View File

@ -1,23 +0,0 @@
using System.Globalization;
using Avalonia.Data.Converters;
using Avalonia.Media;
namespace ABStemPlayer.Converters;
public class PlayPauseGeometryConverter : IValueConverter
{
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
bool isPlaying = value is bool b && b;
// Pause icon
if (isPlaying)
return Geometry.Parse("M 12 8 L 18 8 L 18 32 L 12 32 Z M 22 8 L 28 8 L 28 32 L 22 32 Z");
// Play icon
return Geometry.Parse("M 10 8 L 32 20 L 10 32 Z");
}
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
=> throw new NotSupportedException();
}

View File

@ -36,6 +36,7 @@ public sealed partial class PlaybackViewModel : ObservableObject
public ICommand OpenFileCommand { get; }
public ICommand PlayCommand { get; }
public ICommand PauseCommand { get; }
public ICommand StopCommand { get; }
public ICommand RewindCommand { get; }
public ICommand FastForwardCommand { get; }
@ -47,7 +48,6 @@ public sealed partial class PlaybackViewModel : ObservableObject
// Playback properties
// -----------------------------
[ObservableProperty] private bool _isPlaying;
[ObservableProperty] private bool _loopEnabled;
[ObservableProperty] private float _playbackSpeed = 1f;
[ObservableProperty] private TimeSpan _currentTime;
@ -83,7 +83,8 @@ public sealed partial class PlaybackViewModel : ObservableObject
OpenFileCommand = new AsyncRelayCommand(OpenFileAsync);
PlayCommand = new AsyncRelayCommand(OnPlay);
StopCommand = new AsyncRelayCommand(OnStop);
PauseCommand = new AsyncRelayCommand(() => _engine.PauseAsync());
StopCommand = new AsyncRelayCommand(async () => { await _engine.StopAsync(); await _engine.SeekAsync(TimeSpan.Zero); });
RewindCommand = new AsyncRelayCommand(() => _engine.SeekAsync(CurrentTime - TimeSpan.FromSeconds(5)));
FastForwardCommand = new AsyncRelayCommand(() => _engine.SeekAsync(CurrentTime + TimeSpan.FromSeconds(5)));
@ -122,13 +123,6 @@ public sealed partial class PlaybackViewModel : ObservableObject
private async Task OnPlay()
{
if (IsPlaying)
{
await _engine.PauseAsync();
IsPlaying = false;
return;
}
if (_engine.CurrentSession == null)
return;
@ -141,14 +135,6 @@ public sealed partial class PlaybackViewModel : ObservableObject
await _engine.UpdatePlaybackSpeedAsync(new PlaybackSpeedSettings { Speed = PlaybackSpeed });
await _engine.PlayAsync();
IsPlaying = true;
}
private async Task OnStop()
{
await _engine.StopAsync();
IsPlaying = false;
CurrentTime = TimeSpan.Zero;
}
partial void OnMixerChanged(MixerViewModel? oldValue, MixerViewModel newValue)

View File

@ -39,12 +39,14 @@
Grid.Column="0"
Margin="8">
<ScrollViewer Margin="8" VerticalScrollBarVisibility="Auto">
<ScrollViewer Margin="8"
VerticalScrollBarVisibility="Auto">
<ItemsControl ItemsSource="{Binding Bands}"
Margin="0,2">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel Orientation="Vertical"/>
<StackPanel Orientation="Vertical"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
@ -54,6 +56,7 @@
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</Grid>

View File

@ -3,12 +3,10 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="using:ABStemPlayer.ViewModels"
xmlns:conv="using:ABStemPlayer.Converters"
xmlns:av="clr-namespace:Avalonia;assembly=Avalonia.Base"
x:DataType="vm:PlaybackViewModel"
x:Class="ABStemPlayer.Views.PlaybackControls">
<UserControl.Resources>
<conv:BoolInvertConverter x:Key="BoolInvert" />
<conv:PlayPauseGeometryConverter x:Key="PlayPauseGeometry" />
</UserControl.Resources>
<Border Padding="8"
@ -40,8 +38,7 @@
Width="40"
Height="40"
Grid.Column="0"
Margin="0,0,6,0"
ToolTip.Tip="Open File">
Margin="0,0,6,0">
<Path Fill="#e0e0e0"
Stretch="None"
RenderTransformOrigin="0,0">
@ -60,8 +57,7 @@
Width="40"
Height="40"
Grid.Column="1"
Margin="0,0,6,0"
ToolTip.Tip="Rewind">
Margin="0,0,6,0">
<Path Fill="#e0e0e0"
Stretch="None"
RenderTransformOrigin="0,0">
@ -76,20 +72,41 @@
</Button>
<!-- Play -->
<Button Width="40"
<Button Command="{Binding PlayCommand}"
Width="40"
Height="40"
Grid.Column="2"
Margin="0,0,6,0"
ToolTip.Tip="Play/Pause"
Command="{Binding PlayCommand}">
Margin="0,0,6,0">
<Path Fill="#e0e0e0"
Stretch="None"
RenderTransformOrigin="0,0"
Data="{Binding IsPlaying, Converter={StaticResource PlayPauseGeometry}}">
RenderTransformOrigin="0,0">
<Path.RenderTransform>
<TranslateTransform X="-8" Y="-8"/>
</Path.RenderTransform>
<Path.Data>
M 10 8 L 32 20 L 10 32 Z
</Path.Data>
</Path>
</Button>
<!-- Pause -->
<Button Command="{Binding PauseCommand}"
Width="40"
Height="40"
Grid.Column="3"
Margin="0,0,6,0">
<Path Fill="#e0e0e0"
Stretch="None"
RenderTransformOrigin="0,0">
<Path.RenderTransform>
<TranslateTransform X="-8" Y="-8"/>
</Path.RenderTransform>
<Path.Data>
M 8 8 H 16 V 32 H 8 Z
M 24 8 H 32 V 32 H 24 Z
</Path.Data>
</Path>
</Button>
@ -98,8 +115,7 @@
Width="40"
Height="40"
Grid.Column="4"
Margin="0,0,6,0"
ToolTip.Tip="Stop">
Margin="0,0,6,0">
<Path Fill="#e0e0e0"
Stretch="None"
RenderTransformOrigin="0,0">
@ -117,8 +133,7 @@
<Button Command="{Binding FastForwardCommand}"
Width="40"
Height="40"
Grid.Column="5"
ToolTip.Tip="Fast Forward">
Grid.Column="5">
<Path Fill="#e0e0e0"
Stretch="None"
RenderTransformOrigin="0,0">
@ -174,8 +189,6 @@
<ToggleSwitch IsChecked="{Binding LoopEnabled}"
Content="Loop"
OnContent=""
OffContent=""
VerticalAlignment="Center"
Grid.Column="0"
Margin="0,0,6,0"/>
@ -184,8 +197,7 @@
Width="40"
Height="40"
Grid.Column="1"
Margin="0,0,6,0"
ToolTip.Tip="Set Loop Point A">
Margin="0,0,6,0">
<Grid>
<Path Fill="#0080ff"
Data="M 26 8
@ -200,8 +212,7 @@ L 26 8" />
<Button Command="{Binding SetPointBCommand}"
Width="40"
Height="40"
Grid.Column="2"
ToolTip.Tip="Set Loop Point B">
Grid.Column="2">
<Grid>
<Path Fill="#0080ff"
Data="M 14 8

View File

@ -454,7 +454,7 @@ public sealed class StemPlaybackEngine : IStemPlaybackEngine, IDisposable
catch (OperationCanceledException) { }
catch (Exception ex)
{
Msg($"StemPlaybackEngine: Error in StretchLoopAsync: {ex.Message}");
Debug.WriteLine($"StemPlaybackEngine: Error in StretchLoopAsync: {ex.Message}");
try { pipeline.Cts?.Cancel(); } catch { }
}
}