Skip to content

Commit

Permalink
Fixed #14 #19 #20
Browse files Browse the repository at this point in the history
  • Loading branch information
theweavrs committed Oct 27, 2016
1 parent 71ee544 commit 9643151
Show file tree
Hide file tree
Showing 12 changed files with 689 additions and 90 deletions.
14 changes: 11 additions & 3 deletions BreadPlayer.Core/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ xmlns:Interactivity="using:Microsoft.Xaml.Interactivity" xmlns:MacalifaCore="us
<SolidColorBrush x:Key="AppBarToggleHover" Color="{ThemeResource SystemAccentColor}" Opacity="0.5"/>
<SolidColorBrush x:Key="ThemeForeground" Color="Black"/>
<SolidColorBrush x:Key="ApplicationPageBackgroundThemeBrush" Color="#f2f2f2"/>
<SolidColorBrush x:Key="ThemeBackground" Color="#e5e5e5" Opacity="0.8"/>
<SolidColorBrush x:Key="ThemeBackground" Color="#e5e5e5" Opacity="0.95"/>
<SolidColorBrush x:Key="PointerOverBrush" Color="#b2b2b2"/>
</ResourceDictionary>
<ResourceDictionary x:Key="Dark">
Expand All @@ -58,7 +58,7 @@ xmlns:Interactivity="using:Microsoft.Xaml.Interactivity" xmlns:MacalifaCore="us
<SolidColorBrush x:Key="AppBarToggleHover" Color="{ThemeResource SystemAccentColor}" Opacity="0.5"/>
<SolidColorBrush x:Key="ThemeForeground" Color="White"/>
<SolidColorBrush x:Key="ApplicationPageBackgroundThemeBrush" Color="#0c0c0c"/>
<SolidColorBrush x:Key="ThemeBackground" Color="#141414" Opacity="0.8"/>
<SolidColorBrush x:Key="ThemeBackground" Color="#141414" Opacity="0.95"/>
<SolidColorBrush x:Key="PointerOverBrush" Color="#b2b2b2"/>
<!--<SolidColorBrush x:Key="SelectionBrush" Color="DarkGray" />-->
</ResourceDictionary>
Expand Down Expand Up @@ -736,7 +736,15 @@ xmlns:Interactivity="using:Microsoft.Xaml.Interactivity" xmlns:MacalifaCore="us
<VisualState x:Name="Selected">
<VisualState.Setters>
<Setter Target="PressedBackground.Fill" Value="{ThemeResource HoverBrush}"/>
</VisualState.Setters>
</VisualState.Setters>
<VisualState.Storyboard>
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="DataStack"
Storyboard.TargetProperty="CanDrag">
<DiscreteObjectKeyFrame KeyTime="0" Value="True" />
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState.Storyboard>
</VisualState>
<VisualState x:Name="SelectedUnfocused">
<VisualState.Setters>
Expand Down
4 changes: 2 additions & 2 deletions BreadPlayer.Core/Behaviours/OpenMenuBehaviour.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ public object Execute(object sender, object parameter)
{
FrameworkElement senderElement = sender as FrameworkElement;
var navList = senderElement.GetFirstAncestorOfType<NavMenuListView>() != null && senderElement.GetFirstAncestorOfType<NavMenuListView>().Name == "PlaylistsMenuList" ? senderElement.GetFirstAncestorOfType<NavMenuListView>() : null;
ListBoxItem item = senderElement.GetFirstAncestorOfType<ListBoxItem>();
var ListBox = item.GetFirstAncestorOfType<ListBox>();
ListViewItem item = senderElement.GetFirstAncestorOfType<ListViewItem>();
var ListBox = item.GetFirstAncestorOfType<ListView>();
// if (item != null) item.IsSelected = true;
ListViewItem listItem = senderElement.Tag is ContentPresenter ? (senderElement.Tag as ContentPresenter).Tag as ListViewItem : null;
if(listItem != null) listItem.IsSelected = true;
Expand Down
4 changes: 3 additions & 1 deletion BreadPlayer.Core/Converters/PathToImageSourceConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ public object Convert(object value, Type targetType, object parameter, string la

}
else
image.UriSource = new Uri(def, UriKind.RelativeOrAbsolute);
{
image.UriSource = parameter == null ? new Uri(def, UriKind.RelativeOrAbsolute) : null;
}

return image;
}
Expand Down
20 changes: 18 additions & 2 deletions BreadPlayer.Core/Converters/TrueToFalseConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,34 @@ You should have received a copy of the GNU General Public License
using Windows.UI.Xaml;
using Windows.UI.Xaml.Data;
using System.Globalization;
using Windows.UI.Xaml.Controls;

namespace BreadPlayer.Converters
{
public class TrueToFalseConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language)
{
if(value is Windows.UI.Xaml.Controls.SplitViewDisplayMode)
{
Windows.UI.Xaml.Controls.SplitViewDisplayMode mode = (Windows.UI.Xaml.Controls.SplitViewDisplayMode)value;
if (mode == Windows.UI.Xaml.Controls.SplitViewDisplayMode.CompactInline)
if (mode == Windows.UI.Xaml.Controls.SplitViewDisplayMode.Overlay || mode == Windows.UI.Xaml.Controls.SplitViewDisplayMode.CompactOverlay)
return true;
else
return false;
return false;
}
else if(value is bool)
{
if (parameter == null)
{
if ((bool)value == true)
return false;
else
return true;
}
}

return false;
}
public object ConvertBack(object value, Type targetType,
object parameter, string language)
Expand Down
2 changes: 1 addition & 1 deletion BreadPlayer.Core/Core/MacalifaPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public MacalifaPlayer()
/// <returns></returns>
private void Init()
{
Bass.UpdatePeriod = 10;
Bass.UpdatePeriod = 500;
Bass.Start();
Bass.Init();
}
Expand Down
2 changes: 1 addition & 1 deletion BreadPlayer.Core/Package.appxmanifest
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" xmlns:uap3="http://schemas.microsoft.com/appx/manifest/uap/windows10/3" IgnorableNamespaces="uap mp uap3">
<Identity Name="22102thecodrr.BreadPlayer" Publisher="CN=C12EF191-B051-4B71-922F-A3597A07F49E" Version="0.1.2.0" />
<Identity Name="22102thecodrr.BreadPlayer" Publisher="CN=C12EF191-B051-4B71-922F-A3597A07F49E" Version="0.1.3.0" />
<mp:PhoneIdentity PhoneProductId="f2586309-8386-46e9-9e86-c9b0a8a075b0" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
<Properties>
<DisplayName>Bread Player</DisplayName>
Expand Down
51 changes: 28 additions & 23 deletions BreadPlayer.Core/Shell.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,67 +30,72 @@
</VisualState>
<VisualState>
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="700" />
<AdaptiveTrigger MinWindowWidth="600" />
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="sliderGrid.Visibility" Value="Collapsed" />
<Setter Target="shuffleBtn.Visibility" Value="Collapsed" />
<Setter Target="shuffleBtn.Visibility" Value="Visible" />
</VisualState.Setters>
</VisualState>
<VisualState>
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="0" />
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="infoBar.Width" Value="150" />
<Setter Target="sliderGrid.Visibility" Value="Collapsed" />
<Setter Target="shuffleBtn.Visibility" Value="Visible" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>


</VisualStateManager.VisualStateGroups>
<controls:SplitViewMenu x:Name="hamburgerMenu" PlaylistsItems="{Binding PlaylistsItems}" InitialPage="local:LibraryView" Margin="0,70,0,25">
<controls:SplitViewMenu.TopNavigationItems>
<controls:SimpleNavMenuItem DestinationPage="local:LibraryView" FontGlyph="&#xe806;" Label="Recently Played" Arguments="Recent"></controls:SimpleNavMenuItem>
<controls:SimpleNavMenuItem DestinationPage="local:LibraryView" FontGlyph="&#xe81c;" Label="Music Library" Arguments="Library"></controls:SimpleNavMenuItem>
<controls:SimpleNavMenuItem DestinationPage="local:AlbumArtistView" FontGlyph="&#xe81f;" Label="My Albums"></controls:SimpleNavMenuItem>
<controls:SimpleNavMenuItem DestinationPage="local:LibraryView" FontGlyph="&#xe806;" Label="Recently Played" Arguments="Recent" Symbol="Accept"></controls:SimpleNavMenuItem>
<controls:SimpleNavMenuItem DestinationPage="local:LibraryView" FontGlyph="&#xe81c;" Label="Music Library" Arguments="Library" Symbol="Accept"></controls:SimpleNavMenuItem>
<controls:SimpleNavMenuItem DestinationPage="local:AlbumArtistView" FontGlyph="&#xe81f;" Label="My Albums" Symbol="Accept"></controls:SimpleNavMenuItem>
</controls:SplitViewMenu.TopNavigationItems>
<controls:SplitViewMenu.BottomNavigationItems>
<controls:SimpleNavMenuItem DestinationPage="local:SettingsView" FontGlyph="&#xe814;" Label="Settings"></controls:SimpleNavMenuItem>
<controls:SimpleNavMenuItem DestinationPage="local:SettingsView" FontGlyph="&#xe814;" Label="Settings" Symbol="Accept"></controls:SimpleNavMenuItem>
</controls:SplitViewMenu.BottomNavigationItems>
</controls:SplitViewMenu>
<Grid Height="70" Background="{ThemeResource SystemControlBackgroundAccentBrush}" VerticalAlignment="Top">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="30*"/>
<ColumnDefinition Width="79*"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>

<AppBarButton x:Name="infoBar" Grid.Column="0" Width="Auto" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Background="{x:Null}" BorderBrush="{x:Null}" Margin="0,0,10,0" Grid.ColumnSpan="1">
<StackPanel Orientation="Horizontal" Margin="-4,-17,-3,-31" Height="70">
<Image x:Name="albumArt" Width="66" Source="{Binding Source={StaticResource Core}, Path=Player.CurrentlyPlayingFile.AttachedPicture, Converter={StaticResource PathToImage}, ConverterParameter=null}" Stretch="UniformToFill" Margin="10,0,0,0"/>
<Grid x:Name="infoBar" Padding="0" Grid.Column="0" Width="300" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" BorderBrush="{x:Null}" Margin="0" Grid.ColumnSpan="1">
<Grid.Background>
<ImageBrush ImageSource="{Binding Source={StaticResource Core}, Path=Player.CurrentlyPlayingFile.AttachedPicture, Converter={StaticResource PathToImage}, ConverterParameter=null}" Stretch="UniformToFill"></ImageBrush>
</Grid.Background>
<StackPanel Orientation="Horizontal" Background="#99262626" VerticalAlignment="Stretch" Height="Auto">
<!--<StackPanel Orientation="Horizontal" Height="70">
<Image x:Name="albumArt" Width="66" Source="{Binding Source={StaticResource Core}, Path=Player.CurrentlyPlayingFile.AttachedPicture, Converter={StaticResource PathToImage}, ConverterParameter=null}" Stretch="UniformToFill" Margin="10,0,0,0"/>-->
<StackPanel x:Name="tagsPanel" Orientation="Vertical" Margin="6,2,0,0">
<TextBlock Text="{Binding Source={StaticResource Core}, Path=Player.CurrentlyPlayingFile.Title, UpdateSourceTrigger=Explicit}" FontSize="20" FontFamily="Segoe UI Light" FontWeight="SemiLight" Foreground="White"/>
<TextBlock Text="{Binding Source={StaticResource Core}, Path=Player.CurrentlyPlayingFile.LeadArtist, UpdateSourceTrigger=Explicit}" FontSize="17" FontFamily="Segoe UI Light" Foreground="White"/>
<TextBlock Text="{Binding Source={StaticResource Core}, Path=Player.CurrentlyPlayingFile.Album, UpdateSourceTrigger=Explicit}" FontSize="15" FontFamily="Segoe UI Light" Foreground="White"/>
</StackPanel>
</StackPanel>
</AppBarButton>
<Grid Grid.Column="1" x:Name="sliderGrid">
</Grid>
<Grid Grid.Column="1" Margin="10,0,0,0" x:Name="sliderGrid">
<TextBlock Text="{Binding CurrentPosition, Converter={StaticResource DoubleToTime}}" HorizontalAlignment="Left" VerticalAlignment="Center" Foreground="#FFC5C5C5" Margin="5,0,0,0" FontSize="12"/>
<Slider x:Name="positionSlider" VerticalAlignment="Center" Style="{StaticResource CircleSlider}" Maximum="{Binding Source={StaticResource Core}, Path=Player.Length, FallbackValue=100}" Value="{Binding CurrentPosition, Mode=TwoWay, UpdateSourceTrigger=Explicit, FallbackValue=0}" Background="#FFC5C5C5" BorderBrush="{x:Null}" Foreground="{ThemeResource SystemControlBackgroundAccentBrush}" Height="54" Margin="44,8,45,8" Tapped="positionSlider_Tapped" PointerPressed="positionSlider_PointerPressed"/>
<Slider x:Name="positionSlider" ThumbToolTipValueConverter="{StaticResource DoubleToTime}" VerticalAlignment="Center" Style="{StaticResource CircleSlider}" Maximum="{Binding Source={StaticResource Core}, Path=Player.Length, FallbackValue=100}" Value="{Binding CurrentPosition, Mode=TwoWay, UpdateSourceTrigger=Explicit, FallbackValue=0}" Background="#FFC5C5C5" BorderBrush="{x:Null}" Foreground="{ThemeResource SystemControlBackgroundAccentBrush}" Height="54" Margin="44,8,45,8" Tapped="positionSlider_Tapped" PointerPressed="positionSlider_PointerPressed"/>
<TextBlock Text="{Binding Source={StaticResource Core}, Path=Player.Length, Converter={StaticResource DoubleToTime} , UpdateSourceTrigger=Explicit}" VerticalAlignment="Center" HorizontalAlignment="Right" Foreground="#FFC5C5C5" Margin="34,0,6,0" FontSize="12"/>
</Grid>

<StackPanel Orientation="Horizontal" Grid.Column="2">
<AppBarButton Icon="Previous" VerticalAlignment="Stretch" IsCompact="True" Style="{StaticResource CustomAppBarButtonStyle}" Command="{Binding PlayPreviousCommand}" Width="50"/>
<AppBarButton ToolTipService.ToolTip="Previous Song" Icon="Previous" VerticalAlignment="Stretch" IsCompact="True" Style="{StaticResource CustomAppBarButtonStyle}" Command="{Binding PlayPreviousCommand}" Width="50"/>
<AppBarButton Icon="{Binding PlayPauseIcon, Mode=TwoWay}" VerticalAlignment="Stretch" IsCompact="True" Command="{Binding PlayPauseCommand}" Style="{StaticResource CustomAppBarButtonStyle}" Width="50"/>
<AppBarButton Icon="Next" VerticalAlignment="Stretch" IsCompact="True" Style="{StaticResource CustomAppBarButtonStyle}" Command="{Binding PlayNextCommand}" Background="{ThemeResource AppBarButtonBackgroundDisabled}" Width="50"/>
<AppBarButton ToolTipService.ToolTip="Next Song" Icon="Next" VerticalAlignment="Stretch" IsCompact="True" Style="{StaticResource CustomAppBarButtonStyle}" Command="{Binding PlayNextCommand}" Background="{ThemeResource AppBarButtonBackgroundDisabled}" Width="50"/>
<AppBarToggleButton x:Name="volBtn" Icon="Volume" VerticalAlignment="Stretch" IsChecked="False" IsCompact="True" Width="50" Style="{StaticResource CustomAppBarToggleButtonStyle}"/>
<AppBarToggleButton x:Name="shuffleBtn" VerticalAlignment="Stretch" IsCompact="True" IsChecked="{Binding Path=Shuffle, Mode=TwoWay}" Width="50" Style="{StaticResource CustomAppBarToggleButtonStyle}" Icon="Shuffle"/>
<AppBarToggleButton x:Name="repeatBtn" Icon="Sync" VerticalAlignment="Stretch" Visibility="{Binding ElementName=shuffleBtn, Path=Visibility}" IsCompact="True" IsChecked="{Binding Path=Repeat, Mode=TwoWay}" Width="50" Style="{StaticResource CustomAppBarToggleButtonStyle}" Margin="0" />
<AppBarButton x:Name="openFileBtn" Visibility="{Binding ElementName=shuffleBtn, Path=Visibility}" Icon="OpenFile" VerticalAlignment="Stretch" IsCompact="True" Command="{Binding Path=OpenSongCommand}" Style="{StaticResource CustomAppBarButtonStyle}" Width="50"/>
<AppBarToggleButton ToolTipService.ToolTip="Shuffle" x:Name="shuffleBtn" VerticalAlignment="Stretch" IsCompact="True" IsChecked="{Binding Path=Shuffle, Mode=TwoWay}" Width="50" Style="{StaticResource CustomAppBarToggleButtonStyle}" Icon="Shuffle"/>
<AppBarToggleButton ToolTipService.ToolTip="Repeat" x:Name="repeatBtn" Icon="Sync" VerticalAlignment="Stretch" Visibility="{Binding ElementName=shuffleBtn, Path=Visibility}" IsCompact="True" IsChecked="{Binding Path=Repeat, Mode=TwoWay}" Width="50" Style="{StaticResource CustomAppBarToggleButtonStyle}" Margin="0" />
<AppBarButton ToolTipService.ToolTip="Open a file to play" x:Name="openFileBtn" Visibility="{Binding ElementName=shuffleBtn, Path=Visibility}" Icon="OpenFile" VerticalAlignment="Stretch" IsCompact="True" Command="{Binding Path=OpenSongCommand}" Style="{StaticResource CustomAppBarButtonStyle}" Width="50"/>

</StackPanel>
</Grid>
Expand All @@ -114,9 +119,9 @@
<StackPanel Orientation="Horizontal" Grid.Column="0" Margin="6,0,0,0">
<TextBlock VerticalAlignment="Center" FontSize="12" Text="{Binding Path=Status, FallbackValue='Nothing Baking'}" Foreground="White"></TextBlock>
</StackPanel>
<StackPanel HorizontalAlignment="Right" Grid.Column="2" Orientation="Horizontal" Margin="0,0,5,0">
</StackPanel>
<StackPanel HorizontalAlignment="Right" Grid.Column="2" Orientation="Horizontal" Margin="0,0,5,0">

</StackPanel>
</Grid>
</Border>
</Grid>
Expand Down
25 changes: 21 additions & 4 deletions BreadPlayer.Core/Shell.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ private void VolSliderThumb_DragCompleted(object sender, DragCompletedEventArgs
vm.DontUpdatePosition = false;
}
}

bool isPressed;
bool isValueChanged;
private void Page_Loaded(object sender, RoutedEventArgs e)
{
Thumb volSliderThumb = FrameworkElementExtensions.FindChildOfType<Thumb>(positionSlider);
Expand All @@ -98,19 +99,35 @@ private void Page_Loaded(object sender, RoutedEventArgs e)
volSliderThumb.DragCompleted += VolSliderThumb_DragCompleted;
volSliderThumb.DragStarted += VolSliderThumb_DragStarted;
}
Window.Current.CoreWindow.PointerPressed += (ea, a) =>
{
if( positionSlider.GetBoundingRect().Contains(a.CurrentPoint.Position))
isPressed = true;
};

Window.Current.CoreWindow.PointerReleased += (ea, a) =>
{
if (isPressed) { UpdatePosition(true); isPressed = false; }
};
}

private void positionSlider_Tapped(object sender, TappedRoutedEventArgs e)
{
{
UpdatePosition();
}
async void UpdatePosition(bool wait = false)
{
ShellVM.DontUpdatePosition = true;
if (ShellVM != null)
{
// var se = volSliderThumb.GetPointerPosition().X;
// var se = volSliderThumb.GetPointerPosition().X;
ShellVM.CurrentPosition = positionSlider.Value;
}
if (wait) await Task.Delay(500);
ShellVM.DontUpdatePosition = false;

}


private void positionSlider_PointerPressed(object sender, PointerRoutedEventArgs e)
{
var s = positionSlider.Value;
Expand Down
Loading

0 comments on commit 9643151

Please sign in to comment.