mirror of
https://github.com/crskycode/GARbro.git
synced 2024-12-24 03:44:13 +08:00
(GUI): added stop playback button.
This commit is contained in:
parent
e7bac5c4ed
commit
f34feafeee
@ -251,6 +251,12 @@
|
||||
<TextBlock x:Name="appStatusText"/>
|
||||
</StatusBarItem>
|
||||
<Separator Width="1"/>
|
||||
<StatusBarItem x:Name="appPlaybackControl" Visibility="Collapsed">
|
||||
<Button Width="19" Height="19" HorizontalAlignment="Left" VerticalAlignment="Top"
|
||||
Command="{x:Static local:Commands.StopPlayback}">
|
||||
<Rectangle Stretch="Fill" Fill="Black" Width="8" Height="8"/>
|
||||
</Button>
|
||||
</StatusBarItem>
|
||||
<StatusBarItem>
|
||||
<TextBlock x:Name="appResourceText"/>
|
||||
</StatusBarItem>
|
||||
@ -404,6 +410,7 @@
|
||||
<CommandBinding Command="{x:Static local:Commands.HideToolBar}" Executed="HideToolBarExec" CanExecute="CanExecuteAlways"/>
|
||||
<CommandBinding Command="{x:Static local:Commands.About}" Executed="AboutExec" CanExecute="CanExecuteAlways"/>
|
||||
<CommandBinding Command="{x:Static local:Commands.CheckUpdates}" Executed="CheckUpdatesExec" CanExecute="CanExecuteUpdate"/>
|
||||
<CommandBinding Command="{x:Static local:Commands.StopPlayback}" Executed="StopPlaybackExec" CanExecute="CanExecutePlaybackControl"/>
|
||||
<CommandBinding Command="{x:Static local:Commands.Exit}" Executed="ExitExec" CanExecute="CanExecuteAlways"/>
|
||||
</Window.CommandBindings>
|
||||
</Window>
|
||||
|
@ -988,17 +988,19 @@ namespace GARbro.GUI
|
||||
}
|
||||
CurrentAudio = new WaveStreamImpl (sound);
|
||||
AudioDevice = new WaveOutEvent();
|
||||
if ("wav" == sound.SourceFormat)
|
||||
// conversion to sample provider somehow removes crackling at the end of WAV sound clips.
|
||||
if ("wav" == sound.SourceFormat || 8 == sound.Format.BitsPerSample)
|
||||
AudioDevice.Init (CurrentAudio.ToSampleProvider());
|
||||
else
|
||||
AudioDevice.Init (CurrentAudio);
|
||||
AudioDevice.PlaybackStopped += OnPlaybackStopped;
|
||||
AudioDevice.Play();
|
||||
input = null;
|
||||
appPlaybackControl.Visibility = Visibility.Visible;
|
||||
var fmt = CurrentAudio.WaveFormat;
|
||||
SetResourceText (string.Format (guiStrings.MsgPlaying, entry.Name,
|
||||
fmt.SampleRate, sound.SourceBitrate / 1000,
|
||||
CurrentAudio.TotalTime.ToString ("m':'ss")));
|
||||
input = null;
|
||||
}
|
||||
finally
|
||||
{
|
||||
@ -1014,12 +1016,19 @@ namespace GARbro.GUI
|
||||
}
|
||||
}
|
||||
|
||||
private void StopPlaybackExec (object sender, ExecutedRoutedEventArgs e)
|
||||
{
|
||||
if (AudioDevice != null)
|
||||
AudioDevice.Stop();
|
||||
}
|
||||
|
||||
private void OnPlaybackStopped (object sender, StoppedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
SetResourceText ("");
|
||||
CurrentAudio = null;
|
||||
appPlaybackControl.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
catch (Exception X)
|
||||
{
|
||||
@ -1298,6 +1307,11 @@ namespace GARbro.GUI
|
||||
e.CanExecute = CurrentDirectory.SelectedIndex != -1;
|
||||
}
|
||||
|
||||
private void CanExecutePlaybackControl (object sender, CanExecuteRoutedEventArgs e)
|
||||
{
|
||||
e.CanExecute = CurrentAudio != null;
|
||||
}
|
||||
|
||||
private void CanExecuteConvertMedia (object sender, CanExecuteRoutedEventArgs e)
|
||||
{
|
||||
if (CurrentDirectory.SelectedItems.Count >= 1)
|
||||
@ -1504,5 +1518,6 @@ namespace GARbro.GUI
|
||||
public static readonly RoutedCommand SetFileType = new RoutedCommand();
|
||||
public static readonly RoutedCommand NextItem = new RoutedCommand();
|
||||
public static readonly RoutedCommand CopyNames = new RoutedCommand();
|
||||
public static readonly RoutedCommand StopPlayback = new RoutedCommand();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user