Skip to content

Commit 1ddccec

Browse files
committed
1.0.1.4 - Fixed internet crash when you constantly spam on playlist.
1 parent 1cfb0ad commit 1ddccec

6 files changed

+35
-18
lines changed

AutoUpdateX64.xml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<item>
2-
<version>1.0.1.3</version>
3-
<changelog>https://github.com/J0nathan550/Free-Spotify/releases/tag/1.0.1.3</changelog>
4-
<url>https://github.com/J0nathan550/Free-Spotify/releases/download/1.0.1.3/FreeSpotifyX64.zip</url>
2+
<version>1.0.1.4</version>
3+
<changelog>https://github.com/J0nathan550/Free-Spotify/releases/tag/1.0.1.4</changelog>
4+
<url>https://github.com/J0nathan550/Free-Spotify/releases/download/1.0.1.4/FreeSpotifyX64.zip</url>
55
</item>

AutoUpdateX86.xml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<item>
2-
<version>1.0.1.3</version>
3-
<changelog>https://github.com/J0nathan550/Free-Spotify/releases/tag/1.0.1.3</changelog>
4-
<url>https://github.com/J0nathan550/Free-Spotify/releases/download/1.0.1.3/FreeSpotifyX86.zip</url>
2+
<version>1.0.1.4</version>
3+
<changelog>https://github.com/J0nathan550/Free-Spotify/releases/tag/1.0.1.4</changelog>
4+
<url>https://github.com/J0nathan550/Free-Spotify/releases/download/1.0.1.4/FreeSpotifyX86.zip</url>
55
</item>

Free Spotify/Classes/Utils.cs

+16-8
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,26 @@ public static class Utils
2121
public static string DefaultImagePath { get; set; } = $@"{System.AppDomain.CurrentDomain.BaseDirectory}\Assets\default-playlist-icon.png";
2222
public static async Task<BitmapImage> LoadImageAsync(string imageUrl)
2323
{
24-
using HttpClient client = new();
25-
byte[] imageData = await client.GetByteArrayAsync(imageUrl);
2624
BitmapImage image = new();
25+
try
26+
{
27+
using HttpClient client = new();
28+
byte[] imageData = await client.GetByteArrayAsync(imageUrl);
2729

28-
using (MemoryStream stream = new(imageData))
30+
using (MemoryStream stream = new(imageData))
31+
{
32+
image.BeginInit();
33+
image.CacheOption = BitmapCacheOption.OnLoad;
34+
image.StreamSource = stream;
35+
image.EndInit();
36+
}
37+
return image;
38+
}
39+
catch
2940
{
30-
image.BeginInit();
31-
image.CacheOption = BitmapCacheOption.OnLoad;
32-
image.StreamSource = stream;
33-
image.EndInit();
41+
image.UriSource = new System.Uri(Utils.DefaultImagePath);
42+
return image;
3443
}
35-
return image;
3644
}
3745
}
3846
}

Free Spotify/Free Spotify.csproj

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
<Nullable>enable</Nullable>
88
<UseWPF>true</UseWPF>
99
<Company>J0nathan550</Company>
10-
<Version>1.0.1.3</Version>
11-
<AssemblyVersion>1.0.1.3</AssemblyVersion>
12-
<FileVersion>1.0.1.3</FileVersion>
10+
<Version>1.0.1.4</Version>
11+
<AssemblyVersion>1.0.1.4</AssemblyVersion>
12+
<FileVersion>1.0.1.4</FileVersion>
1313
<SignAssembly>False</SignAssembly>
1414
<Copyright>J0nathan550</Copyright>
1515
<NeutralLanguage>uk-UA</NeutralLanguage>

Free Spotify/Pages/PlayListBriefView.xaml.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ public async void CreateTracksInPlaylist()
4242
{
4343
// Update the playlist view, title, and amount of tracks.
4444
// Display track details and context menus for each track in the current playlist.
45-
4645
PlayListView.Instance?.CreatePlaylists();
4746
playListTitle.Text = Settings.SettingsData.playlists[playListCurrentIndex].Title;
4847
playListAmountTracks.Text = $"{Settings.GetLocalizationString("AmountTracksDefaultText")} {Settings.SettingsData.playlists[playListCurrentIndex].TracksInPlaylist.Count} | {Settings.SettingsData.playlists[playListCurrentIndex].CalculateAmountOfTimeToListenWholePlayList()}";
@@ -137,6 +136,7 @@ public async void CreateTracksInPlaylist()
137136
gridToBeAdded.MouseLeftButtonDown += (sender, e) =>
138137
{
139138
currentSongIndex = int.Parse(gridToBeAdded.Name[1..]);
139+
SearchViewPage.SearchWindow?.ClearListsWhenPlayingInPlaylist();
140140
if (Settings.SettingsData.playlists[playListCurrentIndex].TracksInPlaylist[currentSongIndex].YouTubeTrack != null)
141141
{
142142
MusicPlayerPage.Instance?.PlaySound(Settings.SettingsData.playlists[playListCurrentIndex].TracksInPlaylist[currentSongIndex].YouTubeTrack?.GetVideoSearchResult(), Settings.SettingsData.playlists[playListCurrentIndex].TracksInPlaylist[currentSongIndex].YouTubeTrack, this);
@@ -451,6 +451,7 @@ private void PlayButtonBorder_MouseDown(object sender, MouseButtonEventArgs e)
451451
{
452452
_ = Dispatcher.BeginInvoke(() =>
453453
{
454+
SearchViewPage.SearchWindow?.ClearListsWhenPlayingInPlaylist();
454455
// If a music player instance exists and the playlist is not empty, play the first track.
455456
if (MusicPlayerPage.Instance == null)
456457
{

Free Spotify/Pages/SearchViewPage.xaml.cs

+8
Original file line numberDiff line numberDiff line change
@@ -791,5 +791,13 @@ public void ShuffleSongs()
791791
MusicPlayerPage.Instance?.StopSound();
792792
}
793793
}
794+
795+
public void ClearListsWhenPlayingInPlaylist()
796+
{
797+
newSongsSpotify.Clear();
798+
newSongsYouTube.Clear();
799+
trackSpotifyList.Clear();
800+
trackYouTubeList.Clear();
801+
}
794802
}
795803
}

0 commit comments

Comments
 (0)