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 Jun 1, 2024
1 parent 1dc9cef commit a7a1f83
Show file tree
Hide file tree
Showing 8 changed files with 125 additions and 84 deletions.
2 changes: 1 addition & 1 deletion SoundOS6/Views/MainView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
x:Class="SoundOS6.Views.MainView"
x:DataType="vm:MainViewModel">
<Grid Background="Black">
<Image Opacity="0.5" Source="/Assets/Placeholders/DefaultWallpaper.jpg" Stretch="UniformToFill">
<Image Opacity="0.5" Source="/Assets/Placeholders/DefaultWallpaper.jpg" Margin="-20,-20,-20,-20" Stretch="UniformToFill">
<Image.Effect>
<BlurEffect Radius="45" />
</Image.Effect>
Expand Down
6 changes: 2 additions & 4 deletions SoundOS6/Views/MainView.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ await Dispatcher.UIThread.InvokeAsync(() =>
EndTime.Opacity = 1;
BackgroundBar.Opacity = 1;
LiveLbl.Opacity = 0;

EndTime.Text = SongSpan.ToString();
}

Instructions.Opacity = 0;
Expand All @@ -79,7 +77,7 @@ private void Button_Click(object? sender, Avalonia.Interactivity.RoutedEventArgs
{
MusicHandler.ResumeMusic();

using (var stream = AssetLoader.Open(new Uri("avares://PiSound/Assets/Icons/Light/Pause.png")))
using (var stream = AssetLoader.Open(new Uri("avares://SoundOS6/Assets/Icons/Light/Pause.png")))
{
Play.Source = new Avalonia.Media.Imaging.Bitmap(stream);
}
Expand All @@ -91,7 +89,7 @@ private void Button_Click(object? sender, Avalonia.Interactivity.RoutedEventArgs
else
{
MusicHandler.PauseMusic();
using (var stream = AssetLoader.Open(new Uri("avares://PiSound/Assets/Icons/Light/Play.png")))
using (var stream = AssetLoader.Open(new Uri("avares://SoundOS6/Assets/Icons/Light/Play.png")))
{
Play.Source = new Avalonia.Media.Imaging.Bitmap(stream);
}
Expand Down
2 changes: 1 addition & 1 deletion SoundOS6/Views/MainWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="SoundOS6.Views.MainWindow"
Icon="/Assets/avalonia-logo.ico"
Title="SoundOS (1.2 - Preview 2)">
Title="SoundOS (1.2 - Preview 3)">
<views:MainView />
</Window>
10 changes: 2 additions & 8 deletions SoundOS6/Views/Music/MusicLocal.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,6 @@ private async void Button_Click(object sender, RoutedEventArgs e)
MusicHome.Instance.PausePic.Opacity = 1;
MainView.Instance.PlayCommandBtn.IsEnabled = true;

TimeSpan duration = tagFile.Properties.Duration;
MainView.Instance.EndTime.Text = duration.ToString(@"m\:ss");

MainView.Instance.UnhideMusicWidget();

using (var stream = AssetLoader.Open(new Uri("avares://SoundOS6/Assets/Icons/Light/Pause.png")))
Expand Down Expand Up @@ -219,11 +216,8 @@ public async static void ElapsedProcess(object sender, EventArgs e)

try
{
if (TVMode.Instance.NotDragged)
{
TVMode.Instance.TimerElapsed.Text = currentPositionFormatted;
TVMode.Instance.Slider.Value = currentPositionInSeconds;
}
TVMode.Instance.TimerElapsed.Text = currentPositionFormatted;
TVMode.Instance.Slider.Value = currentPositionInSeconds;
}
catch (Exception)
{
Expand Down
2 changes: 1 addition & 1 deletion SoundOS6/Views/Music/MusicRadio.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ private async void Button_Click(object? sender, Avalonia.Interactivity.RoutedEve
MusicHome.Instance.MusicArtist.Text = MusicHandler.MusicMetadata.Artist;

var client = new HttpClient();
var response = await client.GetAsync("https://plus.imadsnetwork.net/icon/Radio/STUBRU.png");
var response = await client.GetAsync("https://plus.imadsnetwork.net/icon/Radio/MPB_Radio_1.png");
var bytes = await response.Content.ReadAsByteArrayAsync();
using var ms = new MemoryStream(bytes);
var bitmap = new Bitmap(ms);
Expand Down
22 changes: 16 additions & 6 deletions SoundOS6/Views/Music/TVMode.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<Image Source="/Assets/Icons/Light/Back.png" Height="40" Margin="30,14,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" />
<Button Click="Button_Click" Opacity="0" Height="40" Width="70" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="0,14,0,0" />

<TextBlock Opacity="1" x:Name="LocalFiles" Foreground="White" Text="Terug" Margin="70,14,0,0" FontSize="32" FontFamily="/Assets/Latin/Default.otf#SF Pro Display" HorizontalAlignment="Left" VerticalAlignment="Top" />
<TextBlock Opacity="1" x:Name="LocalFiles" Foreground="White" Text="Muziek Selectie" Margin="70,14,0,0" FontSize="32" FontFamily="/Assets/Latin/Default.otf#SF Pro Display" HorizontalAlignment="Left" VerticalAlignment="Top" />
<Button Click="Button_Click" Opacity="0" x:Name="LocalButton" Width="85" Height="40" Margin="78,14,0,0" HorizontalAlignment="Left" VerticalAlignment="Top"/>

<StackPanel Orientation="Horizontal" Margin="0,35,0,0" HorizontalAlignment="Center">
Expand All @@ -17,22 +17,32 @@
<ImageBrush Source="/Assets/Placeholders/Cover2.jpg"/>
</Border.Background>
</Border>
<StackPanel VerticalAlignment="Center" Margin="0,-90,0,0">
<StackPanel VerticalAlignment="Center" Margin="0,0,0,0">
<TextBlock x:Name="MusicTitle" Opacity="1" Foreground="White" Text="Belle de Nuit" Margin="30,0,0,0" FontSize="28" FontFamily="/Assets/Latin/Default.otf#SF Pro Display" HorizontalAlignment="Left" VerticalAlignment="Top" />
<TextBlock x:Name="MusicArtist" Opacity="1" Foreground="White" Text="黒皇帝 feat. AKA" Margin="30,0,0,0" FontSize="18" FontFamily="/Assets/Latin/Default.otf#SF Pro Display" HorizontalAlignment="Left" VerticalAlignment="Top" />
<Border Width="300" Margin="30,10,0,0" Background="White" CornerRadius="12">
<Grid>
<Slider IsEnabled="False" VerticalAlignment="Top" ValueChanged="Slider_ValueChanged" PointerPressed="Slider_PointerPressed" PointerReleased="Slider_PointerReleased" Maximum="9" Margin="10,0,10,0" x:Name="Slider" />
<Slider IsEnabled="False" VerticalAlignment="Top" Maximum="9" Margin="10,0,10,0" x:Name="Slider" />
<TextBlock Opacity="1" x:Name="TimerElapsed" Foreground="Black" Text="0:00" Margin="10,40,0,0" FontSize="16" FontFamily="/Assets/Latin/Default.otf#SF Pro Display" HorizontalAlignment="Left" VerticalAlignment="Top" />
<TextBlock Opacity="1" x:Name="TimerEnd" Foreground="Black" Text="0:02" Margin="0,40,10,0" FontSize="16" FontFamily="/Assets/Latin/Default.otf#SF Pro Display" HorizontalAlignment="Right" VerticalAlignment="Top" />
</Grid>
</Border>

<Grid Margin="0,50,0,0">
<Grid Margin="0,25,0,0">
<Image Tapped="PauseBTN" Source="/Assets/Icons/Light/Pause.png" Height="60" Width="60" VerticalAlignment="Center" x:Name="Pause" />
<Image Margin="-130,-50,0,0" Tapped="BackSong" Source="/Assets/Icons/Light/Scrub.png" Height="60" Width="60" VerticalAlignment="Center" x:Name="BackABit" />
<Image Margin="130,-50,0,0" Tapped="ForwardSong" Source="/Assets/Icons/Light/ScrubForward.png" Height="60" Width="60" VerticalAlignment="Center" x:Name="ForwardABit" />
<Image Margin="-130,-50,0,0" Tapped="ScrubBack" Source="/Assets/Icons/Light/Scrub.png" Height="50" Width="50" VerticalAlignment="Center" x:Name="BackABit" />
<Image Margin="130,-50,0,0" Tapped="ScrubForward" Source="/Assets/Icons/Light/ScrubForward.png" Height="50" Width="50" VerticalAlignment="Center" x:Name="ForwardABit" />

<Image Margin="-130,50,0,0" Tapped="BackSong" Source="/Assets/Icons/Light/NextSong.png" Height="50" Width="50" VerticalAlignment="Center" x:Name="NextSong">
<Image.RenderTransform>
<RotateTransform Angle="180" />
</Image.RenderTransform>
</Image>
<Image Margin="130,50,0,0" Tapped="ForwardSong" Source="/Assets/Icons/Light/NextSong.png" Height="50" Width="50" VerticalAlignment="Center" x:Name="PreviousSong" />

</Grid>

<Slider x:Name="VolumeSlider" ValueChanged="VolChanged" Maximum="100" IsEnabled="True" VerticalAlignment="Top" Margin="30,5,10,0" />
</StackPanel>
</StackPanel>
</Grid>
Expand Down
140 changes: 92 additions & 48 deletions SoundOS6/Views/Music/TVMode.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
using System.Threading;
using System;
using LibVLCSharp.Shared;
using System.IO;
using Avalonia.Threading;

namespace SoundOS6.Views.Music
{
public partial class TVMode : UserControl
{
public static TVMode Instance;
public bool NotDragged = true;
private bool isUserInteracting;

public TVMode()
{
Expand All @@ -22,11 +22,12 @@ public TVMode()
Instance = this;
TimerEnd.Text = MusicHandler.EndTimes;
Slider.Maximum = MusicHandler.EndTimesInSeconds;
if(MusicHandler.IsPlayingRadio)
if (MusicHandler.IsPlayingRadio)
{
BackABit.Opacity = 0;
ForwardABit.Opacity = 0;
}
VolumeSlider.Value = MusicHandler._stream.Volume;
}

public void SetBar(Avalonia.Media.Imaging.Bitmap Cover)
Expand Down Expand Up @@ -54,89 +55,132 @@ private void Button_Click(object? sender, Avalonia.Interactivity.RoutedEventArgs
MusicHome.Instance.StatusShow.Content = null;
}

private void Slider_PointerPressed(object sender, VectorEventArgs e)
private void PauseBTN(object? sender, Avalonia.Input.TappedEventArgs e)
{
NotDragged = false;
TimerElapsed.Opacity = 0.5;
if (MusicHandler.IsPlaying == false)
{
MusicHandler.ResumeMusic();

using (var stream = AssetLoader.Open(new Uri("avares://SoundOS6/Assets/Icons/Light/Pause.png")))
{
Pause.Source = new Avalonia.Media.Imaging.Bitmap(stream);
}

return;
}
else
{
MusicHandler.PauseMusic();
using (var stream = AssetLoader.Open(new Uri("avares://SoundOS6/Assets/Icons/Light/Play.png")))
{
Pause.Source = new Avalonia.Media.Imaging.Bitmap(stream);
}

return;
}
}

private void Slider_PointerReleased(object sender, VectorEventArgs e)
private void ScrubBack(object? sender, Avalonia.Input.TappedEventArgs e)
{
NotDragged = true;
MusicHandler._stream.Time -= 15000;
}

private CancellationTokenSource cts = new CancellationTokenSource();

private void ScrubForward(object? sender, Avalonia.Input.TappedEventArgs e)
{
MusicHandler._stream.Time += 15000;
}

private async void Slider_ValueChanged(object? sender, Avalonia.Controls.Primitives.RangeBaseValueChangedEventArgs e)
private async void BackSong(object? sender, Avalonia.Input.TappedEventArgs e)
{
if (isUserInteracting)
await Dispatcher.UIThread.InvokeAsync(() =>
{
NotDragged = false;
TimerElapsed.Opacity = 0.5;

cts.Cancel();
cts = new CancellationTokenSource();
MusicHandler._stream.Stop();
int index = MusicSplash.Instance.filePaths.IndexOf(MusicHandler.CurrentSongPath);

try
{
await Task.Delay(500, cts.Token);
MusicHandler.StartMusic(MusicSplash.Instance.filePaths[index - 1], false);
index = index - 1;

NotDragged = true;
TimerElapsed.Opacity = 1;
TagLib.File tagFile = TagLib.File.Create(MusicSplash.Instance.filePaths[index + 1]);
}
catch (TaskCanceledException)
catch (ArgumentOutOfRangeException)
{
// The delay was cancelled, so we don't do anything
int KeyAmount = MusicSplash.Instance.filePaths.Count;
MusicHandler.StartMusic(MusicSplash.Instance.filePaths[KeyAmount - 1], false);
index = KeyAmount - 1;

TagLib.File tagFile = TagLib.File.Create(MusicSplash.Instance.filePaths[0]);
}
}

}
MusicHome.Instance.PausePic.Opacity = 1;
MainView.Instance.PlayCommandBtn.IsEnabled = true;

private void Slider_PointerPressed(object? sender, Avalonia.Input.PointerPressedEventArgs e)
{
isUserInteracting = true;
}

private void Slider_PointerReleased(object? sender, Avalonia.Input.PointerReleasedEventArgs e)
{
isUserInteracting = false;

MainView.Instance.UnhideMusicWidget();

using (var stream = AssetLoader.Open(new Uri("avares://SoundOS6/Assets/Icons/Light/Pause.png")))
{
MusicHome.Instance.PausePic.Source = new Avalonia.Media.Imaging.Bitmap(stream);
}

MusicHandler._TimeElapsed = new DispatcherTimer();
MusicHandler._TimeElapsed.Interval = TimeSpan.FromMilliseconds(500);
MusicHandler._TimeElapsed.Tick += MusicLocal.ElapsedProcess;
MusicHandler._TimeElapsed.Start();
});
}

private void PauseBTN(object? sender, Avalonia.Input.TappedEventArgs e)
private async void ForwardSong(object? sender, Avalonia.Input.TappedEventArgs e)
{
if (MusicHandler.IsPlaying == false)
MusicHandler._stream.Stop();
int index = MusicSplash.Instance.filePaths.IndexOf(MusicHandler.CurrentSongPath);
if (index != -1 && index + 1 < MusicSplash.Instance.filePaths.Count)
{
MusicHandler.ResumeMusic();
MusicHandler.StartMusic(MusicSplash.Instance.filePaths[index + 1], false);

TagLib.File tagFile = TagLib.File.Create(MusicSplash.Instance.filePaths[index + 1]);

MusicHome.Instance.PausePic.Opacity = 1;
MainView.Instance.PlayCommandBtn.IsEnabled = true;

MainView.Instance.UnhideMusicWidget();

using (var stream = AssetLoader.Open(new Uri("avares://SoundOS6/Assets/Icons/Light/Pause.png")))
{
Pause.Source = new Avalonia.Media.Imaging.Bitmap(stream);
MusicHome.Instance.PausePic.Source = new Avalonia.Media.Imaging.Bitmap(stream);
}

return;
}
else
{
MusicHandler.PauseMusic();
using (var stream = AssetLoader.Open(new Uri("avares://SoundOS6/Assets/Icons/Light/Play.png")))
MusicHandler.StartMusic(MusicSplash.Instance.filePaths[0], false);

TagLib.File tagFile = TagLib.File.Create(MusicSplash.Instance.filePaths[0]);

MusicHome.Instance.PausePic.Opacity = 1;
MainView.Instance.PlayCommandBtn.IsEnabled = true;

MainView.Instance.UnhideMusicWidget();

using (var stream = AssetLoader.Open(new Uri("avares://SoundOS6/Assets/Icons/Light/Pause.png")))
{
Pause.Source = new Avalonia.Media.Imaging.Bitmap(stream);
MusicHome.Instance.PausePic.Source = new Avalonia.Media.Imaging.Bitmap(stream);
}

return;
}
}

private void BackSong(object? sender, Avalonia.Input.TappedEventArgs e)
{
MusicHandler._stream.Time -= 15000;
await Dispatcher.UIThread.InvokeAsync(() =>
{
MusicHandler._TimeElapsed = new DispatcherTimer();
MusicHandler._TimeElapsed.Interval = TimeSpan.FromMilliseconds(500);
MusicHandler._TimeElapsed.Tick += MusicLocal.ElapsedProcess;
MusicHandler._TimeElapsed.Start();
});
}

private void ForwardSong(object? sender, Avalonia.Input.TappedEventArgs e)
private void VolChanged(object? sender, Avalonia.Controls.Primitives.RangeBaseValueChangedEventArgs e)
{
MusicHandler._stream.Time += 15000;
MusicHandler._stream.Volume = Convert.ToInt32(VolumeSlider.Value);
}
}
}
Loading

0 comments on commit a7a1f83

Please sign in to comment.