Skip to content

Commit 8bc0115

Browse files
authored
Merge pull request #86 from aboe026/version-1.2
Version 1.2 Resolves #82
2 parents db36670 + d45826f commit 8bc0115

50 files changed

Lines changed: 2925 additions & 1994 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎Boxify/App.xaml.cs‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ You should have received a copy of the GNU General Public License
2525
using Windows.Foundation.Metadata;
2626
using Windows.Storage;
2727
using Windows.System;
28+
using Windows.UI;
2829
using Windows.UI.ViewManagement;
2930
using Windows.UI.Xaml;
3031
using Windows.UI.Xaml.Controls;
@@ -154,11 +155,11 @@ private void LoadSettings()
154155
// playback source
155156
if (composite["PlaybackSource"] != null && composite["PlaybackSource"].ToString() == "YouTube")
156157
{
157-
Settings.playbackSource = Settings.Playbacksource.YouTube;
158+
Settings.playbackSource = Settings.PlaybackSource.YouTube;
158159
}
159160
else
160161
{
161-
Settings.playbackSource = Settings.Playbacksource.Spotify;
162+
Settings.playbackSource = Settings.PlaybackSource.Spotify;
162163
}
163164

164165
// repeat
@@ -199,7 +200,7 @@ private void LoadSettings()
199200
// Defaults
200201
Settings.tvSafeArea = true;
201202
Settings.theme = Settings.Theme.System;
202-
Settings.playbackSource = Settings.Playbacksource.Spotify;
203+
Settings.playbackSource = Settings.PlaybackSource.Spotify;
203204
Settings.repeatEnabled = false;
204205
Settings.shuffleEnabled = false;
205206
Settings.volume = 100;
@@ -230,6 +231,10 @@ private void LoadSettings()
230231
{
231232
MainPage.announcementItems.Add(new Shuffle(Settings.shuffleEnabled));
232233
}
234+
if (VersionGreaterThan(previousVersion, "1.2.0.0"))
235+
{
236+
MainPage.announcementItems.Add(new NewReleases());
237+
}
233238
}
234239
}
235240
roamingSettings.Values["Announcements"] = Settings.version.ToString();

‎Boxify/Boxify.csproj‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,15 @@
118118
</Compile>
119119
<Compile Include="Classes\Artist.cs" />
120120
<Compile Include="Classes\PlaybackSession.cs" />
121+
<Compile Include="Controls\AlbumHero.xaml.cs">
122+
<DependentUpon>AlbumHero.xaml</DependentUpon>
123+
</Compile>
121124
<Compile Include="Controls\AlbumList.xaml.cs">
122125
<DependentUpon>AlbumList.xaml</DependentUpon>
123126
</Compile>
127+
<Compile Include="Controls\Announcements\NewReleases.xaml.cs">
128+
<DependentUpon>NewReleases.xaml</DependentUpon>
129+
</Compile>
124130
<Compile Include="Controls\Announcements\PlaybackMode.xaml.cs">
125131
<DependentUpon>PlaybackMode.xaml</DependentUpon>
126132
</Compile>
@@ -239,10 +245,18 @@
239245
<Generator>MSBuild:Compile</Generator>
240246
<SubType>Designer</SubType>
241247
</ApplicationDefinition>
248+
<Page Include="Controls\AlbumHero.xaml">
249+
<SubType>Designer</SubType>
250+
<Generator>MSBuild:Compile</Generator>
251+
</Page>
242252
<Page Include="Controls\AlbumList.xaml">
243253
<SubType>Designer</SubType>
244254
<Generator>MSBuild:Compile</Generator>
245255
</Page>
256+
<Page Include="Controls\Announcements\NewReleases.xaml">
257+
<SubType>Designer</SubType>
258+
<Generator>MSBuild:Compile</Generator>
259+
</Page>
246260
<Page Include="Controls\Announcements\PlaybackMode.xaml">
247261
<SubType>Designer</SubType>
248262
<Generator>MSBuild:Compile</Generator>

‎Boxify/Classes/Album.cs‎

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,12 @@ public class Album : IDisposable
3535
private bool disposed = false;
3636
public string id = "";
3737
public string name = "";
38+
public string releaseDate = "";
3839
public int tracksCount = 1;
3940
public List<Artist> artists = new List<Artist>();
4041
public BitmapImage image = new BitmapImage();
4142
public string imageUrl = "";
43+
public string href = "";
4244
private const string TRACKS_HREF = "https://api.spotify.com/v1/albums/{0}/tracks";
4345

4446
/// <summary>
@@ -78,15 +80,37 @@ public async Task SetInfo(string albumString)
7880
{
7981
return;
8082
}
81-
if (albumJson.TryGetValue("id", out IJsonValue idJson))
83+
if (albumJson.TryGetValue("id", out IJsonValue idJson) && idJson.ValueType == JsonValueType.String)
8284
{
8385
id = idJson.GetString();
8486
}
85-
if (albumJson.TryGetValue("name", out IJsonValue nameJson))
87+
if (albumJson.TryGetValue("name", out IJsonValue nameJson) && nameJson.ValueType == JsonValueType.String)
8688
{
8789
name = nameJson.GetString();
8890
}
89-
if (albumJson.TryGetValue("artists", out IJsonValue artistsJson)) {
91+
if (albumJson.TryGetValue("href", out IJsonValue hrefJson) && hrefJson.ValueType == JsonValueType.String)
92+
{
93+
href = hrefJson.GetString();
94+
95+
// extra request to get release date
96+
UriBuilder fullUriBuilder = new UriBuilder(href);
97+
string fullString = await RequestHandler.SendCliGetRequest(fullUriBuilder.Uri.ToString());
98+
JsonObject fullJson = new JsonObject();
99+
try
100+
{
101+
fullJson = JsonObject.Parse(fullString);
102+
}
103+
catch (COMException)
104+
{
105+
return;
106+
}
107+
108+
if (fullJson.TryGetValue("release_date", out IJsonValue releaseJson) && releaseJson.ValueType == JsonValueType.String)
109+
{
110+
releaseDate = releaseJson.GetString();
111+
}
112+
}
113+
if (albumJson.TryGetValue("artists", out IJsonValue artistsJson) && artistsJson.ValueType == JsonValueType.Array) {
90114
JsonArray artistsArray = artistsJson.GetArray();
91115
foreach (JsonValue artistObject in artistsArray)
92116
{
@@ -95,7 +119,7 @@ public async Task SetInfo(string albumString)
95119
artists.Add(artist);
96120
}
97121
}
98-
if (albumJson.TryGetValue("images", out IJsonValue imagesJson)) {
122+
if (albumJson.TryGetValue("images", out IJsonValue imagesJson) && imagesJson.ValueType == JsonValueType.Array) {
99123
JsonArray imagesArray = imagesJson.GetArray();
100124
if (imagesArray.Count > 0)
101125
{
@@ -126,7 +150,7 @@ public async Task SetInfo(string albumString)
126150
return;
127151
}
128152

129-
if (tracksJson.TryGetValue("total", out IJsonValue totalJson))
153+
if (tracksJson.TryGetValue("total", out IJsonValue totalJson) && totalJson.ValueType == JsonValueType.Number)
130154
{
131155
tracksCount = Convert.ToInt32(totalJson.GetNumber());
132156
}
@@ -149,7 +173,7 @@ public async Task<List<Track>> GetTracks()
149173
{
150174
return tracks;
151175
}
152-
if (tracksJson.TryGetValue("items", out IJsonValue itemsJson))
176+
if (tracksJson.TryGetValue("items", out IJsonValue itemsJson) && itemsJson.ValueType == JsonValueType.Array)
153177
{
154178
JsonArray itemsArray = itemsJson.GetArray();
155179
foreach (JsonValue trackJson in itemsArray)
@@ -186,20 +210,15 @@ protected virtual void Dispose(bool disposing)
186210
disposed = true;
187211
if (disposing)
188212
{
189-
id = null;
190-
name = null;
191213
while (artists.Count > 0)
192214
{
193215
Artist artist = artists.ElementAt(0);
194216
artists.Remove(artist);
195217
artist.Dispose();
196-
artist = null;
197218
}
198219
artists.Clear();
199-
artists = null;
200-
image.UriSource = null;
201-
image = null;
202-
imageUrl = null;
220+
221+
image.ClearValue(BitmapImage.UriSourceProperty);
203222
}
204223
}
205224
}

‎Boxify/Classes/Artist.cs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public void SetInfo(string artistString)
4545
{
4646
return;
4747
}
48-
if (trackJson.TryGetValue("name", out IJsonValue nameJson))
48+
if (trackJson.TryGetValue("name", out IJsonValue nameJson) && nameJson.ValueType == JsonValueType.String)
4949
{
5050
name = nameJson.GetString();
5151
}
@@ -65,7 +65,7 @@ protected virtual void Dispose(bool disposing)
6565
disposed = true;
6666
if (disposing)
6767
{
68-
name = null;
68+
6969
}
7070
}
7171
}

‎Boxify/Classes/PlaybackService.cs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public PlaybackService()
5151
queue.CurrentItemChanged += CurrentItemChanged;
5252
queue.ItemFailed += ItemFailed;
5353
Player.PlaybackSession.PlaybackStateChanged += PlayStateChanges;
54+
Player.AudioCategory = MediaPlayerAudioCategory.Media;
5455
}
5556

5657
/// <summary>
@@ -77,6 +78,7 @@ public async void StartNewSession(PlaybackType type, string href, int totalTrack
7778
currentSession = new PlaybackSession(currentLock, Settings.playbackSource, type, Settings.shuffleEnabled, href, totalTracks);
7879
queue.Items.Clear();
7980
Player.Source = queue;
81+
queue.AutoRepeatEnabled = Settings.repeatEnabled;
8082
await currentSession.LoadTracks(0, PlaybackSession.INITIAL_TRACKS_REQUEST);
8183
App.mainPage.SetPlaybackMenu(false);
8284
}
@@ -118,7 +120,6 @@ public void RemoveFromQueue(string mediaId, long localLock)
118120
{
119121
MediaPlaybackItem item = queue.Items.First(kvp => kvp.Source.CustomProperties["mediaItemId"].ToString() == mediaId);
120122
queue.Items.Remove(item);
121-
item = null;
122123
}
123124
}
124125

0 commit comments

Comments
 (0)