Exemplo n.º 1
0
        public async Task StartDownloadPlaylist(PlaylistFile playlist)
        {
            foreach (var audio in playlist.TracksFiles)
            {
                var track = new DownloadAudioFile()
                {
                    Title     = audio.Title.Replace("*", "").Replace(".", "").Replace("\"", "").Replace("\\", "").Replace("/", "").Replace("[", "").Replace("]", "").Replace(":", "").Replace(";", "").Replace("|", "").Replace("=", "").Replace(",", ""),
                    AlbumName = playlist.Name.Replace("*", "").Replace(".", "").Replace("\"", "").Replace("\\", "").Replace("/", "").Replace("[", "").Replace("]", "").Replace(":", "").Replace(";", "").Replace("|", "").Replace("=", "").Replace(",", ""),
                    AlbumYear = playlist.Year,
                    Artist    = audio.Artist.Replace("*", "").Replace(".", "").Replace("\"", "").Replace("\\", "").Replace("/", "").Replace("[", "").Replace("]", "").Replace(":", "").Replace(";", "").Replace("|", "").Replace("=", "").Replace(",", ""),
                    Cover     = audio.Cover,
                    Url       = audio.SourceString,
                    FromAlbum = true,
                    AudioFile = audio
                };
                AddToQueue(track);
            }

            StorageFolder folder = await KnownFolders.MusicLibrary.TryGetItemAsync("Music X") == null ?
                                   await KnownFolders.MusicLibrary.CreateFolderAsync("Music X")
                : await KnownFolders.MusicLibrary.GetFolderAsync("Music X");

            var           playlistName   = playlist.Name.Replace("*", "").Replace(".", "").Replace("\"", "").Replace("\\", "").Replace("/", "").Replace("[", "").Replace("]", "").Replace(":", "").Replace(";", "").Replace("|", "").Replace("=", "").Replace(",", "");
            StorageFolder playlistFolder = await folder.TryGetItemAsync(playlistName) == null ?
                                           await folder.CreateFolderAsync(playlistName)
                : await folder.GetFolderAsync(playlistName);

            var task = Task.Run(async() =>
            {
                await DownloadAudio(QueueTracks.First());
            });
        }
Exemplo n.º 2
0
        private void DonwloadFileComplete(object a, DownloadAudioFile e)
        {
            var settings = ApplicationData.Current.LocalSettings;

            settings.Values["CountDownloads"] = (int)settings.Values["CountDownloads"] + 1;

            QueueTracks.Remove(e);
            if (QueueTracks.Count == 0)
            {
                DispatcherHelper.CheckBeginInvokeOnUI(() =>
                {
                    this.Timer.Stop();
                    DownloadQueueComplete?.Invoke(this, null);
                });
            }
            else
            {
                var task = Task.Run(async() =>
                {
                    await DownloadAudio(QueueTracks.First());
                });
            }

            CurrentDownloadTrack = null;
        }
Exemplo n.º 3
0
        private void AddToQueue(DownloadAudioFile track)
        {
            if (QueueTracks == null)
            {
                QueueTracks = new List <DownloadAudioFile>();
            }

            if (QueueTracks.Any(t => t == track))
            {
                return;
            }
            QueueTracks.Add(track);
        }
        private HttpResponse QueueContentsResponse()
        {
            var queue = new QueueTracks();
            var track = Player.CurrentTrack;

            if (track != null)
            {
                var container = Player.ActivePlaylist ?? Player.MediaLibrary;

                var canp = new CanpData
                {
                    DatabaseId      = id,
                    ContainerId     = container.Id,
                    ContainerItemId = track.Id,
                    TrackId         = track.Id
                };

                queue.Add(new QueueTrack()
                {
                    TrackSpecs  = canp.Data,
                    AlbumId     = (track.Album != null) ? track.Album.PersistentId : 0,
                    Album       = track.AlbumName,
                    AlbumArtist = (track.AlbumArtist != null) ? track.AlbumArtist.Id : 0,
                    Artist      = track.ArtistName,
                    Title       = track.Title,
                    Genre       = track.GenreName,
                    MediaKind   = 1,
                    QueueIndex  = 1,
                    Upcoming    = false
                });
            }

            return(new DmapResponse(new
            {
                ceQR = new
                {
                    mstt = 200,
                    muty = (byte)0,
                    ceQu = true, // update???
                    mlcl = queue,
                    apsm = false,
                    aprm = (byte)0
                }
            }));
        }