Skip to content

Commit

Permalink
V2.0
Browse files Browse the repository at this point in the history
- Mejoras añadidas
  • Loading branch information
Ts-Pytham committed Dec 25, 2020
1 parent 9cf5379 commit 60e8e13
Show file tree
Hide file tree
Showing 53 changed files with 2,017 additions and 158 deletions.
Binary file modified .vs/Reproductor de Musica/v16/.suo
Binary file not shown.
Binary file added Reproductor de Musica/IMG/ajuste.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Reproductor de Musica/IMG/ajuste2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Reproductor de Musica/IMG/charla.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Reproductor de Musica/IMG/tema.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
45 changes: 27 additions & 18 deletions Reproductor de Musica/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,20 @@
<Grid>

<WrapPanel x:Name="WrapPanel_Principal" HorizontalAlignment="Left" Height="36" VerticalAlignment="Top" Width="1280" Background="Black" MouseLeftButtonDown="WrapPanel_MouseLeftButtonDown">
<Button Width="75" Background="Black" BorderBrush="Black" Foreground="White" Click="ButtonMinimize_Click" Height="36" Style="{DynamicResource ButtonMinimize}" Margin="1130,0,0,0">
<Button x:Name="Button_Minus" Width="75" Background="Black" BorderBrush="Black" Foreground="White" Click="ButtonMinimize_Click" Height="36" Style="{DynamicResource ButtonMinimize}" Margin="1130,0,0,0">
<Image Source="/IMG/minimizar.png" Height="26" Width="24"></Image>
</Button>
<Button Width="75" Background="Black" BorderBrush="Black" Foreground="White" Click="ButtonX_Click" Style="{DynamicResource ButtonClose}" >
<Button x:Name="Button_X" Width="75" Background="Black" BorderBrush="Black" Foreground="White" Click="ButtonX_Click" Style="{DynamicResource ButtonClose}" >
<Image Source="/IMG/cerrar.png" Height="14" Width="11"></Image>
</Button>
</WrapPanel>

<StackPanel HorizontalAlignment="Left" Height="584" Margin="0,36,0,0" VerticalAlignment="Top" Width="180" Background="#FF151515">
<StackPanel x:Name="StackPanel_Principal" HorizontalAlignment="Left" Height="584" Margin="0,36,0,0" VerticalAlignment="Top" Width="180" Background="#FF151515">
<WrapPanel Height="70" Margin="10,92,0,0">
<Rectangle x:Name="Rectangle_Barra" Fill="#FFFE4164" Height="21" Stroke="Black" Width="6" Visibility="Hidden"/>
<Image Height="41" Width="26" Source="/IMG/circulo-plus.png" Margin="5,0,0,0"/>
<Image x:Name="Image_Add" Height="41" Width="26" Source="/IMG/circulo-plus.png" Margin="5,0,0,0" MouseLeftButtonDown="TextBlock_MouseLeftButtonDown"/>
<TextBlock x:Name="TextBlock_Add" TextWrapping="Wrap" Text="Agregar Música" Foreground="#FFCFCFCF" VerticalAlignment="Center" Margin="10,0,0,0" FontFamily="Verdana" MouseLeftButtonDown="TextBlock_MouseLeftButtonDown" MouseLeave="TextBlock_Add_MouseLeave" MouseEnter="TextBlock_Add_MouseEnter" MouseLeftButtonUp="TextBlock_Add_MouseLeftButtonUp" FontWeight="Bold">
<TextBlock.OpacityMask>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="Black" Offset="0"/>
<GradientStop Color="White" Offset="1"/>
</LinearGradientBrush>
</TextBlock.OpacityMask>

</TextBlock>

</WrapPanel>
Expand All @@ -36,15 +31,27 @@

<WrapPanel Height="70" Margin="10,-4,0,0">
<Rectangle x:Name="Rectangle_Barra1" Fill="#FFFE4164" Height="21" Stroke="Black" Width="6" Visibility="Hidden"/>
<Image Height="41" Width="26" Source="/IMG/playlist.png" Margin="5,0,0,0"/>
<Image x:Name="Image_PlayList" Height="41" Width="26" Source="/IMG/playlist.png" Margin="5,0,0,0" MouseLeftButtonDown ="TextBlock_MouseLeftButtonDown"/>
<TextBlock x:Name="TextBlock_PlayList" TextWrapping="Wrap" Text="Agregar PlayList" Foreground="#FFCFCFCF" VerticalAlignment="Center" Margin="10,0,0,0" FontFamily="Verdana" MouseLeftButtonDown="TextBlock_MouseLeftButtonDown" MouseLeave="TextBlock_Add_MouseLeave" MouseEnter="TextBlock_Add_MouseEnter" MouseLeftButtonUp="TextBlock_Add_MouseLeftButtonUp" FontWeight="Bold"/>

</WrapPanel>

<WrapPanel Height="70" Margin="10,-4,0,0">
<Rectangle x:Name="Rectangle_Barra2" Fill="#FFFE4164" Height="21" Stroke="Black" Width="6" Visibility="Hidden"/>
<Image x:Name="Image_Favorite" Height="41" Width="26" Source="/IMG/Favorite/favorite.png" Margin="5,0,0,0"/>
<TextBlock x:Name="TextBlock_Favorite" TextWrapping="Wrap" Text="Favoritas" Foreground="#FFCFCFCF" VerticalAlignment="Center" Margin="10,0,0,0" FontFamily="Verdana" MouseLeave="TextBlock_Add_MouseLeave" MouseEnter="TextBlock_Add_MouseEnter" MouseLeftButtonUp="TextBlock_Add_MouseLeftButtonUp" FontWeight="Bold"/>
</WrapPanel>

<WrapPanel Height="70" Margin="10,-4,0,0">
<Rectangle x:Name="Rectangle_Barra3" Fill="#FFFE4164" Height="21" Stroke="Black" Width="6" Visibility="Hidden"/>
<Image x:Name="Image_Ajuste" Height="41" Width="26" Source="/IMG/ajuste2.png" Margin="5,0,0,0" MouseLeftButtonDown="TextBox_Ajuste_MouseLeftButtonDown"/>
<TextBlock x:Name="TextBlock_Ajuste" TextWrapping="Wrap" Text="Ajustes" Foreground="#FFCFCFCF" VerticalAlignment="Center" Margin="10,0,0,0" FontFamily="Verdana" MouseLeave="TextBlock_Add_MouseLeave" MouseEnter="TextBlock_Add_MouseEnter" MouseLeftButtonUp="TextBlock_Add_MouseLeftButtonUp" FontWeight="Bold" MouseLeftButtonDown="TextBox_Ajuste_MouseLeftButtonDown"/>
</WrapPanel>

</StackPanel>

<WrapPanel HorizontalAlignment="Left" Height="100" Margin="0,620,0,0" VerticalAlignment="Top" Width="1280" Background="#FF212121">
<TextBlock x:Name="Name_Music" Text="-" Foreground="White" FontFamily="Verdana" Padding="58,31,0,0" Width="200"/>
<WrapPanel x:Name="WrapPanel_Secundaria" HorizontalAlignment="Left" Height="100" Margin="0,620,0,0" VerticalAlignment="Top" Width="1280" Background="#FF212121">
<TextBlock x:Name="Name_Music" Text="-" Foreground="White" FontFamily="Verdana" Padding="90,31,0,0" Width="200"/>
<StackPanel Height="100" Width="574" Margin="150,0,0,0">
<Image Height="23" Source="/IMG/Aleatorio/barajar.png" Margin="202,17,340,6"/>

Expand All @@ -64,6 +71,10 @@
<Slider x:Name="Slider_Volumen" Width="218" Height="36" Style="{DynamicResource Horizontal_Slider}" Value="0" Maximum="1" Margin="115,0,0,24" ValueChanged="Slider_ValueChanged"/>

</WrapPanel>


<TextBlock x:Name="TextBlock_Author_Name" HorizontalAlignment="Left" Margin="90,670,0,0" TextWrapping="Wrap" Text="-" VerticalAlignment="Top" Foreground="White"/>

<Slider x:Name="Slider_Carga" Height="36" Margin="500,674,478,10" Style="{DynamicResource Horizontal_Slider1}" Value="0" Maximum="100" Background="AliceBlue" MouseLeftButtonUp="Slider_Carga_MouseLeftButtonUp"/>
<TextBlock x:Name="Text_MinLength" HorizontalAlignment="Left" Margin="456,679,0,0" TextWrapping="Wrap" Text="-" VerticalAlignment="Top" Foreground="White" FontFamily="Verdana" />
<TextBlock x:Name="Text_MaxLength" HorizontalAlignment="Left" Margin="822,679,0,0" TextWrapping="Wrap" Text="-" VerticalAlignment="Top" Foreground="White" FontFamily="Verdana" />
Expand All @@ -77,7 +88,7 @@
</Trigger>

<Trigger Property="IsSelected" Value="False" >
<Setter Property="Background" Value="#FF2F3136" />

<Setter Property="Foreground" Value="White" />
</Trigger>
</Style.Triggers>
Expand All @@ -87,10 +98,8 @@

</ListBox>
<Image x:Name="IMG_Favorite" HorizontalAlignment="Left" Height="24" Margin="517,638,0,0" VerticalAlignment="Top" Width="22" Source="/IMG/Favorite/favorite.png" MouseLeftButtonDown="Image_MouseLeftButtonDown_1"/>




<TextBlock x:Name="TextBlock_Info_PlayList" HorizontalAlignment="Left" Margin="240,588,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Foreground="White" FontFamily="Verdana"/>




Expand Down
160 changes: 142 additions & 18 deletions Reproductor de Musica/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,49 @@ namespace Reproductor_de_Musica
/// <summary>
/// Lógica de interacción para MainWindow.xaml
/// </summary>
[Serializable]
public partial class MainWindow : Window
{

private readonly MediaPlayer mediaPlayer = new MediaPlayer();
private bool IsPaused = true;
private readonly List<string> URLS = new List<string>();
public List<string> LTheme = new List<string>();
private TimeSpan position;
private DispatcherTimer timer = new DispatcherTimer();
private TimeSpan suma = new TimeSpan();
private WinAjuste win;
/* Si theme es igual a 0 quiere decir, que el tema será de color negro,
* Si es igual a 1 es porque el tema es claro, 2 tema Opera GX y si
* es igual a 3 el tema es personalizado.
*/
public int theme = 0;







public MainWindow()
{
//mediaPlayer = new MediaPlayer();

InitializeComponent();
if (IO.File.Exists("theme.pytham"))
{
GetTheme();
}
}


private void WrapPanel_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
this.DragMove();
}

private void ButtonX_Click(object sender, RoutedEventArgs e)
{
if(win != null)
win.Close();
this.Close();
}

Expand Down Expand Up @@ -75,15 +97,26 @@ private void Button_Pause_Click(object sender, RoutedEventArgs e)
/* Para hacer el efecto de darle click al textblock y que sea tipo button*/
private void TextBlock_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{

TextBlock textBlock = (TextBlock)sender;
/* Creo el try catch para comprobar si lo que ingresa es un botón o un imagen
* Sirve para que tanto el botón como el textBlock puedan acceder a sus bloque de código.
*/
TextBlock textBlock = new TextBlock();
Image image = new Image();
try
{
textBlock = (TextBlock)sender;
}
catch (System.InvalidCastException)
{
image = (Image)sender;
}

textBlock.Foreground = Brushes.Gray;
/* El if comprueba cual textblock fue el que se presionó,
* solo sirve para ocultar/mostrar el rectángulo y llama a la función para
* agregar la música, es decir, si entra en el else es porque el usuario ingresa
* una playlist. */
if (textBlock.Name == "TextBlock_Add")
if (textBlock.Name == "TextBlock_Add" || image.Name == "Image_Add")
{
Rectangle_Barra.Visibility = Visibility.Visible;
Rectangle_Barra1.Visibility = Visibility.Hidden;
Expand All @@ -97,7 +130,7 @@ private void TextBlock_MouseLeftButtonDown(object sender, MouseButtonEventArgs e
if (fd.ShowDialog() == WinForms.DialogResult.OK)
{

Name_Music.Text = fd.SafeFileName;
Name_Music.Text = IO.Path.GetFileNameWithoutExtension(fd.SafeFileName);

mediaPlayer.Open(new Uri(fd.FileName));

Expand All @@ -119,12 +152,14 @@ private void TextBlock_MouseLeftButtonDown(object sender, MouseButtonEventArgs e

mediaPlayer.MediaOpened += MediaPlayer_MediaOpened;

ListBox.Items.Add($"{ListBox.Items.Count + 1} - {fd.SafeFileName}");
TagLib.File tagFile = TagLib.File.Create(fd.FileName);
ListBox.Items.Add($"{ListBox.Items.Count + 1} - {IO.Path.GetFileNameWithoutExtension(fd.SafeFileName)}");

URLS.Add(fd.FileName);

//TextBlock_Author_Name.Text = TagLib.File.Create(fd.FileName).Tag.FirstAlbumArtist;
ListBox.SelectedIndex = ListBox.Items.Count - 1;

suma += tagFile.Properties.Duration;
}
}
}
Expand All @@ -144,9 +179,9 @@ private void TextBlock_MouseLeftButtonDown(object sender, MouseButtonEventArgs e
if (fd.ShowDialog() == WinForms.DialogResult.OK)
{

Name_Music.Text = fd.SafeFileName;
Name_Music.Text = IO.Path.GetFileNameWithoutExtension(fd.SafeFileName);

mediaPlayer.Open(new Uri(fd.FileName));



Image img = new Image { Source = new BitmapImage(new Uri(@"pack://application:,,,/IMG/pausa.png")) };
Expand All @@ -171,12 +206,22 @@ private void TextBlock_MouseLeftButtonDown(object sender, MouseButtonEventArgs e
IsEmpty = false;

int len = fd.FileNames.Length;

for(int i = 0; i != len; ++i)
{
ListBox.Items.Add($"{ListBox.Items.Count + 1} - {fd.SafeFileNames[i]}");
TagLib.File tagFile = TagLib.File.Create(fd.FileNames[i]);
ListBox.Items.Add($"{ListBox.Items.Count + 1} - {IO.Path.GetFileNameWithoutExtension(fd.SafeFileNames[i])}");
//ListBox.Items.Add($"{ListBox.Items.Count + 1} - {tagFile.Properties.N}");
URLS.Add(fd.FileNames[i]);

suma += tagFile.Properties.Duration;
}


mediaPlayer.Open(new Uri(fd.FileName));



// Comprueba si en la lista hay música, si no hay pone el index en 0.
if (IsEmpty)
ListBox.SelectedIndex = 0;
Expand All @@ -192,20 +237,25 @@ private void TextBlock_MouseLeftButtonDown(object sender, MouseButtonEventArgs e

private void MediaPlayer_MediaOpened(object sender, EventArgs e)
{

mediaPlayer.Play();

TextBlock_Info_PlayList.Text = $"Duración total: {suma:dd\\:hh\\:mm\\:ss}";
TextBlock_Author_Name.Text = TagLib.File.Create(URLS[ListBox.SelectedIndex]).Tag.FirstAlbumArtist;
position = mediaPlayer.NaturalDuration.TimeSpan;
Slider_Carga.Minimum = 0;
Slider_Carga.Maximum = position.TotalSeconds;

Text_MinLength.Text = mediaPlayer.Position.ToString(@"mm\:ss");
Text_MaxLength.Text = mediaPlayer.NaturalDuration.TimeSpan.ToString(@"mm\:ss");
}

private void TextBlock_Add_MouseLeave(object sender, MouseEventArgs e)
{
TextBlock textBlock = (TextBlock)sender;

textBlock.Foreground = new SolidColorBrush(Color.FromRgb(207, 207, 207));
if(theme == 0 || theme == 2)
textBlock.Foreground = new SolidColorBrush(Color.FromRgb(207, 207, 207));
else
textBlock.Foreground = new SolidColorBrush(Color.FromRgb(0, 0, 0));
}

private void TextBlock_Add_MouseEnter(object sender, MouseEventArgs e)
Expand Down Expand Up @@ -377,16 +427,30 @@ private void ListBox_Drop(object sender, DragEventArgs e)
}

}
Name_Music.Text = IO.Path.GetFileName(files[0]);

DispatcherTimer timer = new DispatcherTimer
{
Interval = TimeSpan.FromSeconds(1)
};
timer.Tick += Timer_Tick;
timer.Start();

mediaPlayer.MediaOpened += MediaPlayer_MediaOpened;

int len = files.Length;
for(int i = 0; i != len; ++i)
{
ListBox.Items.Add($"{ListBox.Items.Count + 1} - {IO.Path.GetFileName(files[i])}");
TagLib.File tagLib = TagLib.File.Create(files[i]);

ListBox.Items.Add($"{ListBox.Items.Count + 1} - {IO.Path.GetFileNameWithoutExtension(files[i])}");
URLS.Add(files[i]);
suma += tagLib.Properties.Duration;
}

ListBox.SelectedIndex = 0;



TextBlock_Info_PlayList.Text = $"Duración total: {suma:dd\\:hh\\:mm\\:ss}";

}
/* Eventos para guardar las canciones favoritas */
Expand All @@ -398,6 +462,66 @@ private void Image_MouseLeftButtonDown_1(object sender, MouseButtonEventArgs e)
IMG_Favorite.Source = new BitmapImage(new Uri(@"pack://application:,,,/IMG/Favorite/clic_favorite.png"));
}







/* Eventos para el botón de ajustes */

private void TextBox_Ajuste_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{

win = new WinAjuste(this);

win.Show();
}



/* Función para obtener los elementos */

public void GetTheme()
{
LTheme = Utilidades.Utilities.GetFile("theme");

WrapPanel_Principal.Background = (Brush)new BrushConverter().ConvertFrom(LTheme[0]);

Button_X.Background = (Brush)new BrushConverter().ConvertFrom(LTheme[0]);
Button_X.BorderBrush = (Brush)new BrushConverter().ConvertFrom(LTheme[0]);
Button_Minus.Background = (Brush)new BrushConverter().ConvertFrom(LTheme[0]);
Button_Minus.BorderBrush = (Brush)new BrushConverter().ConvertFrom(LTheme[0]);
this.Background = (Brush)new BrushConverter().ConvertFrom(LTheme[1]);

ListBox.Background = (Brush)new BrushConverter().ConvertFrom(LTheme[1]);
ListBox.Foreground = (Brush)new BrushConverter().ConvertFrom(LTheme[4]);
ResourceDictionary resourceDictionary = new ResourceDictionary
{
Source = new Uri(@"pack://application:,,,/Styles/ListBox.xaml")
};

theme = Convert.ToInt32(LTheme[6]);

if (theme == 0 || theme == 2)
ListBox.ItemContainerStyle = (Style)resourceDictionary["Modo_Oscuro"];
else
ListBox.ItemContainerStyle = (Style)resourceDictionary["Modo_Claro"];

StackPanel_Principal.Background = (Brush)new BrushConverter().ConvertFrom(LTheme[2]);
WrapPanel_Secundaria.Background = (Brush)new BrushConverter().ConvertFrom(LTheme[3]);

TextBlock_Add.Foreground = (Brush)new BrushConverter().ConvertFrom(LTheme[5]);
TextBlock_Favorite.Foreground = (Brush)new BrushConverter().ConvertFrom(LTheme[5]);
TextBlock_PlayList.Foreground = (Brush)new BrushConverter().ConvertFrom(LTheme[5]);
TextBlock_Author_Name.Foreground = (Brush)new BrushConverter().ConvertFrom(LTheme[5]);
TextBlock_Ajuste.Foreground = (Brush)new BrushConverter().ConvertFrom(LTheme[5]);
Name_Music.Foreground = (Brush)new BrushConverter().ConvertFrom(LTheme[5]);
Text_MinLength.Foreground = (Brush)new BrushConverter().ConvertFrom(LTheme[4]);
Text_MaxLength.Foreground = (Brush)new BrushConverter().ConvertFrom(LTheme[4]);
TextBlock_Info_PlayList.Foreground = (Brush)new BrushConverter().ConvertFrom(LTheme[4]);



}
}
}
Loading

0 comments on commit 60e8e13

Please sign in to comment.