mirror of
https://github.com/crskycode/GARbro.git
synced 2024-12-24 20:04: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"/>
|
<TextBlock x:Name="appStatusText"/>
|
||||||
</StatusBarItem>
|
</StatusBarItem>
|
||||||
<Separator Width="1"/>
|
<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>
|
<StatusBarItem>
|
||||||
<TextBlock x:Name="appResourceText"/>
|
<TextBlock x:Name="appResourceText"/>
|
||||||
</StatusBarItem>
|
</StatusBarItem>
|
||||||
@ -404,6 +410,7 @@
|
|||||||
<CommandBinding Command="{x:Static local:Commands.HideToolBar}" Executed="HideToolBarExec" CanExecute="CanExecuteAlways"/>
|
<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.About}" Executed="AboutExec" CanExecute="CanExecuteAlways"/>
|
||||||
<CommandBinding Command="{x:Static local:Commands.CheckUpdates}" Executed="CheckUpdatesExec" CanExecute="CanExecuteUpdate"/>
|
<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"/>
|
<CommandBinding Command="{x:Static local:Commands.Exit}" Executed="ExitExec" CanExecute="CanExecuteAlways"/>
|
||||||
</Window.CommandBindings>
|
</Window.CommandBindings>
|
||||||
</Window>
|
</Window>
|
||||||
|
@ -988,17 +988,19 @@ namespace GARbro.GUI
|
|||||||
}
|
}
|
||||||
CurrentAudio = new WaveStreamImpl (sound);
|
CurrentAudio = new WaveStreamImpl (sound);
|
||||||
AudioDevice = new WaveOutEvent();
|
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());
|
AudioDevice.Init (CurrentAudio.ToSampleProvider());
|
||||||
else
|
else
|
||||||
AudioDevice.Init (CurrentAudio);
|
AudioDevice.Init (CurrentAudio);
|
||||||
AudioDevice.PlaybackStopped += OnPlaybackStopped;
|
AudioDevice.PlaybackStopped += OnPlaybackStopped;
|
||||||
AudioDevice.Play();
|
AudioDevice.Play();
|
||||||
input = null;
|
appPlaybackControl.Visibility = Visibility.Visible;
|
||||||
var fmt = CurrentAudio.WaveFormat;
|
var fmt = CurrentAudio.WaveFormat;
|
||||||
SetResourceText (string.Format (guiStrings.MsgPlaying, entry.Name,
|
SetResourceText (string.Format (guiStrings.MsgPlaying, entry.Name,
|
||||||
fmt.SampleRate, sound.SourceBitrate / 1000,
|
fmt.SampleRate, sound.SourceBitrate / 1000,
|
||||||
CurrentAudio.TotalTime.ToString ("m':'ss")));
|
CurrentAudio.TotalTime.ToString ("m':'ss")));
|
||||||
|
input = null;
|
||||||
}
|
}
|
||||||
finally
|
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)
|
private void OnPlaybackStopped (object sender, StoppedEventArgs e)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
SetResourceText ("");
|
SetResourceText ("");
|
||||||
CurrentAudio = null;
|
CurrentAudio = null;
|
||||||
|
appPlaybackControl.Visibility = Visibility.Collapsed;
|
||||||
}
|
}
|
||||||
catch (Exception X)
|
catch (Exception X)
|
||||||
{
|
{
|
||||||
@ -1298,6 +1307,11 @@ namespace GARbro.GUI
|
|||||||
e.CanExecute = CurrentDirectory.SelectedIndex != -1;
|
e.CanExecute = CurrentDirectory.SelectedIndex != -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void CanExecutePlaybackControl (object sender, CanExecuteRoutedEventArgs e)
|
||||||
|
{
|
||||||
|
e.CanExecute = CurrentAudio != null;
|
||||||
|
}
|
||||||
|
|
||||||
private void CanExecuteConvertMedia (object sender, CanExecuteRoutedEventArgs e)
|
private void CanExecuteConvertMedia (object sender, CanExecuteRoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (CurrentDirectory.SelectedItems.Count >= 1)
|
if (CurrentDirectory.SelectedItems.Count >= 1)
|
||||||
@ -1504,5 +1518,6 @@ namespace GARbro.GUI
|
|||||||
public static readonly RoutedCommand SetFileType = new RoutedCommand();
|
public static readonly RoutedCommand SetFileType = new RoutedCommand();
|
||||||
public static readonly RoutedCommand NextItem = new RoutedCommand();
|
public static readonly RoutedCommand NextItem = new RoutedCommand();
|
||||||
public static readonly RoutedCommand CopyNames = 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