Exemplo n.º 1
0
        // returns the unresolved segment count
        protected virtual int ParseTracks()
        {
            Tracks.Clear();

            // make a copy of overpass Segments
            List <Segment> segments = new List <Segment>(overpass.Segments);
            List <Segment> starts   = new List <Segment>(GetStartSegments(overpass.Segments));

            foreach (Segment start in starts)
            {
                ConstructTrack(segments, start);
            }

            // at this point we should have only segments that tweak of from other tracks
            List <Segment> rest = new List <Segment>(GetStartSegments(segments));

            foreach (Segment start in rest)
            {
                ConstructTrack(segments, start);
            }

            // sort by name, without creating a new list
            Tracks.Sort((x, y) => x.Name.CompareTo(y.Name));

            PostProcess();

            // should be 0!
            return(segments.Count);
        }
Exemplo n.º 2
0
        private void LoadList()
        {
            Guid?selectedTrackId = SelectedTrack?.Track.Id;

            var tracks = tracksProvider.Tracks.Select(t => new TrackListItemVM()
            {
                Track     = t,
                Body      = t.Body.Names.First(),
                StartDate = JulianDayToString(t.From),
                EndDate   = JulianDayToString(t.To),
                Color     = t.Color
            });

            Tracks.Clear();
            foreach (var track in tracks)
            {
                Tracks.Add(track);
            }

            if (selectedTrackId != null)
            {
                SelectedTrack = tracks.FirstOrDefault(t => t.Track.Id == selectedTrackId.Value);
            }

            NotifyPropertyChanged(nameof(NoTracks));
        }
Exemplo n.º 3
0
        public override void OnNavigatedTo(NavigatedToEventArgs e, Dictionary <string, object> viewModelState)
        {
            Tracks  = Tracks ?? new SimpleStateSupportCollection <JumpListGroup <VKSaverTrack> >(LoadTracks);
            Artists = Artists ?? new SimpleStateSupportCollection <JumpListGroup <VKSaverArtist> >(LoadArtists);
            Albums  = Albums ?? new SimpleStateSupportCollection <JumpListGroup <VKSaverAlbum> >(LoadAlbums);
            Genres  = Genres ?? new SimpleStateSupportCollection <JumpListGroup <VKSaverGenre> >(LoadGenres);
            Folders = Folders ?? new SimpleStateSupportCollection <VKSaverFolder>(LoadFolders);
            Cached  = Cached ?? new SimpleStateSupportCollection <JumpListGroup <VKSaverTrack> >(LoadCachedTracks);

            if (_libraryDatabaseService.NeedReloadLibraryView)
            {
                Tracks.Clear();
                Artists.Clear();
                Albums.Clear();
                Genres.Clear();
                Folders.Clear();
                Cached.Clear();

                _libraryDatabaseService.NeedReloadLibraryView = false;
            }

            if (viewModelState.Count > 0)
            {
                CurrentPivotIndex = (int)viewModelState[nameof(CurrentPivotIndex)];
            }
            else
            {
                string viewName = (string)e.Parameter;
                SetPivotIndex(viewName);
            }

            base.OnNavigatedTo(e, viewModelState);
        }
Exemplo n.º 4
0
        /// <summary>
        ///     Updates the playlist Url.
        /// </summary>
        private async Task UpdatePlaylistUrl()
        {
            if (_playlistUrlChanged)
            {
                Workspace.SetPlaylistUrl(PlaylistUrl);
                Tracks.Clear();
            }

            if (string.IsNullOrEmpty(Workspace.PlaylistId))
            {
                return;
            }

            await Task.Run(() =>
            {
                foreach (var track in Tracks)
                {
                    track.CheckForTrack();
                }
            });

            PlaylistFetchProgress = 0;
            FetchingPlaylist      = true;

            var retreiver = new PlaylistItemsRetriever(Settings.Default.PlaylistReceiveMaximum);

            retreiver.PlaylistItemsRetrieverProgressChanged +=
                delegate(object sender, PlaylistItemRetreiverProgressChangedEventArgs args)
            {
                PlaylistFetchProgress = args.Progress;
            };

            retreiver.PlaylistItemsRetrieverCompleted +=
                (sender, args) =>
            {
                if (args.Cancelled)
                {
                    Messenger.Default.Send(
                        new ShowMessageDialogMessage(Resources.MainWindow_CurrentWorkspace_PlaylistLoadError_Title,
                                                     Resources.MainWindow_CurrentWorkspace_PlaylistLoadError_Content));
                    FetchingPlaylist = false;
                    return;
                }

                Workspace.Settings.Items =
                    new HashSet <PlaylistItem>(List.Sync(Workspace.Settings.Items.ToList(), args.Result));

                UpdateTracks();

                FetchingPlaylist = false;

                if (_playlistUrlChanged)
                {
                    _playlistUrlChanged = false;
                    CleanupWorkspaceFolder();
                }
            };

            await Task.Run(() => { retreiver.GetPlaylistItems(Workspace.PlaylistId); });
        }
Exemplo n.º 5
0
        void ClearDatabase()
        {
            musicDatabase.DeleteAll();
            musicDatabase.DeleteAll();
            musicDatabase.DeleteAll();
            trackCollectionRepository.DeleteAll();
            tracklistItemRepository.DeleteAll();

            musicDatabase.Initialize();
            musicDatabase.Initialize();
            musicDatabase.Initialize();
            trackCollectionRepository.Initialize();
            tracklistItemRepository.Initialize();

            Artists.Clear();
            Albums.Clear();
            Tracks.Clear();
            TrackCollections.Clear();

            videoDatabase.DeleteAll();

            Videos.Clear();
            CameraRoll.Clear();
            Shows.Clear();
        }
Exemplo n.º 6
0
        void Load_files()
        {
            var dialog = new FolderBrowserDialog();

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                Tracks.Clear();
                foreach (string file in Directory.GetFiles(dialog.SelectedPath))
                {
                    if (filter.Exists(n => n == file.Split(new char[] { '.' }).Last().ToLower()))
                    {
                        try
                        {
                            var fileinfo = new FileInfo(file);
                            Tracks.Add(new Track {
                                Name = fileinfo.Name, Path_to_Track = fileinfo.FullName, Size = fileinfo.Length / 1000
                            });
                        }
                        catch (Exception ex)
                        {
                            System.Windows.MessageBox.Show(ex.Message);
                        }
                    }
                }
            }
        }
Exemplo n.º 7
0
 public void ResetMusicContent()
 {
     Tracks.Clear();
     Albums.Clear();
     Artists.Clear();
     Playlists.Clear();
 }
Exemplo n.º 8
0
        public async Task Initialize()
        {
            Artists.Clear();
            Albums.Clear();
            Tracks.Clear();
            TrackCollections.Clear();

            Videos.Clear();
            CameraRoll.Clear();
            Shows.Clear();

            if (_alreadyIndexedOnce)
            {
                return;
            }
            _alreadyIndexedOnce = true;
            // Doing full indexing from scratch if 0 tracks are found
            if (IsMusicDatabaseEmpty() && IsVideoDatabaseEmpty())
            {
                ClearDatabase();
            }
            else // Restore the database
            {
                LoadVideosFromDatabase();
                await LoadShowsFromDatabase();

                LoadCameraRollFromDatabase();
            }
            await PerformMediaLibraryIndexing();
        }
        public SessionsViewModel()
        {
            Title = "Sessions";

            _logger = AppSettings.Log.CreateLogger(Title);

            _dataStore             = App.DataStore;
            _tracks                = new List <TrackState>();
            _selectedTrack         = null;
            _sessions              = new ObservableCollection <SessionState>();
            _sessionsGroupedByDate = new ObservableCollection <Grouping <SessionDateInfo, SessionState> >();

            DependencyService.Get <IMessageBus>().OnEventRefreshed(this, state =>
            {
                Sessions.Clear();
                foreach (SessionState session in state.Sessions)
                {
                    Sessions.Add(session);
                }
                Tracks.Clear();
                foreach (var track in state.Tracks)
                {
                    Tracks.Add(track);
                }
                FilterSessions(_selectedTrack);
            });
        }
Exemplo n.º 10
0
        public override int Build()
        {
            Tracks.Clear();

            Track track = new Track(++trackId, Tracktype.Airline);

            Node node;

            Osm.Segment segment = new Osm.Segment();
            segment.Tags.Add("ref", "North/South connection");

            Osm.Node osmNode;

            segment.Id = 1;

            // make a track with segment size of 96 meter. (180 segments North/South)
            for (int y = -MapSize / 2; y <= MapSize / 2; y += 96)
            {
                osmNode     = new Osm.Node();
                osmNode.Lat = GeoTools.DistanceToLat(lat, y);
                osmNode.Lon = lon;

                node = CreateNode(track, segment, osmNode, 0, y);

                track.Nodes.Add(node);
            }

            Tracks.Add(track);

            return(0);
        }
Exemplo n.º 11
0
 private void OnVisualizeTrack(VisualizeTrackEvent obj)
 {
     Tracks.Clear();
     if (obj.Track != null && obj.Track.Any())
     {
         if (obj.Track.Count == 2)
         {
             Tracks.Add(obj.Track.First().CalculateGreatCircleLocations(obj.Track.Last()));
         }
         else if (obj.Track.Count > 2)
         {
             IList <LogbookLocation> filteredTrack = GetFilteredTrack(obj.Track, Length.FromMeters(10));
             int pageSize = 2000;
             int pages    = (int)Math.Ceiling(filteredTrack.Count / (double)pageSize);
             for (int i = 0; i < pages * pageSize; i += pageSize)
             {
                 LocationCollection locations = new LocationCollection();
                 foreach (LogbookLocation location in filteredTrack.Skip(i).Take(pageSize))
                 {
                     locations.Add(location);
                 }
                 Tracks.Add(locations);
             }
         }
         ZoomToTracksBounds();
     }
 }
Exemplo n.º 12
0
 private void ClearViewModel()
 {
     Albums.Clear();
     Artists.Clear();
     Playlists.Clear();
     Tracks.Clear();
 }
Exemplo n.º 13
0
        public async Task SetupView(Playlist newPlaylist)
        {
            // Check if the models saved playlist is null
            if (newPlaylist != null && (Playlist == null || Playlist.Id != newPlaylist.Id))
            {
                // Show the loading ring
                (App.CurrentFrame?.FindName("PlaylistInfoPane") as InfoPane)?.ShowLoading();

                // Set the playlist
                Playlist = newPlaylist;
                // Clear any existing tracks
                Tracks.Clear();

                // Get the resource loader
                var resources = ResourceLoader.GetForCurrentView();

                // Check if the tile is pinned
                if (TileService.Instance.DoesTileExist("Playlist_" + Playlist.Id))
                {
                    PinButtonIcon = "\uE77A";
                    PinButtonText = resources.GetString("AppBarUI_Unpin_Raw");
                }
                else
                {
                    PinButtonIcon = "\uE718";
                    PinButtonText = resources.GetString("AppBarUI_Pin_Raw");
                }

                if (await SoundByteService.Instance.ExistsAsync($"/e1/me/playlist_likes/{Playlist.Id}"))
                {
                    LikeButtonText = "Unlike Playlist";
                }
                else
                {
                    LikeButtonText = "Like Playlist";
                }

                try
                {
                    // Show the loading ring
                    (App.CurrentFrame?.FindName("PlaylistInfoPane") as InfoPane)?.ShowLoading();
                    // Get the playlist tracks
                    var playlistTracks =
                        (await SoundByteService.Instance.GetAsync <Playlist>("/playlists/" + Playlist.Id)).Tracks;
                    playlistTracks.ForEach(x => Tracks.Add(x));
                    // Hide the loading ring
                    (App.CurrentFrame?.FindName("PlaylistInfoPane") as InfoPane)?.ClosePane();
                }
                catch (Exception)
                {
                    (App.CurrentFrame?.FindName("PlaylistInfoPane") as InfoPane)?.ShowMessage("Could not load tracks",
                                                                                              "Something went wrong when trying to load the tracks for this playlist, please make sure you are connected to the internet and then go back, and click on this playlist again.",
                                                                                              "", false);
                }

                // Hide the loading ring
                (App.CurrentFrame?.FindName("PlaylistInfoPane") as InfoPane)?.ClosePane();
            }
        }
Exemplo n.º 14
0
 public void Clear()
 {
     TargetVideoCodec = MediaConvertGUIConfiguration.GetVideoCodecByName("copy");
     TargetContainer  = MediaConvertGUIConfiguration.DefaultContainer;
     AutoRotate       = false;
     Tracks.Clear();
     FileSize = 0;
 }
Exemplo n.º 15
0
 public override void CreateEmptyMedia()
 {
     _LastError = "";
     Tracks.Clear();
     for (int i = 0; i < 80; ++i)
     {
         Tracks.Add(new Track(i + 1, 40));
     }
     CreateBAM();
 }
Exemplo n.º 16
0
        public async Task SetupView(Playlist newPlaylist)
        {
            // Check if the models saved playlist is null
            if (newPlaylist != null && (Playlist == null || Playlist.Id != newPlaylist.Id))
            {
                // Set the playlist
                Playlist = newPlaylist;
                // Clear any existing tracks
                Tracks.Clear();

                // Get the resource loader
                var resources = ResourceLoader.GetForCurrentView();

                // Check if the tile is pinned
                if (TileService.Current.DoesTileExist("Playlist_" + Playlist.Id))
                {
                    PinButtonIcon = "\uE77A";
                    PinButtonText = resources.GetString("AppBarUI_Unpin_Raw");
                }
                else
                {
                    PinButtonIcon = "\uE718";
                    PinButtonText = resources.GetString("AppBarUI_Pin_Raw");
                }

                try
                {
                    // Show the loading ring
                    App.IsLoading = true;
                    // Get the playlist tracks
                    var playlistTracks = (await SoundByteService.Current.GetAsync <Playlist>("/playlists/" + Playlist.Id)).Tracks;
                    playlistTracks.ForEach(x => Tracks.Add(x));
                    // Hide the loading ring
                    App.IsLoading = false;
                }
                catch (Exception)
                {
                    // Create the error dialog
                    var noItemsDialog = new ContentDialog
                    {
                        Title   = "Could not load tracks",
                        Content = new TextBlock {
                            TextWrapping = TextWrapping.Wrap, Text = "Something went wrong when trying to load the tracks for this playlist, please make sure you are connected to the internet and then go back, and click on this playlist again."
                        },
                        IsPrimaryButtonEnabled = true,
                        PrimaryButtonText      = "Close"
                    };
                    // Hide the loading ring
                    App.IsLoading = false;
                    // Show the dialog
                    await noItemsDialog.ShowAsync();
                }
            }
        }
Exemplo n.º 17
0
        public async Task SetupView(BasePlaylist newPlaylist)
        {
            // Check if the models saved playlist is null
            if (newPlaylist != null && (Playlist == null || Playlist.PlaylistId != newPlaylist.PlaylistId))
            {
                // Show the loading ring
                await App.SetLoadingAsync(true);

                // Set the playlist
                Playlist = newPlaylist;
                // Clear any existing tracks
                Tracks.Clear();

                // Get the resource loader
                var resources = ResourceLoader.GetForCurrentView();

                // Check if the tile is pinned
                if (TileHelper.IsTilePinned("Playlist_" + Playlist.PlaylistId))
                {
                    PinButtonIcon = "\uE77A";
                    PinButtonText = resources.GetString("AppBarUI_Unpin_Raw");
                }
                else
                {
                    PinButtonIcon = "\uE718";
                    PinButtonText = resources.GetString("AppBarUI_Pin_Raw");
                }

                if ((await SoundByteService.Current.ExistsAsync(ServiceType.SoundCloud, $"/e1/me/playlist_likes/{Playlist.PlaylistId}")).Response)
                {
                    LikeButtonText = "Unlike Playlist";
                }
                else
                {
                    LikeButtonText = "Like Playlist";
                }

                try
                {
                    // Get the playlist tracks
                    var playlistTracks =
                        (await SoundByteService.Current.GetAsync <SoundCloudPlaylist>(ServiceType.SoundCloud, "/playlists/" + Playlist.PlaylistId)).Response.Tracks;
                    playlistTracks.ForEach(x => Tracks.Add(x.ToBaseTrack()));
                }
                catch (Exception)
                {
                    await NavigationService.Current.CallMessageDialogAsync("Could not load tracks",
                                                                           "Something went wrong when trying to load the tracks for this playlist, please make sure you are connected to the internet and then go back, and click on this playlist again.");
                }

                // Hide the loading ring
                await App.SetLoadingAsync(false);
            }
        }
Exemplo n.º 18
0
 private void SearchTracks(string searchQuery)
 {
     Tracks.Clear();
     foreach (var item in AllTracks)
     {
         if (item.TrackName.ToLower().Contains(searchQuery.ToLower()))
         {
             Tracks.Add(item);
         }
     }
 }
        private void Close()
        {
            CancelAsync();
            Tracks.Clear();

            var flyout = Application.Current.MainWindow.GetVisualDescendents().FirstOrDefault(c => c is FlyoutControl) as FlyoutControl;

            if (flyout != null)
            {
                flyout.Close();
            }
        }
Exemplo n.º 20
0
        public bool Refresh()
        {
            var newTracks = Filter.Apply(LibraryTracks);

            if (!newTracks.SequenceEqual(Tracks))
            {
                Tracks.Clear();
                Tracks.AddRange(Filter.Apply(LibraryTracks));
                RaisePropertyChanged("Tracks");
                return(true);
            }
            return(false);
        }
Exemplo n.º 21
0
        /// <summary>
        /// Plays playlist passed as a parameter
        /// </summary>
        /// <param name="playlist"></param>
        /// <returns></returns>
        public async Task PlayPlaylist(PlaylistToDisplay playlist)
        {
            if (playlist == null)
            {
                throw new ArgumentNullException("There was an error during fetching tracks for playlist. Play playlist failed.");
            }
            var tracks = PlaylistTrackService.GetPlaylistTracks(playlist.id).OrderBy(pt => pt.TrackOrder);

            if (tracks == null)
            {
                throw new EmptyPlaylistException("Playlist does not contain any tracks.");
            }
            else if (tracks.Count() == 0)
            {
                throw new EmptyPlaylistException("Playlist does not contain any tracks.");
            }
            List <PlaylistTrackToDisplay> deletedPlaylistTracks = new List <PlaylistTrackToDisplay>();

            Playlist = playlist;
            // Clear tracks from current playlist
            Tracks.Clear();
            foreach (var t in tracks)
            {
                var tempTrack = await SoundCloudHelper.GetSoundCloudTrack(t.TrackID);

                if (tempTrack != null)
                {
                    Tracks.Add(tempTrack);
                }
                else
                {
                    deletedPlaylistTracks.Add(t);
                }
            }
            MessageService.SendMessageToBackground(this, new UpdatePlaylistMessage(Tracks.ToList()));
            if (deletedPlaylistTracks.Count > 0)
            {
                foreach (var deletedPlaylistTrack in deletedPlaylistTracks)
                {
                    PlaylistTrackService.DeletePlaylistTrack(deletedPlaylistTrack.id);
                }
                for (int i = 0; i < Tracks.Count; ++i)
                {
                    var movedTrack = PlaylistTrackService.GetPlaylistTrack(Playlist.id, (int)Tracks[i].id);
                    movedTrack.TrackOrder = i;
                    PlaylistTrackService.ModifyPlaylistTrack(movedTrack);
                }
                throw new SoundCloudTrackNotAvailableException($"Some of your tracks were deleted from playlist {playlist.Name}, because they were no longer available on SoundCloud", deletedPlaylistTracks.Select(pt => pt.id).ToList());
            }
        }
Exemplo n.º 22
0
        public int LoadPlaylistFromList(List <ITrack> tracks, bool startPlayback = true)
        {
            StopPlaylistPlayback();

            Tracks.Clear();
            tracks.ForEach(t => Tracks.Add(t));

            if (startPlayback)
            {
                StartPlaylistPlayback();
            }

            return(Tracks.Count);
        }
Exemplo n.º 23
0
        private async void Refresh()
        {
            await ServiceLocator.LocalMusicService.Clear();

            if (Tracks != null)
            {
                Tracks.Clear();
            }

            if (Artists != null)
            {
                Artists.Clear();
            }

            if (Albums != null)
            {
                Albums.Clear();
            }

            if (AlbumGroups != null)
            {
                AlbumGroups.Clear();
            }

            if (SelectedArtistAlbums != null)
            {
                SelectedArtistAlbums.Clear();
            }

            var flyout = new FlyoutControl();

            flyout.FlyoutContent = new MusicScanView();
            await flyout.ShowAsync();

            switch (SelectedTabIndex)
            {
            case 0:
                LoadTracks();
                break;

            case 1:
                LoadAlbums();
                break;

            case 2:
                LoadArtists();
                break;
            }
        }
Exemplo n.º 24
0
        private void ProcessTracks()
        {
            if (SourceTracks != null)
            {
                _trackProcessor.KalmanEnabled  = Filtering;
                _trackProcessor.StopsDetection = StopsDetection;
                _trackProcessor.SpikeDetection = SpikeDetection;
                Tracks.Clear();
                Tracks.AddRange(SourceTracks);

                FilterResult      = _trackProcessor.ProcessTracks(SourceTracks);
                FilterResult.Name = "Result";
                Tracks.Add(FilterResult);
            }
        }
        private async Task SearchTracks(string searchQuery)
        {
            if (AddTracks == true)
            {
                if (string.IsNullOrWhiteSpace(searchQuery))
                {
                    await Application.Current.MainPage.DisplayAlert("Error", "Please type in the search bar", "OK");

                    return;
                }
                var searchResult = await _trackService.Get <List <Track> >(new TrackSearchRequest()
                {
                    TrackName = searchQuery
                });

                Tracks.Clear();
                foreach (var item in searchResult)
                {
                    var thisTrack = await _trackService.GetById <Track>(item.TrackId);

                    var thisAlbum = await _albumService.GetById <Album>(thisTrack.AlbumId);

                    var thisArtist = await _artistService.GetById <Artist>(thisAlbum.ArtistId);

                    TrackHelperVM local = new TrackHelperVM()
                    {
                        TrackId    = thisTrack.TrackId,
                        TrackName  = thisTrack.TrackName,
                        AlbumId    = thisAlbum.AlbumId,
                        AlbumName  = thisAlbum.AlbumName,
                        ArtistId   = thisArtist.ArtistId,
                        ArtistName = thisArtist.ArtistName
                    };
                    Tracks.Add(local);
                }
            }
            else
            {
                Tracks.Clear();
                foreach (var item in AllTracks)
                {
                    if (item.TrackName.ToLower().Contains(searchQuery.ToLower()))
                    {
                        Tracks.Add(item);
                    }
                }
            }
        }
Exemplo n.º 26
0
        private async Task LoadFromDatabase()
        {
            await App.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                Artists.Clear();
                Tracks.Clear();
            });

            await MusicLibraryManagement.LoadFromSQL();

            await DispatchHelper.InvokeAsync(() =>
            {
                IsMusicLibraryEmpty = !Artists.Any();
                OnPropertyChanged("IsMusicLibraryEmpty");
            });
        }
Exemplo n.º 27
0
        public async Task FindOnViez(string term)
        {
            if (Tracks == null)
            {
                Tracks = new IncrementalObservableCollection <Base>();
            }
            else
            {
                Tracks.Clear();
            }

            List <WebSong> _allTracks;

            try
            {
                if (Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamily == "Windows.Mobile")
                {
                    _allTracks = await _misc.GetViezResultsAsync(term, 20);
                }
                else
                {
                    _allTracks = await _misc.GetViezResultsAsync(term, 30);
                }
                if (_allTracks != null)
                {
                    int indexToAdd = -1;
                    foreach (var oSong in _allTracks)
                    {
                        indexToAdd++;
                        Tracks.Add(oSong);
                        if (indexToAdd == 2 || indexToAdd == 10 || indexToAdd == 22 || indexToAdd == 34 || indexToAdd == 49 ||
                            indexToAdd == 63 || indexToAdd == 78 || indexToAdd == 88 || indexToAdd == 99)
                        {
                            Tracks.Insert(indexToAdd, new ListAdvert());
                        }
                    }
                }

                TrackMessage = (Tracks != null && Tracks.Count > 0) ? Core.StringMessage.NoMessge : Core.StringMessage.EmptyMessage;
            }
            catch (Exception)
            {
                TrackMessage = Core.StringMessage.SomethinWentWrong;
            }

            foundInViez = true;
        }
Exemplo n.º 28
0
        private void DoStuff(Playlist item)
        {
            if (Tracks.Count != 0)
            {
                Tracks.Clear();
            }

            for (int i = 0; i < Playlists.Count; i++)
            {
                if (Playlists[i].PlaylistName == item.PlaylistName)
                {
                    for (int j = 0; j < Playlists[i].AllTracks.Count; j++)
                    {
                        Tracks.Add(Playlists[i].AllTracks[j]);
                    }
                }
            }
        }
Exemplo n.º 29
0
 /// <summary>
 /// Cleans current playlist and plays single track
 /// </summary>
 /// <param name="track"></param>
 public void PlaySingleTrack(SoundCloudTrack track)
 {
     if (track == null)
     {
         throw new Exception("Track is empty. Play track failed.");
     }
     if (track.stream_url == null && track.uri != null)
     {
         track.stream_url = GetStreamUrlFromUri(track.uri);
     }
     if (track.stream_url != null)
     {
         MessageService.SendMessageToBackground(this, new UpdatePlaylistMessage(new List <SoundCloudTrack> {
             track
         }));
     }
     Tracks.Clear();
     Tracks.Add(track);
 }
Exemplo n.º 30
0
        /// <summary>
        ///     Loads the library from the cache.
        /// </summary>
        public void LoadFromDatabase()
        {
            if (!File.Exists(LibraryCacheFilename))
            {
                return;
            }
            try
            {
                var tracks = SerializationHelper <List <Track> > .FromXmlFile(LibraryCacheFilename);

                lock (Tracks)
                {
                    Tracks.Clear();
                    Tracks.AddRange(tracks.ToArray());
                }
            }
            catch
            {
                // ignored
            }
        }