Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
imadofficial authored Oct 30, 2023
1 parent fc59244 commit aa94664
Show file tree
Hide file tree
Showing 13 changed files with 393 additions and 22 deletions.
4 changes: 2 additions & 2 deletions PiMusic/Home.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@
<Button x:Name="Musicbox" Opacity="0" Click="Musicbox_Click"/>
</Grid>

<Grid x:Name="WeerBlok" HorizontalAlignment="Left" Height="180" Width="250" Margin="400,0,0,120">
<Grid x:Name="WeerBlok" HorizontalAlignment="Center" Height="180" Width="250" Margin="270,0,0,120">
<Border Background="LightBlue" CornerRadius="15"/>
<TextBlock FontStretch="UltraCondensed" Text="Laken" Width="210" Foreground="Black" Margin="20,10,0,0" FontSize="21" FontFamily="/Assets/Latin/Default.otf#SF Pro Display" HorizontalAlignment="Left" VerticalAlignment="Top" />
<TextBlock FontStretch="UltraCondensed" Text="21°C" Foreground="Black" VerticalAlignment="Center" Margin="20,0,0,50" FontSize="62" FontFamily="/Assets/Latin/Default.otf#SF Pro Display" HorizontalAlignment="Left" />
<TextBlock FontStretch="UltraCondensed" Text="21:35" Foreground="Black" VerticalAlignment="Bottom" Margin="0,0,20,10" FontSize="21" FontFamily="/Assets/Latin/Default.otf#SF Pro Display" HorizontalAlignment="Right" />
</Grid>

<Grid x:Name="Instellingen" HorizontalAlignment="Left" Height="80" Width="80" Margin="400,0,0,-160">
<Grid x:Name="Instellingen" HorizontalAlignment="Center" Height="80" Width="80" Margin="100,0,0,-170">
<Border Background="Gray" CornerRadius="10"/>
</Grid>

Expand Down
2 changes: 2 additions & 0 deletions PiMusic/Home.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ namespace PiMusic
/// </summary>
public partial class Home : Page
{


public Home()
{
InitializeComponent();
Expand Down
2 changes: 1 addition & 1 deletion PiMusic/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:PiMusic"
mc:Ignorable="d"
Title="Imad's Music Player (v1.0.0.84)" Height="480" Width="800">
Title="Imad's Music Player (v1.0)" Height="480" Width="800">
<Grid>
<Frame x:Name="HomeScreen" NavigationUIVisibility="Hidden"/>
<Frame x:Name="MainContent" NavigationUIVisibility="Hidden"/>
Expand Down
14 changes: 14 additions & 0 deletions PiMusic/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,25 @@ public MainWindow()

public void ConfirmClosure()
{
// Dispose of the content if it's disposable
if (MainContent.Content is IDisposable disposableContent)
{
disposableContent.Dispose();
}

MainContent.Content = null;

// Dispose of the content if it's disposable
if (Navbar.Content is IDisposable disposableNavbar)
{
disposableNavbar.Dispose();
}

Navbar.Content = null;
Navbar.Content = new Navbar();

Statusbar.Instance.SwitchColor(0);
}

}
}
18 changes: 18 additions & 0 deletions PiMusic/Music/MusicBackground.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<Page x:Class="PiMusic.Music.MusicBackground"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:PiMusic.Music"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"
Title="MusicBackground">

<Grid>
<Image Opacity="0.8" Stretch="Fill" Margin="-30,-150,-30,-150" Source="/Assets/Placeholders/Cover.jpg">
<Image.Effect>
<BlurEffect Radius="50" />
</Image.Effect>
</Image>
</Grid>
</Page>
28 changes: 28 additions & 0 deletions PiMusic/Music/MusicBackground.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace PiMusic.Music
{
/// <summary>
/// Interaction logic for MusicBackground.xaml
/// </summary>
public partial class MusicBackground : Page
{
public MusicBackground()
{
InitializeComponent();
}
}
}
34 changes: 24 additions & 10 deletions PiMusic/Music/MusicHome.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,43 @@
Title="MusicHome">

<Grid x:Name="MainContent" Background="Black">
<TextBlock x:Name="LocalFiles" Foreground="White" Text="Schijf" Margin="40,14,0,0" FontSize="32" FontFamily="/Assets/Latin/Default.otf#SF Pro Display" HorizontalAlignment="Left" VerticalAlignment="Top" />
<TextBlock x:Name="OnlineRadio" Foreground="White" Text="Radio" Margin="140,14,0,0" FontSize="32" FontFamily="/Assets/Latin/Default.otf#SF Pro Display" HorizontalAlignment="Left" VerticalAlignment="Top" />
<Border Background="White" CornerRadius="2" Height="3" Width="25" Margin="65,52,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Opacity="1"/>
<Frame x:Name="CoverBlurBG" />

<TextBlock Opacity="0" x:Name="NoResults" Foreground="White" Text="Geen liedjes gevonden. Voeg er toe via een SD-Kaart of USB." Margin="0,0,0,0" FontSize="24" FontFamily="/Assets/Latin/Default.otf#SF Pro Display" HorizontalAlignment="Center" VerticalAlignment="Center" />

<Grid x:Name="Song" Height="50" VerticalAlignment="Top" Margin="30,80,30,0">
<Border Background="#E9A54B" CornerRadius="20" Opacity="0.7"/>
<TextBlock x:Name="Title" Text="Fractured Angel" Foreground="White" Margin="30,0,0,11" FontSize="24" FontFamily="/Assets/Latin/Default.otf#SF Pro Display" HorizontalAlignment="Left" VerticalAlignment="Bottom" />
</Grid>
<ScrollViewer x:Name="SongSelection" VerticalScrollBarVisibility="Hidden" Margin="0,0,0,75" PanningMode="Both">
</ScrollViewer>

<Rectangle Height="90" Margin="0,0,0,0" VerticalAlignment="Top">
<Rectangle.Fill>
<LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
<GradientStop x:Name="GradientTop" Color="#000000" Offset="0.1" />
<GradientStop x:Name="GradientBottom" Color="Transparent" Offset="0.7" />
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>

<TextBlock x:Name="LocalFiles" Foreground="White" Text="Schijf" Margin="40,14,0,0" FontSize="32" FontFamily="/Assets/Latin/Default.otf#SF Pro Display" HorizontalAlignment="Left" VerticalAlignment="Top" />
<TextBlock x:Name="OnlineRadio" Foreground="White" Text="Radio" Margin="140,14,0,0" FontSize="32" FontFamily="/Assets/Latin/Default.otf#SF Pro Display" HorizontalAlignment="Left" VerticalAlignment="Top" />
<Border Background="White" CornerRadius="2" Height="3" Width="25" Margin="65,52,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Opacity="1"/>

<Grid x:Name="Bar" Margin="0,0,0,-25">
<Border Background="Gray" CornerRadius="30" Height="100" VerticalAlignment="Bottom" Opacity="1"/>

<Rectangle VerticalAlignment="Bottom" HorizontalAlignment="Left" x:Name="CoverArt" Margin="50,0,0,40" RadiusX="10" RadiusY="10" Width="50" Height="50">
<Rectangle VerticalAlignment="Bottom" HorizontalAlignment="Left" x:Name="CoverArt" Margin="50,0,0,32" RadiusX="10" RadiusY="10" Width="60" Height="60">
<Rectangle.Fill>
<ImageBrush RenderOptions.BitmapScalingMode="HighQuality" ImageSource="/Assets/Placeholders/Cover2.jpg"/>
</Rectangle.Fill>
</Rectangle>

<TextBlock x:Name="SongTitle" FontStretch="UltraCondensed" Text="Belle de Nuit" Foreground="White" Margin="110,0,0,62" FontSize="24" FontFamily="/Assets/Latin/Default.otf#SF Pro Display" HorizontalAlignment="Left" VerticalAlignment="Bottom" />
<TextBlock x:Name="SongArtist" FontStretch="UltraCondensed" Text="黒皇帝 feat. AKA" Foreground="White" Margin="110,0,0,40" FontSize="20" FontFamily="/Assets/Latin/Default.otf#SF Pro Display" HorizontalAlignment="Left" VerticalAlignment="Bottom" />
<TextBlock x:Name="MusicTitle" FontStretch="UltraCondensed" Text="Selecteer een liedje om af te spelen." Foreground="White" Margin="125,0,0,50" FontSize="24" FontFamily="/Assets/Latin/Default.otf#SF Pro Display" HorizontalAlignment="Left" VerticalAlignment="Bottom" />
<TextBlock Opacity="0" x:Name="MusicArtist" FontStretch="UltraCondensed" Text="" Foreground="White" Margin="125,0,0,40" FontSize="20" FontFamily="/Assets/Latin/Default.otf#SF Pro Display" HorizontalAlignment="Left" VerticalAlignment="Bottom" />

<Grid x:Name="PauseButton">
<Image Opacity="0" x:Name="PausePic" RenderOptions.BitmapScalingMode="HighQuality" Source="/Assets/Icons/Light/Pause.png" Height="35" VerticalAlignment="Bottom" HorizontalAlignment="Right" Margin="0,0,50,45"/>
<Border x:Name="PauseBGEffect" Width="60" Height="40" Opacity="0" Background="White" CornerRadius="12" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0,0,37,43"/>
<Button Click="PauseClick" Width="60" Height="40" Opacity="0" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0,0,37,43" />
</Grid>
</Grid>
</Grid>
</Page>
190 changes: 189 additions & 1 deletion PiMusic/Music/MusicHome.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
using System;
using NAudio.Wave;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Forms;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Threading;
using static PiMusic.MusicHandler;

namespace PiMusic.Music
{
Expand All @@ -21,11 +28,176 @@ namespace PiMusic.Music
/// </summary>
public partial class MusicHome : Page
{
public static MusicHome Instance;

public Stopwatch stopwatch;
public DispatcherTimer timer;

public MusicHome()
{
InitializeComponent();
Instance = this;
MusicLibPrep();

CoverBlurBG.Content = new MusicBackground();
}

public async Task MusicLibPrep()
{
string exeDirectory = AppDomain.CurrentDomain.BaseDirectory;
string configDirectory = System.IO.Path.Combine(exeDirectory, "Config");
string filePath = System.IO.Path.Combine(configDirectory, "SongIndex.json");
string json = await System.IO.File.ReadAllTextAsync(filePath);
List<string> Songs = JsonConvert.DeserializeObject<List<string>>(json);

ScrollViewer songSelection = this.FindName("SongSelection") as ScrollViewer;

StackPanel songPanel = new StackPanel();

int Position = 1;
int Pos1;

foreach (string song in Songs)
{
TagLib.File tagFile = TagLib.File.Create(song);
TimeSpan duration = tagFile.Properties.Duration;

if (Position == 1)
{
Pos1 = 100;
Position = 0;
}
else
{
Pos1 = 20;
}

Grid songGrid = new Grid
{
Height = 90,
VerticalAlignment = VerticalAlignment.Top,
Margin = new Thickness(30, Pos1, 30, 0)
};

string AccentColor = "#000000";
Color color = (Color)ColorConverter.ConvertFromString(AccentColor);

Border border = new Border
{
Background = new SolidColorBrush(color),
CornerRadius = new CornerRadius(20),
Opacity = 0.7
};

songGrid.Children.Add(border);

if (tagFile.Tag.Pictures.Length >= 1)
{
var bin = (byte[])(tagFile.Tag.Pictures[0].Data.Data);
MemoryStream ms = new MemoryStream(bin);

BitmapImage albumCover = new BitmapImage();
albumCover.BeginInit();
albumCover.CacheOption = BitmapCacheOption.OnLoad;
albumCover.StreamSource = ms;
albumCover.EndInit();
albumCover.Freeze();

Rectangle cover1 = new Rectangle
{
Margin = new Thickness(30, 0, 0, 0),
HorizontalAlignment = System.Windows.HorizontalAlignment.Left,
RadiusX = 10,
RadiusY = 10,
Width = 80,
Height = 80,

Fill = new ImageBrush
{
ImageSource = albumCover
}
};

songGrid.Children.Add(cover1);
}

StackPanel stackPanel = new StackPanel
{
VerticalAlignment = VerticalAlignment.Center,
Margin = new Thickness(130, 0, 200, 0)
};

stackPanel.Children.Add(new TextBlock { Text = tagFile.Tag.Title, Foreground = new SolidColorBrush(Colors.White), Margin = new Thickness(0, -3, 0, 0), TextWrapping = TextWrapping.Wrap, FontSize = 24, FontFamily = new FontFamily(new Uri("pack://application:,,,/"), "./Assets/Latin/Default.otf#SF Pro Display")
});
stackPanel.Children.Add(new TextBlock { Text = tagFile.Tag.FirstPerformer, Foreground = new SolidColorBrush(Colors.White), FontSize = 18, FontFamily = new FontFamily(new Uri("pack://application:,,,/"), "./Assets/Latin/Default.otf#SF Pro Display") });

songGrid.Children.Add(stackPanel);

songGrid.Children.Add(new TextBlock { Text = duration.ToString(@"mm\:ss"), Foreground = new SolidColorBrush(Colors.White), Margin = new Thickness(0, -40, 30, 0), FontSize = 24, VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = System.Windows.HorizontalAlignment.Right, FontFamily = new FontFamily(new Uri("pack://application:,,,/"), "./Assets/Latin/Default.otf#SF Pro Display") });

FileInfo fileInfo = new FileInfo(song);
long fileSizeInBytes = fileInfo.Length;
double fileSizeInMB = Math.Round((double)fileSizeInBytes / 1048576, 2);

songGrid.Children.Add(new TextBlock { Text = fileSizeInMB.ToString() + " MB", Foreground = new SolidColorBrush(Colors.White), Margin = new Thickness(0, 10, 30, 0), FontSize = 24, HorizontalAlignment = System.Windows.HorizontalAlignment.Right, VerticalAlignment = VerticalAlignment.Center, FontFamily = new FontFamily(new Uri("pack://application:,,,/"), "./Assets/Latin/Default.otf#SF Pro Display") });

var button = new System.Windows.Controls.Button { Opacity = 0, Content = song };
button.Click += Button_Click;
songGrid.Children.Add(button);

songPanel.Children.Add(songGrid);
}
songSelection.Content = songPanel;
}
private async void Button_Click(object sender, RoutedEventArgs e)
{
QuinticEase c = new QuinticEase();
c.EasingMode = EasingMode.EaseInOut;

ThicknessAnimation PosCorrect = new ThicknessAnimation()
{
To = new Thickness(125, 0, 0, 62),
Duration = TimeSpan.FromSeconds(1),
EasingFunction = c
};

DoubleAnimation Appear = new DoubleAnimation()
{
To = 1,
Duration = TimeSpan.FromSeconds(0.5)
};

System.Windows.Controls.Button button = sender as System.Windows.Controls.Button;
var content = button.Content;

MusicHandler.StartMusic(content.ToString());
TagLib.File tagFile = TagLib.File.Create(content.ToString());

MusicTitle.Text = tagFile.Tag.Title;
MusicArtist.Text = tagFile.Tag.FirstPerformer;

MusicTitle.BeginAnimation(TextBlock.MarginProperty, PosCorrect);
await Task.Delay(500);
MusicArtist.BeginAnimation(TextBlock.OpacityProperty, Appear);

if (tagFile.Tag.Pictures.Length >= 1)
{
var bin = (byte[])(tagFile.Tag.Pictures[0].Data.Data);
MemoryStream ms = new MemoryStream(bin);

BitmapImage albumCover = new BitmapImage();
albumCover.BeginInit();
albumCover.StreamSource = ms;
albumCover.EndInit();

// Assuming you're in the same class where CoverArt is defined
ImageBrush brush = (ImageBrush)CoverArt.Fill;
brush.ImageSource = albumCover;
}
PausePic.Opacity = 1;
}


public async void Closure()
{
QuinticEase c = new QuinticEase();
Expand Down Expand Up @@ -64,5 +236,21 @@ public async void Closure()

MainWindow.Instance.ConfirmClosure();
}

private void PauseClick(object sender, RoutedEventArgs e)
{
if(MusicHandler.IsPlaying == false)
{
MusicHandler.ResumeMusic();
PausePic.Source = new BitmapImage(new Uri("pack://application:,,,/PiMusic;component/Assets/Icons/Light/Pause.png"));
}
else
{
MusicHandler.PauseMusic();
PausePic.Source = new BitmapImage(new Uri("pack://application:,,,/PiMusic;component/Assets/Icons/Light/Play.png"));
}

return;
}
}
}
Loading

0 comments on commit aa94664

Please sign in to comment.