Ejemplo n.º 1
0
        public static void PrepareDownload(SongViewModel item)
        {
            var nameBase = System.IO.Path.Combine(Global.BasePath, "cache", item.Id);

            if (!item.HasMp3)
            {
                var mp3 = nameBase + ".mp3";
                var d   = new DownloaderMp3
                {
                    Info = new DownloaderInfo
                    {
                        Id       = "mp3" + item.Id,
                        FileName = mp3,
                        Entity   = item,
                        Tag      = item.Id,
                    }
                };
                DownloadManager.Instance.Add(d);
            }
            if (!item.HasLrc)
            {
                var lrc = nameBase + ".lrc";
                var d   = new DownloaderLrc
                {
                    Info = new DownloaderInfo
                    {
                        Id       = "lrc" + item.Id,
                        FileName = lrc,
                        Tag      = item.Id,
                        Entity   = item
                    }
                };
                DownloadManager.Instance.Add(d);
            }
            if (!item.HasArt)
            {
                var art = System.IO.Path.Combine(
                    Global.BasePath, "cache",
                    item.AlbumId + ".art");
                var d = new DownloaderArt
                {
                    Info = new DownloaderInfo
                    {
                        Id       = "art" + item.AlbumId,
                        FileName = art,
                        Entity   = item,
                        Tag      = item.Id,
                    }
                };
                var first = DownloadManager.Instance.GetDownloader(d.Info.Id) as DownloaderArt;
                if (first == null)
                {
                    DownloadManager.Instance.Add(d);
                }
                else
                {
                    first.ArtDownloaded += d.HandleDownloaded;
                }
            }
        }
 public static void PrepareDownload(SongViewModel item)
 {
     var nameBase = System.IO.Path.Combine(Global.BasePath, "cache", item.Id);
     if (!item.HasMp3)
     {
         var mp3 = nameBase + ".mp3";
         var d = new DownloaderMp3
         {
             Info = new DownloaderInfo
             {
                 Id = "mp3" + item.Id,
                 FileName = mp3,
                 Entity = item,
                 Tag = item.Id,
             }
         };
         DownloadManager.Instance.Add(d);
     }
     if (!item.HasLrc)
     {
         var lrc = nameBase + ".lrc";
         var d = new DownloaderLrc
         {
             Info = new DownloaderInfo
             {
                 Id = "lrc" + item.Id,
                 FileName = lrc,
                 Tag = item.Id,
                 Entity = item
             }
         };
         DownloadManager.Instance.Add(d);
     }
     if (!item.HasArt)
     {
         var art = System.IO.Path.Combine(
             Global.BasePath, "cache",
             item.AlbumId + ".art");
         var d = new DownloaderArt
         {
             Info = new DownloaderInfo
             {
                 Id = "art" + item.AlbumId,
                 FileName = art,
                 Entity = item,
                 Tag = item.Id,
             }
         };
         var first = DownloadManager.Instance.GetDownloader(d.Info.Id) as DownloaderArt;
         if (first == null)
             DownloadManager.Instance.Add(d);
         else
         {
             first.ArtDownloaded += d.HandleDownloaded;
         }
     }
 }
        public static void PrepareDownload(this SongViewModel item)
        {
            var nameBase = Path.Combine(Global.BasePath, "cache", item.Id);
            if (!item.HasArt)
            {
                var art = Path.Combine(
                       Global.BasePath, "cache",
                       item.AlbumId + ".art");
                if (File.Exists(art))
                {
                    item.ImageSource = art;
                    item.HasArt = true;
                }
                else
                {
                    AfterDownloadManager.Register("art" + item.AlbumId, x =>
                    {
                        item.ImageSource = x;
                        item.HasArt = true;
                    });
                    if (DownloadManager.Instance.GetById("art" + item.AlbumId) == null)
                    {

                        var d = new DownloaderArt
                        {
                            Info = new DownloaderInfo
                            {
                                Id = "art" + item.AlbumId,
                                FileName = art,
                                Entity = item,
                                Tag = item.Id,
                                Priority = 2,
                                Url = item.UrlArt,
                            }
                        };
                        DownloadManager.Instance.Add(d);
                    }
                }
            }
            if(!item.HasMp3)
            {
                var mp3 = nameBase + ".mp3";
                var d = new DownloaderMp3
                {
                    Info = new DownloaderInfo
                    {
                        Id = "mp3" + item.Id,
                        FileName = mp3,
                        Entity = item,
                        Tag = item.Id,
                        Priority = 1,
                        Url=item.UrlMp3,
                    }
                };
                DownloadManager.Instance.Add(d);
            }
            if(!item.HasLrc)
            {
                var lrc = nameBase + ".lrc";
                var d = new DownloaderLrc
                {
                    Info = new DownloaderInfo
                    {
                        Id = "lrc" + item.Id,
                        FileName = lrc,
                        Tag = item.Id,
                        Entity = item,
                        Url= item.UrlLrc,
                        Priority=0,
                    }
                };
                DownloadManager.Instance.Add(d);
            }
        }
Ejemplo n.º 4
0
        public static void PrepareDownload(this SongViewModel item)
        {
            var nameBase = Path.Combine(Global.BasePath, "cache", item.Id);

            //if (!item.HasArt)
            //{
            //    var art = Path.Combine(
            //           Global.BasePath, "cache",
            //           item.AlbumId + ".art");
            //    if (File.Exists(art))
            //    {
            //        item.ImageSource = art;
            //        item.HasArt = true;
            //    }
            //    else
            //    {
            //        AfterDownloadManager.Register("art" + item.AlbumId, x =>
            //        {
            //            item.ImageSource = x;
            //            item.HasArt = true;
            //        });
            //        if (DownloadManager.Instance.GetById("art" + item.AlbumId) == null)
            //        {

            //            var d = new DownloaderArt
            //            {
            //                Info = new DownloaderInfo
            //                {
            //                    Id = "art" + item.AlbumId,
            //                    FileName = art,
            //                    Entity = item,
            //                    Tag = item.Id,
            //                    Priority = 2,
            //                    Url = item.UrlArt.Replace("_1.jpg",".jpg")
            //                }
            //            };
            //            DownloadManager.Instance.Add(d);
            //        }
            //    }
            //}
            if (!item.HasMp3)
            {
                var mp3 = nameBase + ".mp3";
                var d   = new DownloaderMp3
                {
                    Info = new DownloaderInfo
                    {
                        Id       = "mp3" + item.Id,
                        FileName = mp3,
                        Entity   = item,
                        Tag      = item.Id,
                        Priority = 1,
                        Url      = item.UrlMp3,
                    }
                };
                DownloadManager.Instance.Add(d);
            }
            if (!item.HasLrc)
            {
                var lrc = nameBase + ".lrc";
                var d   = new DownloaderLrc
                {
                    Info = new DownloaderInfo
                    {
                        Id       = "lrc" + item.Id,
                        FileName = lrc,
                        Tag      = item.Id,
                        Entity   = item,
                        Url      = item.UrlLrc,
                        Priority = 0,
                    }
                };
                DownloadManager.Instance.Add(d);
            }
        }
        public static void PrepareDownload(this SongViewModel item)
        {
            var nameBase = Path.Combine(Global.BasePath, "cache", item.Id);
            //if (!item.HasArt)
            //{
            //    var art = Path.Combine(
            //           Global.BasePath, "cache",
            //           item.AlbumId + ".art");
            //    if (File.Exists(art))
            //    {
            //        item.ImageSource = art;
            //        item.HasArt = true;
            //    }
            //    else
            //    {
            //        AfterDownloadManager.Register("art" + item.AlbumId, x =>
            //        {
            //            item.ImageSource = x;
            //            item.HasArt = true;
            //        });
            //        if (DownloadManager.Instance.GetById("art" + item.AlbumId) == null)
            //        {

            //            var d = new DownloaderArt
            //            {
            //                Info = new DownloaderInfo
            //                {
            //                    Id = "art" + item.AlbumId,
            //                    FileName = art,
            //                    Entity = item,
            //                    Tag = item.Id,
            //                    Priority = 2,
            //                    Url = item.UrlArt.Replace("_1.jpg",".jpg")
            //                }
            //            };
            //            DownloadManager.Instance.Add(d);
            //        }
            //    }
            //}
            if(!item.HasMp3)
            {
                var mp3 = nameBase + ".mp3";
                var d = new DownloaderMp3
                {
                    Info = new DownloaderInfo
                    {
                        Id = "mp3" + item.Id,
                        FileName = mp3,
                        Entity = item,
                        Tag = item.Id,
                        Priority = 1,
                        Url=item.UrlMp3,
                    }
                };
                DownloadManager.Instance.Add(d);
            }
            if(!item.HasLrc)
            {
                var lrc = nameBase + ".lrc";
                var d = new DownloaderLrc
                {
                    Info = new DownloaderInfo
                    {
                        Id = "lrc" + item.Id,
                        FileName = lrc,
                        Tag = item.Id,
                        Entity = item,
                        Url= item.UrlLrc,
                        Priority=0,
                    }
                };
                DownloadManager.Instance.Add(d);
            }
        }