Beispiel #1
0
 public static MTVPreview GetViewer(MyMTV mtv)
 {
     if (Previewer == null)
     {
         Previewer = new MTVPreview();
     }
     else
     {
         Previewer.Dispose();
         Previewer = new MTVPreview();
     }
     Previewer.InitData(mtv.Id);
     return(Previewer);
 }
Beispiel #2
0
 public OrderLabel(MyMTV mtv, int sort)
 {
     InitializeComponent();
     OrderMTV       = mtv;
     labelSort.Text = sort.ToString();
     labelName.Text = OrderMTV.MTVName + "-" + OrderMTV.Artist;
     if (sort % 2 == 0)
     {
         Appearance.BackColor = Color.FromArgb(204, 204, 204);
     }
     if (RunTimeData.VideoQueue.Any(m => m.MTV.Id == Guid.Parse(OrderMTV.Id)))
     {
         LabelOrder.Appearance.BackColor = Color.Green;
     }
 }
Beispiel #3
0
        public static void ShotMTV(MyMTV mtv)
        {
            if (mtv == null)
            {
                return;
            }

            AxPlayer player = new AxPlayer();

            ((System.ComponentModel.ISupportInitialize)(player)).BeginInit();
            Form form = new Form();

            form.Controls.Add(player);
            ((System.ComponentModel.ISupportInitialize)(player)).EndInit();
            if (player.GetConfig(APlayerSnapshotConfig.SnapshotUsable.GetHashCode()) != "0")
            {
                return;
            }
            player.SetConfig(APlayerSnapshotConfig.SnapshotFormat.GetHashCode(), "2");
            player.SetConfig(APlayerSnapshotConfig.SnapshotJpegQuality.GetHashCode(), "100");
            string imgPath = PathHelper.GetScreenShotDir(mtv.Id) + mtv.MTVName + "-" + mtv.Artist + "ScreenShot";
            int    unit    = 0;

            player.OnOpenSucceeded += (s, e) =>
            {
                player.Pause();
                int duration = player.GetDuration();
                unit = duration / 7;
                for (int i = 1; i < 7; i++)
                {
                    player.SetPosition(unit * i);
                    Thread.Sleep(1000);
                    player.SetConfig(APlayerSnapshotConfig.SnapshotImage.GetHashCode(), imgPath + i + ".jpg");
                }
                player.Dispose();
                form.Dispose();
            };

            player.Open(mtv.SavePath.Replace("~", PathHelper.GetDownloadDir(Guid.Parse(mtv.Id))));
        }
Beispiel #4
0
        public static void BeginDownload()
        {
            List <DownloadInfo> DownloadQeueu = KTVStatus.RunTimeData.DownloadQueue;

            lock (DownloadQeueu)
            {
                foreach (DownloadInfo di in DownloadQeueu.OrderBy(m => m.Sort))
                {
                    if (di.IsDownloading || di.IsCompelet)
                    {
                        continue;
                    }
                    if (di.DownloadType == KTVEnum.MTVDownloadType.Server ||
                        (di.DownloadType == KTVEnum.MTVDownloadType.Cloud && DownloadQeueu.Where(m => m.DownloadType == KTVEnum.MTVDownloadType.Cloud).All(m => m.IsDownloading == false)))
                    {
                        WebClient client = new WebClient();
                        if (di.ProcessChange != null)
                        {
                            client.DownloadProgressChanged += di.ProcessChange;
                        }
                        if (di.Complete != null)
                        {
                            client.DownloadFileCompleted += di.Complete;
                        }
                        client.DownloadFileCompleted += (sender, e) =>
                        {
                            di.IsDownloading = false;
                            di.IsCompelet    = true;
                            using (var db = new KTVDataBase())
                            {
                                var entity = new MyMTV()
                                {
                                    Id            = di.MTV.Id.ToString(),
                                    Artist        = di.MTV.Artist,
                                    CloudDiskUrl  = di.MTV.CloudDiskUrl,
                                    DetailUrl     = di.MTV.DetailUrl,
                                    ED2KUrl       = di.MTV.ED2KUrl,
                                    FileName      = di.MTV.MTVName + "-" + di.MTV.Artist + ".mkv",
                                    MTVImage      = di.MTV.MTVImage,
                                    MTVName       = di.MTV.MTVName,
                                    SavePath      = di.SavePath,
                                    MTVSize       = di.MTV.MTVSize,
                                    ServerUrl     = di.MTV.ServerUrl,
                                    SouceFileName = di.MTV.SouceFileName
                                };
                                db.MyMTV.Add(entity);
                                db.SaveChanges();
                                VideoScreenShot.ShotMTV(entity);
                            }
                            BeginDownload();
                        };
                        if (di.DownloadType == KTVEnum.MTVDownloadType.Cloud)
                        {
                            di.WebUrl = di.MTV.CloudDiskUrl;
                        }
                        if (di.DownloadType == KTVEnum.MTVDownloadType.Server)
                        {
                            di.WebUrl = di.MTV.ServerUrl;
                        }
                        di.IsDownloading = true;
                        client.DownloadFileAsync(new Uri(di.WebUrl), di.SavePath.Replace("~", PathHelper.GetDownloadDir(di.MTV.Id)));
                    }
                }
            }
        }