mirror of
https://github.com/4sval/FModel.git
synced 2026-04-01 06:35:36 -05:00
Merge 587a2bb4c8 into 30b647aa81
This commit is contained in:
commit
548a0ca94e
|
|
@ -356,6 +356,13 @@ namespace FModel.Settings
|
|||
set => SetProperty(ref _addAudio, value);
|
||||
}
|
||||
|
||||
private Hotkey _removeAudio = new(Key.X);
|
||||
public Hotkey RemoveAudio
|
||||
{
|
||||
get => _removeAudio;
|
||||
set => SetProperty(ref _removeAudio, value);
|
||||
}
|
||||
|
||||
private Hotkey _playPauseAudio = new(Key.K);
|
||||
public Hotkey PlayPauseAudio
|
||||
{
|
||||
|
|
|
|||
|
|
@ -238,6 +238,20 @@ public class AudioPlayerViewModel : ViewModel, ISource, IDisposable
|
|||
});
|
||||
}
|
||||
|
||||
public void Unload()
|
||||
{
|
||||
Application.Current.Dispatcher.Invoke(() =>
|
||||
{
|
||||
_waveSource = null;
|
||||
|
||||
PlayedFile = new AudioFile(-1, "No audio file");
|
||||
Spectrum = null;
|
||||
|
||||
RaiseSourceEvent(ESourceEventType.Clearing);
|
||||
ClearSoundOut();
|
||||
});
|
||||
}
|
||||
|
||||
public void AddToPlaylist(byte[] data, string filePath)
|
||||
{
|
||||
Application.Current.Dispatcher.Invoke(() =>
|
||||
|
|
@ -269,11 +283,30 @@ public class AudioPlayerViewModel : ViewModel, ISource, IDisposable
|
|||
if (_audioFiles.Count < 1) return;
|
||||
Application.Current.Dispatcher.Invoke(() =>
|
||||
{
|
||||
var removedPlaying = false;
|
||||
if (PlayedFile.Id == SelectedAudioFile.Id)
|
||||
{
|
||||
removedPlaying = true;
|
||||
Stop();
|
||||
}
|
||||
|
||||
_audioFiles.RemoveAt(SelectedAudioFile.Id);
|
||||
for (var i = 0; i < _audioFiles.Count; i++)
|
||||
{
|
||||
_audioFiles[i].Id = i;
|
||||
}
|
||||
|
||||
if (_audioFiles.Count < 1)
|
||||
{
|
||||
Unload();
|
||||
return;
|
||||
}
|
||||
|
||||
SelectedAudioFile = _audioFiles[SelectedAudioFile.Id];
|
||||
|
||||
if (!removedPlaying) return;
|
||||
Load();
|
||||
Play();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -529,6 +562,11 @@ public class AudioPlayerViewModel : ViewModel, ISource, IDisposable
|
|||
_soundOut.Volume = UserSettings.Default.AudioPlayerVolume / 100;
|
||||
}
|
||||
|
||||
private void ClearSoundOut()
|
||||
{
|
||||
_soundOut = null;
|
||||
}
|
||||
|
||||
private IEnumerable<MMDevice> EnumerateDevices()
|
||||
{
|
||||
using var deviceEnumerator = new MMDeviceEnumerator();
|
||||
|
|
|
|||
|
|
@ -75,6 +75,8 @@ public partial class AudioPlayer
|
|||
_applicationView.AudioPlayer.Previous();
|
||||
else if (UserSettings.Default.NextAudio.IsTriggered(e.Key))
|
||||
_applicationView.AudioPlayer.Next();
|
||||
else if (UserSettings.Default.RemoveAudio.IsTriggered(e.Key))
|
||||
_applicationView.AudioPlayer.Remove();
|
||||
}
|
||||
|
||||
private void OnAudioFileMouseDoubleClick(object sender, MouseButtonEventArgs e)
|
||||
|
|
|
|||
|
|
@ -4,7 +4,8 @@ namespace FModel.Views.Resources.Controls.Aup;
|
|||
|
||||
public enum ESourceEventType
|
||||
{
|
||||
Loading
|
||||
Loading,
|
||||
Clearing
|
||||
}
|
||||
|
||||
public class SourceEventArgs : EventArgs
|
||||
|
|
@ -15,4 +16,4 @@ public class SourceEventArgs : EventArgs
|
|||
{
|
||||
Event = e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -607,6 +607,9 @@
|
|||
<TextBlock Grid.Row="12" Grid.Column="0" Text="Next Audio" VerticalAlignment="Center" Margin="0 0 0 5" />
|
||||
<controls:HotkeyTextBox Grid.Row="12" Grid.Column="2" Style="{StaticResource TextBoxDefaultStyle}" Margin="0 0 0 5"
|
||||
HotKey="{Binding NextAudio, Source={x:Static local:Settings.UserSettings.Default}, Mode=TwoWay}" />
|
||||
<TextBlock Grid.Row="12" Grid.Column="0" Text="Remove Selected Audio" VerticalAlignment="Center" Margin="0 0 0 5" />
|
||||
<controls:HotkeyTextBox Grid.Row="12" Grid.Column="2" Style="{StaticResource TextBoxDefaultStyle}" Margin="0 0 0 5"
|
||||
HotKey="{Binding RemoveAudio, Source={x:Static local:Settings.UserSettings.Default}, Mode=TwoWay}" />
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ResourceDictionary>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user