Commit 446824e9 authored by Axelander's avatar Axelander

Issue 41 playlist crash

parent ba2fb841
This diff is collapsed.
......@@ -17,4 +17,12 @@ C# library which implements the MusicBrainz API.
- Author: [avatar29A](https://github.com/avatar29A)
- Source: [GitHub](https://github.com/avatar29A)
- License: [The MIT License (MIT)](https://github.com/avatar29A/MusicBrainz/blob/master/LICENSE.txt)
\ No newline at end of file
- License: [The MIT License (MIT)](https://github.com/avatar29A/MusicBrainz/blob/master/LICENSE.txt)
### Json.NET Schema
Json.NET Schema is a powerful, complete and easy to use JSON Schema framework for .NET
- Author: [Newtonsoft](http://www.newtonsoft.com/)
- Source: [GitHub](https://github.com/JamesNK/Newtonsoft.Json.Schema)
- License: [GNU Affero General Public License Version 3](http://www.gnu.org/licenses/agpl-3.0.html)
\ No newline at end of file
......@@ -28,14 +28,14 @@ namespace SonicStreamer.Test.Common
public async Task AddToPlaybackTestAsync()
{
var tracks = await GetSampleTracks();
await PlaybackService.Current.AddToPlaybackAsync(tracks);
PlaybackService.Current.AddToPlaybackAsync(tracks);
Assert.AreEqual(tracks.Count, PlaybackService.Current.Playback.Items.Count);
// Duplicate Check
await PlaybackService.Current.AddToPlaybackAsync(tracks, false);
PlaybackService.Current.AddToPlaybackAsync(tracks, false);
Assert.AreEqual(tracks.Count, PlaybackService.Current.Playback.Items.Count);
// Replace Playback
tracks.RemoveAt(0);
await PlaybackService.Current.AddToPlaybackAsync(tracks);
PlaybackService.Current.AddToPlaybackAsync(tracks);
Assert.AreEqual(tracks.Count, PlaybackService.Current.Playback.Items.Count);
PlaybackService.Current.ResetPlayabck();
}
......@@ -56,7 +56,7 @@ namespace SonicStreamer.Test.Common
{
var tracks = await GetSampleTracks();
PlaybackService.Current.SetShuffleMode(false);
await PlaybackService.Current.AddToPlaybackAsync(tracks);
PlaybackService.Current.AddToPlaybackAsync(tracks);
var playbackItem = PlaybackService.Current.Playback.Items.First();
var displayProperties = playbackItem.GetDisplayProperties();
Assert.AreEqual(tracks.First().Id,
......@@ -86,7 +86,7 @@ namespace SonicStreamer.Test.Common
var newOrder = GetTrackIdOrder();
Assert.AreNotEqual(oldOrder, newOrder);
await PlaybackService.Current.AddToPlaybackAsync(tracks);
PlaybackService.Current.AddToPlaybackAsync(tracks);
Assert.AreNotEqual(newOrder, GetTrackIdOrder());
PlaybackService.Current.ResetPlayabck();
}
......@@ -97,7 +97,7 @@ namespace SonicStreamer.Test.Common
var tracks = await GetSampleTracks();
// Add only one track to trigger Play mode
await PlaybackService.Current.AddToPlaybackAsync(tracks.First());
PlaybackService.Current.AddToPlaybackAsync(tracks.First());
await Task.Delay(2000);
Assert.AreEqual(MediaPlaybackState.Playing, PlaybackService.Current.Player.PlaybackSession.PlaybackState);
......@@ -107,7 +107,7 @@ namespace SonicStreamer.Test.Common
Assert.AreEqual(MediaPlaybackState.Paused, PlaybackService.Current.Player.PlaybackSession.PlaybackState);
// Add now all tracks to test correct Play/Pause behaviour
await PlaybackService.Current.AddToPlaybackAsync(tracks, false);
PlaybackService.Current.AddToPlaybackAsync(tracks, false);
await Task.Delay(2000);
Assert.AreEqual(MediaPlaybackState.Paused, PlaybackService.Current.Player.PlaybackSession.PlaybackState);
......@@ -122,7 +122,7 @@ namespace SonicStreamer.Test.Common
Assert.AreNotEqual(MediaPlaybackState.Playing, PlaybackService.Current.Player.PlaybackSession.PlaybackState);
// Test Auto Play for empty playback
await PlaybackService.Current.AddToPlaybackAsync(tracks, false);
PlaybackService.Current.AddToPlaybackAsync(tracks, false);
await Task.Delay(2000);
Assert.AreEqual(MediaPlaybackState.Playing, PlaybackService.Current.Player.PlaybackSession.PlaybackState);
PlaybackService.Current.ResetPlayabck();
......@@ -133,7 +133,7 @@ namespace SonicStreamer.Test.Common
{
var tracks = await GetSampleTracks();
PlaybackService.Current.SetShuffleMode(false);
await PlaybackService.Current.AddToPlaybackAsync(tracks);
PlaybackService.Current.AddToPlaybackAsync(tracks);
await Task.Delay(2000);
// Test PlayNext
......@@ -163,13 +163,15 @@ namespace SonicStreamer.Test.Common
}
[TestMethod]
[Ignore]
public async Task JumpTestAsync()
{
// TODO Create new Sample Data
var tracks = await GetSampleTracks();
await PlaybackService.Current.AddToPlaybackAsync(tracks);
PlaybackService.Current.AddToPlaybackAsync(tracks);
var rnd = new Random();
var rndTrack = tracks.ElementAt(rnd.Next(tracks.Count - 1));
PlaybackService.Current.Jump(rndTrack);
//PlaybackService.Current.Jump(rndTrack);
// delay required to wait for updated CurrentItem
await Task.Delay(2000);
......
......@@ -40,7 +40,7 @@ namespace SonicStreamer.Test.ViewModels
var playbackVm = new PlaybackViewModel();
ResourceLoader.Current.SetNewTempResource(playbackVm, Constants.ViewModelPlayback);
tracks = await GetSampleTracks();
await PlaybackService.Current.AddToPlaybackAsync(tracks);
PlaybackService.Current.AddToPlaybackAsync(tracks);
await Task.Delay(2000);
return playbackVm;
}
......@@ -53,23 +53,22 @@ namespace SonicStreamer.Test.ViewModels
{
Assert.AreEqual(
PlaybackService.Current.Playback.CurrentItem.Source.CustomProperties[Constants.PlaybackTrackId].ToString
(), playbackVm.CurrentTrack.Id);
(), playbackVm.PlaybackCurrentTrack.Source.CustomProperties[Constants.PlaybackTrackId]);
Assert.AreEqual(
PlaybackService.Current.Playback.CurrentItem.Source.CustomProperties[Constants.PlaybackArtistId]
.ToString(), playbackVm.CurrentTrack.ArtistId);
.ToString(), playbackVm.PlaybackCurrentTrack.Source.CustomProperties[Constants.PlaybackArtistId]);
Assert.AreEqual(
((CoverArt)
PlaybackService.Current.Playback.CurrentItem.Source.CustomProperties[Constants.PlaybackCover]).Id,
playbackVm.CurrentTrack.Cover.Id);
PlaybackService.Current.Playback.CurrentItem.Source.CustomProperties[Constants.PlaybackCover],
playbackVm.PlaybackCurrentTrack.Source.CustomProperties[Constants.PlaybackCover]);
Assert.AreEqual(
PlaybackService.Current.Playback.CurrentItem.Source.CustomProperties[Constants.PlaybackDuration]
.ToString(), playbackVm.CurrentTrack.Duration);
.ToString(), playbackVm.PlaybackCurrentTrack.Source.CustomProperties[Constants.PlaybackDuration]);
var displayProperties = PlaybackService.Current.Playback.CurrentItem.GetDisplayProperties();
Assert.AreEqual(displayProperties.MusicProperties.Title, playbackVm.CurrentTrack.Name);
Assert.AreEqual(displayProperties.MusicProperties.Artist, playbackVm.CurrentTrack.Artist);
Assert.AreEqual(displayProperties.MusicProperties.AlbumTitle, playbackVm.CurrentTrack.Album);
Assert.AreEqual(PlaybackService.Current.Playback.Items.Count, playbackVm.Tracks.Count);
Assert.AreEqual(displayProperties.MusicProperties.Title, playbackVm.PlaybackCurrentTrack.Source.CustomProperties[Constants.PlaybackName]);
Assert.AreEqual(displayProperties.MusicProperties.Artist, playbackVm.PlaybackCurrentTrack.Source.CustomProperties[Constants.PlaybackArtist]);
Assert.AreEqual(displayProperties.MusicProperties.AlbumTitle, playbackVm.PlaybackCurrentTrack.Source.CustomProperties[Constants.PlaybackAlbum]);
Assert.AreEqual(PlaybackService.Current.Playback.Items.Count, playbackVm.PlaybackTracks.Count);
}
[TestMethod]
......@@ -78,10 +77,10 @@ namespace SonicStreamer.Test.ViewModels
using (var playbackVm = new PlaybackViewModel())
{
await playbackVm.LoadDataAsync();
Assert.AreEqual(0, playbackVm.Tracks.Count);
Assert.AreEqual(0, playbackVm.PlaybackTracks.Count);
Assert.AreEqual(Symbol.Play, playbackVm.PlayButtonIcon);
Assert.AreEqual(PlaybackViewModel.PlaybackPanelStatus.Large, playbackVm.PanelStaus);
Assert.IsNull(playbackVm.CurrentTrack);
Assert.IsNull(playbackVm.PlaybackCurrentTrack);
Assert.IsNull(playbackVm.CurrentArtistInfo);
Assert.IsFalse(playbackVm.IsPlaybackPanelVisible);
PlaybackService.Current.ResetPlayabck();
......@@ -117,8 +116,8 @@ namespace SonicStreamer.Test.ViewModels
AssertCurrentTrack(playbackVm);
// Add test with duplicates
await PlaybackService.Current.AddToPlaybackAsync(tracks, false);
Assert.AreEqual(PlaybackService.Current.Playback.Items.Count, playbackVm.Tracks.Count);
PlaybackService.Current.AddToPlaybackAsync(tracks, false);
Assert.AreEqual(PlaybackService.Current.Playback.Items.Count, playbackVm.PlaybackTracks.Count);
PlaybackService.Current.ResetPlayabck();
}
}
......@@ -145,7 +144,7 @@ namespace SonicStreamer.Test.ViewModels
{
using (var playbackVm = await InitNewPlayback(await GetSampleTracks()))
{
playbackVm.Jump(playbackVm.Tracks.Last());
playbackVm.Jump(playbackVm.PlaybackTracks.Last());
await Task.Delay(2000);
AssertCurrentTrack(playbackVm);
PlaybackService.Current.ResetPlayabck();
......@@ -158,7 +157,7 @@ namespace SonicStreamer.Test.ViewModels
using (var playbackVm = await InitNewPlayback(await GetSampleTracks()))
{
await playbackVm.LoadDataAsync();
Assert.AreEqual(playbackVm.CurrentTrack.Artist, playbackVm.CurrentArtistInfo.Name);
Assert.AreEqual(playbackVm.PlaybackCurrentTrack.Source.CustomProperties[Constants.PlaybackArtist], playbackVm.CurrentArtistInfo.Name);
Assert.AreNotEqual(playbackVm.CurrentArtistInfo.SocialLinks.Count, 0);
PlaybackService.Current.ResetPlayabck();
}
......
......@@ -132,6 +132,7 @@ namespace SonicStreamer
{
var deferral = e.SuspendingOperation.GetDeferral();
var saveTasks = new List<Task>();
var cacheTask = PlaybackService.Current.SaveCachedObjectsAsync();
foreach (var ressource in Current.Resources)
{
var viewModel = ressource.Value as IViewModelSerializable;
......@@ -141,6 +142,7 @@ namespace SonicStreamer
}
}
await Task.WhenAll(saveTasks);
await cacheTask;
deferral.Complete();
}
......
......@@ -20,6 +20,10 @@
public const string ContainerLogin = "LoginSettings";
public const string SettingServerType = "ServerType";
// LocalSettings
public const string CacheFileName = "cache.json";
public const string TrackCacheFolder = "tracks";
// MusicBrainz
public const string MusicBrainzArtistQueryParams =
......@@ -48,5 +52,6 @@
public const string PlaybackAlbumId = "albumId";
public const string PlaybackCover = "cover";
public const string PlaybackDuration = "duration";
public const string PlaybackDurationOutput = "durationOutput";
}
}
\ No newline at end of file
......@@ -32,17 +32,17 @@
</Grid.RowDefinitions>
<Grid Margin="0,0,0,5">
<Image Source="ms-appx:///Assets/cover.png" />
<Image Canvas.ZIndex="1" Source="{Binding CurrentTrack.Cover.Uri}" />
<Image Canvas.ZIndex="1" Source="{Binding PlaybackCurrentTrack.Source.CustomProperties[cover]}" />
</Grid>
<StackPanel Grid.Row="1">
<TextBlock
FontWeight="SemiBold"
Style="{StaticResource OrangeTitleTextBlockStyle}"
Text="{Binding CurrentTrack.Name}"
Text="{Binding PlaybackCurrentTrack.Source.CustomProperties[name]}"
TextAlignment="Center" />
<TextBlock
Style="{StaticResource OrangeSubtitleTextBlockStyle}"
Text="{Binding CurrentTrack.Artist}"
Text="{Binding PlaybackCurrentTrack.Source.CustomProperties[artist]}"
TextAlignment="Center" />
</StackPanel>
</Grid>
......
......@@ -171,11 +171,11 @@
</Grid.ColumnDefinitions>
<Grid Margin="5,0">
<Image Source="ms-appx:///Assets/cover.png" />
<Image Canvas.ZIndex="1" Source="{Binding CurrentTrack.Cover.Uri}" />
<Image Canvas.ZIndex="1" Source="{Binding PlaybackCurrentTrack.Source.CustomProperties[cover]}" />
</Grid>
<StackPanel Grid.Column="1">
<TextBlock Style="{StaticResource OrangeItemTitleTextBlockStyle}" Text="{Binding CurrentTrack.Name}" />
<TextBlock Style="{StaticResource OrangeItemSubtitleTextBlockStyle}" Text="{Binding CurrentTrack.Artist}" />
<TextBlock Style="{StaticResource OrangeItemTitleTextBlockStyle}" Text="{Binding PlaybackCurrentTrack.Source.CustomProperties[name]}" />
<TextBlock Style="{StaticResource OrangeItemSubtitleTextBlockStyle}" Text="{Binding PlaybackCurrentTrack.Source.CustomProperties[artist]}" />
</StackPanel>
</Grid>
<StackPanel Grid.Column="1" Orientation="Horizontal">
......@@ -203,11 +203,11 @@
</Grid.ColumnDefinitions>
<Grid Margin="5,0">
<Image Source="ms-appx:///Assets/cover.png" />
<Image Canvas.ZIndex="1" Source="{Binding CurrentTrack.Cover.Uri}" />
<Image Canvas.ZIndex="1" Source="{Binding PlaybackCurrentTrack.Source.CustomProperties[cover]}" />
</Grid>
<StackPanel Grid.Column="1">
<TextBlock Style="{StaticResource OrangeItemTitleTextBlockStyle}" Text="{Binding CurrentTrack.Name}" />
<TextBlock Style="{StaticResource OrangeItemSubtitleTextBlockStyle}" Text="{Binding CurrentTrack.Artist}" />
<TextBlock Style="{StaticResource OrangeItemTitleTextBlockStyle}" Text="{Binding PlaybackCurrentTrack.Source.CustomProperties[name]}" />
<TextBlock Style="{StaticResource OrangeItemSubtitleTextBlockStyle}" Text="{Binding PlaybackCurrentTrack.Source.CustomProperties[artist]}" />
</StackPanel>
</Grid>
<Grid
......@@ -342,11 +342,11 @@
</Grid.ColumnDefinitions>
<Grid Margin="5,0">
<Image Source="ms-appx:///Assets/cover.png" />
<Image Canvas.ZIndex="1" Source="{Binding CurrentTrack.Cover.Uri}" />
<Image Canvas.ZIndex="1" Source="{Binding PlaybackCurrentTrack.Source.CustomProperties[cover]}" />
</Grid>
<StackPanel Grid.Column="1">
<TextBlock Style="{StaticResource OrangeItemTitleTextBlockStyle}" Text="{Binding CurrentTrack.Name}" />
<TextBlock Style="{StaticResource OrangeItemSubtitleTextBlockStyle}" Text="{Binding CurrentTrack.Artist}" />
<TextBlock Style="{StaticResource OrangeItemTitleTextBlockStyle}" Text="{Binding PlaybackCurrentTrack.Source.CustomProperties[name]}" />
<TextBlock Style="{StaticResource OrangeItemSubtitleTextBlockStyle}" Text="{Binding PlaybackCurrentTrack.Source.CustomProperties[artist]}" />
</StackPanel>
</Grid>
<Grid
......
......@@ -50,8 +50,8 @@
MaxWidth="800"
IsItemClickEnabled="True"
ItemClick="{x:Bind PlaybackVm.PlaybackTracks_ItemClick}"
ItemsSource="{Binding Tracks}"
SelectedItem="{Binding CurrentTrack, Mode=TwoWay}"
ItemsSource="{Binding PlaybackTracks}"
SelectedItem="{Binding PlaybackCurrentTrack, Mode=TwoWay}"
SelectionChanged="PlaybackTracks_SelectionChanged">
<ListView.ItemTemplate>
<DataTemplate>
......@@ -62,15 +62,15 @@
<ColumnDefinition x:Name="ArtistColumn" Width="200" />
<ColumnDefinition Width="80" />
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding Name}" TextTrimming="CharacterEllipsis" />
<TextBlock Text="{Binding Source.CustomProperties[name]}" TextTrimming="CharacterEllipsis" />
<TextBlock
Grid.Column="1"
Text="{Binding Artist}"
Text="{Binding Source.CustomProperties[artist]}"
TextTrimming="CharacterEllipsis" />
<TextBlock
Grid.Column="2"
Margin="0,0,15,0"
Text="{Binding DurationOutput}"
Text="{Binding Source.CustomProperties[durationOutput]}"
TextAlignment="Right" />
<VisualStateManager.VisualStateGroups>
<VisualStateGroup>
......
......@@ -48,11 +48,5 @@ namespace SonicStreamer.Subsonic.Data
{
EpisodeStatus = DownloadStatus.Unkown;
}
public PodcastEpisode(MediaPlaybackItem playbackItem) : base(playbackItem)
{
Description = playbackItem.Source.CustomProperties["description"] as string;
EpisodeStatus = DownloadStatus.Completed;
}
}
}
\ No newline at end of file
......@@ -3,12 +3,8 @@ using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Xml.Serialization;
using Windows.ApplicationModel.Core;
using Windows.Media.Playback;
using Windows.Networking.BackgroundTransfer;
using Windows.Storage;
using Windows.UI.Core;
using SonicStreamer.Common.Extension;
namespace SonicStreamer.Subsonic.Data
{
......@@ -145,32 +141,16 @@ namespace SonicStreamer.Subsonic.Data
}
}
}
private IDispatcherWrapper _dispatcherWrapper;
public SubsonicPlayableObject()
{
Status = PlayableObjectStatus.Online;
}
public SubsonicPlayableObject(MediaPlaybackItem playbackItem) : this()
{
Id = playbackItem.Source.CustomProperties[Constants.PlaybackTrackId] as string;
ArtistId = playbackItem.Source.CustomProperties[Constants.PlaybackArtistId] as string;
Cover = playbackItem.Source.CustomProperties[Constants.PlaybackCover] as CoverArt;
Duration = playbackItem.Source.CustomProperties[Constants.PlaybackDuration] as string;
Name = playbackItem.GetDisplayProperties().MusicProperties.Title;
Artist = playbackItem.GetDisplayProperties().MusicProperties.Artist;
Album = playbackItem.GetDisplayProperties().MusicProperties.AlbumTitle;
}
/// <summary>
/// Baut die Uri zumsammen, um das <see cref="SubsonicPlayableObject"/> zu streamen
/// Creates and returns an <see cref="Uri"/> to stream the <see cref="SubsonicPlayableObject"/>.
/// If the <see cref="SubsonicPlayableObject"/> has no Id it returns null.
/// </summary>
/// <returns>
/// Uri Adresse zum Streamen des <see cref="SubsonicPlayableObject"/>.
/// Hat das <see cref="SubsonicPlayableObject"/> keine ID wird null zurückgegeben.
/// </returns>
public Uri GetStreamUri()
{
if (Id == null) return null;
......@@ -179,50 +159,47 @@ namespace SonicStreamer.Subsonic.Data
}
/// <summary>
/// Gibt die Uri des <see cref="SubsonicPlayableObject"/> zum Streamen oder für die lokale Wiedergabe zurück
/// Checks if the Id is listed in the Cache Pool and sets the <see cref="Status"/> property
/// </summary>
public async Task<Uri> GetSource()
public void SetStatus()
{
await CheckLocalFileAsync();
if (Status != PlayableObjectStatus.Offline) return GetStreamUri();
var result = GetLocalFilePath();
return result != null ? new Uri(result) : GetStreamUri();
if (!PlaybackService.Current.CachedPlayableObjects.TryGetValue(Id, out string path))
Status = PlayableObjectStatus.Online;
if (path == Path)
{
Status = PlayableObjectStatus.Offline;
}
else
{
// Inconsistent Data - Either File was moved Id has been changed on server
PlaybackService.Current.CachedPlayableObjects.Remove(Id);
Status = PlayableObjectStatus.Online;
}
// TODO Check if Files really exists in background
}
#region Cache Handling
/// <summary>
/// Prüft, ob das <see cref="SubsonicPlayableObject"/> im LocalFolder vorhanden ist.
/// Checks if the local file still really exists
/// </summary>
public void CheckLocalFile()
public async Task CheckStatusAsync()
{
try
{
_dispatcherWrapper = new DispatcherWrapper(CoreApplication.MainView.CoreWindow.Dispatcher);
}
catch (System.Exception)
{
_dispatcherWrapper = new FakeDispatcherWrapper();
}
var startResult =
_dispatcherWrapper.RunAsync(
async () =>
{
Status = await IsLocalFileAvailable()
? PlayableObjectStatus.Offline
: PlayableObjectStatus.Online;
});
if (Status == PlayableObjectStatus.Online) return;
if (await IsLocalFileAvailableAsync()) return;
PlaybackService.Current.CachedPlayableObjects.Remove(Id);
Status = PlayableObjectStatus.Online;
}
/// <summary>
/// Prüft, ob das <see cref="SubsonicPlayableObject"/> im LocalFolder vorhanden ist.
/// Gibt die Uri des <see cref="SubsonicPlayableObject"/> zum Streamen oder für die lokale Wiedergabe zurück
/// </summary>
public async Task CheckLocalFileAsync()
public Uri GetSource()
{
Status = await IsLocalFileAvailable() ? PlayableObjectStatus.Offline : PlayableObjectStatus.Online;
return Status == PlayableObjectStatus.Offline ? new Uri(GetLocalFilePath()) : GetStreamUri();
}
private async Task<bool> IsLocalFileAvailable()
#region Cache Handling
private async Task<bool> IsLocalFileAvailableAsync()
{
try
{
......@@ -274,13 +251,13 @@ namespace SonicStreamer.Subsonic.Data
{
if (download.RequestedUri != item.RequestedUri) continue;
await item.AttachAsync();
CheckLocalFile();
await CheckDownloadedFileAsync();
return;
}
// Starten und Prozess überwachen
await download.StartAsync();
CheckLocalFile();
await CheckDownloadedFileAsync();
}
catch (System.Exception)
{
......@@ -306,7 +283,7 @@ namespace SonicStreamer.Subsonic.Data
/// </summary>
private async Task<StorageFolder> GetDestinationFolderAsync()
{
var tracksFolder = await ApplicationData.Current.LocalFolder.CreateFolderAsync("tracks",
var tracksFolder = await ApplicationData.Current.LocalFolder.CreateFolderAsync(Constants.TrackCacheFolder,
CreationCollisionOption.OpenIfExists);
var subFolders = Path.Split('\\');
......@@ -318,6 +295,24 @@ namespace SonicStreamer.Subsonic.Data
return nextFolder;
}
/// <summary>
/// Checks if the Download was successfully and adds Id to central Cached Pool
/// </summary>
private async Task CheckDownloadedFileAsync()
{
if (!await IsLocalFileAvailableAsync()) return;
try
{
PlaybackService.Current.CachedPlayableObjects.Add(Id, Path);
}
catch (ArgumentException)
{
// Cached Id already exists, update Path in Cache Pool
PlaybackService.Current.CachedPlayableObjects[Id] = Path;
}
Status = PlayableObjectStatus.Offline;
}
#endregion
}
}
\ No newline at end of file
......@@ -15,14 +15,5 @@ namespace SonicStreamer.Subsonic.Data
}
#endregion
public Track() : base()
{
}
public Track(MediaPlaybackItem playbackItem) : base(playbackItem)
{
TrackNr = playbackItem.GetDisplayProperties().MusicProperties.TrackNumber.ToString();
}
}
}
\ No newline at end of file
......@@ -221,7 +221,7 @@ namespace SonicStreamer.ViewModelItems
/// </summary>
public async Task PlayAsync()
{
await PlaybackService.Current.AddToPlaybackAsync(await GetTracksAsync());
PlaybackService.Current.AddToPlaybackAsync(await GetTracksAsync());
}
/// <summary>
......@@ -229,7 +229,7 @@ namespace SonicStreamer.ViewModelItems
/// </summary>
public async Task AddAsync()
{
await PlaybackService.Current.AddToPlaybackAsync(await GetTracksAsync(), false);
PlaybackService.Current.AddToPlaybackAsync(await GetTracksAsync(), false);
}
/// <summary>
......
......@@ -54,7 +54,7 @@ namespace SonicStreamer.ViewModelItems
{
Episode = episode;
IsDescriptionVisible = isExpand;
Episode.CheckLocalFile();
Episode.SetStatus();
}
#region Setter Implementation
......@@ -92,21 +92,21 @@ namespace SonicStreamer.ViewModelItems
/// <summary>
/// Bindable Methode um die Episode abzuspielen. Die existierende Wiedergabe wird ersetzt
/// </summary>
public async void PlayEpisodeClick()
public void PlayEpisodeClick()
{
Microsoft.HockeyApp.HockeyClient.Current.TrackEvent(string.Format("{0} - {1}", GetType().Name,
"PlayEpisodeClick"));
await PlaybackService.Current.AddToPlaybackAsync(Episode, true);
PlaybackService.Current.AddToPlaybackAsync(Episode, true);
}
/// <summary>
/// Bindable Methode um eine Epsiode zur Wiedergabe hinzuzufügen.
/// </summary>
public async void AddEpisodeClick()
public void AddEpisodeClick()
{
Microsoft.HockeyApp.HockeyClient.Current.TrackEvent(string.Format("{0} - {1}", GetType().Name,
"AddEpisodeClick"));
await PlaybackService.Current.AddToPlaybackAsync(Episode, false);
PlaybackService.Current.AddToPlaybackAsync(Episode, false);
}
/// <summary>
......
......@@ -181,7 +181,7 @@ namespace SonicStreamer.ViewModels
/// </summary>
public async Task PlaySelectionAsync()
{
await PlaybackService.Current.AddToPlaybackAsync(await GetTracksAsync());
PlaybackService.Current.AddToPlaybackAsync(await GetTracksAsync());
}
/// <summary>
......@@ -189,7 +189,7 @@ namespace SonicStreamer.ViewModels
/// </summary>
public async Task AddSelectionAsync()
{
await PlaybackService.Current.AddToPlaybackAsync(await GetTracksAsync(), false);
PlaybackService.Current.AddToPlaybackAsync(await GetTracksAsync(), false);
}
/// <summary>
......
......@@ -79,7 +79,7 @@ namespace SonicStreamer.ViewModels
{
try
{
var trackFolder = await ApplicationData.Current.LocalFolder.GetFolderAsync("tracks");
var trackFolder = await ApplicationData.Current.LocalFolder.GetFolderAsync(Constants.TrackCacheFolder);
var folderSize = await GetFolderSizeAsync(trackFolder);
TrackCacheSize = (ConvertBytesToMegabytes(folderSize)).ToString("#.000");
}
......@@ -119,33 +119,11 @@ namespace SonicStreamer.ViewModels
IsScrobbleActivated = (boolValue != false);
}
#region Tapped Methods
public async void HomepageTextBlock_Tapped(object sender, TappedRoutedEventArgs e)
{
var webAddress = new Uri(Homepage);
await Windows.System.Launcher.LaunchUriAsync(webAddress);
}
public async void MailTextBlock_Tapped(object sender, TappedRoutedEventArgs e)
{
var webAddress = new Uri(Mail);
await Windows.System.Launcher.LaunchUriAsync(webAddress);
}
public async void PolicyTextBlock_Tapped(object sender, TappedRoutedEventArgs e)
{
var webAddress = new Uri(Policy);
await Windows.System.Launcher.LaunchUriAsync(webAddress);
}
#endregion
public async void ClearTrackCacheClick()
{
var messageDialog =
new MessageDialog("Warning: This action will stop the current playback and delete all local tracks. " +
"Do you stil want to continue?");
"Do you still want to continue?");
messageDialog.Commands.Add(new UICommand("Delete",
new UICommandInvokedHandler(DeleteTrackCacheCommandHandler)));
messageDialog.Commands.Add(new UICommand("Cancel"));
......@@ -161,7 +139,7 @@ namespace SonicStreamer.ViewModels
playbackVm.Clear();
try
{
var trackFolder = await ApplicationData.Current.LocalFolder.GetFolderAsync("tracks");
var trackFolder = await ApplicationData.Current.LocalFolder.GetFolderAsync(Constants.TrackCacheFolder);
await trackFolder.DeleteAsync();
TrackCacheSize = "0";
}
......@@ -169,6 +147,15 @@ namespace SonicStreamer.ViewModels
{
// ignored
}
try
{
var file = await ApplicationData.Current.LocalFolder.GetFileAsync(Constants.CacheFileName);
await file.DeleteAsync();
}
catch (Exception)
{
// ignored
}
}
}
}
\ No newline at end of file
......@@ -279,7 +279,7 @@ namespace SonicStreamer.ViewModels
Current = await SubsonicConnector.Current.CurrentConnection.GetFolderContentAsync(target.Id);
foreach (var track in Current.Tracks)
{
track.CheckLocalFile();
track.SetStatus();
}
GroupSubFolder();
}
......@@ -467,7 +467,7 @@ namespace SonicStreamer.ViewModels
/// </summary>
public async Task PlaySelectionAsync()
{
await PlaybackService.Current.AddToPlaybackAsync(await GetTracksAsync());
PlaybackService.Current.AddToPlaybackAsync(await GetTracksAsync());
}
/// <summary>
......@@ -475,7 +475,7 @@ namespace SonicStreamer.ViewModels
/// </summary>
public async Task AddSelectionAsync()
{
await PlaybackService.Current.AddToPlaybackAsync(await GetTracksAsync(), false);
PlaybackService.Current.AddToPlaybackAsync(await GetTracksAsync(), false);
}
/// &l