예제 #1
0
        //合并视频
        private void btnCombineStart_Click(object sender, EventArgs e)
        {
            //检查文件是否存在
            if (!VideoCombineHelper.CheckFileExists())
            {
                if (MessageBox.Show("尚未安装视频合并所需要的插件," +
                                    Environment.NewLine +
                                    "是否立即下载?", "视频合并插件"
                                    , MessageBoxButtons.YesNo, MessageBoxIcon.Information)
                    == DialogResult.Yes)
                {
                    Process.Start(@"https://acdown.codeplex.com/wikipage?title=%e8%a7%86%e9%a2%91%e5%90%88%e5%b9%b6%e6%8f%92%e4%bb%b6");
                }
                //Clipboard.SetText("视频合并插件");
                return;
            }
            panelCombine.Enabled = false;
            btnCombineStart.Text = "视频正在合并中,过一会儿再回来看看吧";
            //数组参数
            List <string> l = new List <string>();

            foreach (string item in lstCombine.Items)
            {
                l.Add(item);
            }
            //使用新线程合并视频
            Thread t = new Thread(() =>
            {
                bool result = rdoFlv.Checked ?
                              CombineFlvFile(txtCombineOutput.Text, l.ToArray()) :
                              new VideoCombineHelper().Combine(l.ToArray(), txtCombineOutput.Text, null);

                if (result)                 //合并成功
                {
                    MessageBox.Show("视频合并成功ヾ(●゜ⅴ゜)ノ" + Environment.NewLine + txtCombineOutput.Text, "合并视频", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.ServiceNotification);
                }
                else                 //合并失败
                {
                    MessageBox.Show("啊喔,视频合并失败了ヾ(´・ω・`)ノ。", "合并视频", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1, MessageBoxOptions.ServiceNotification);
                }

                //恢复控件的状态
                this.Invoke(new MethodInvoker(() =>
                {
                    panelCombine.Enabled = true;
                    btnCombineStart.Text = "开始合并";
                }));
            });

            //启动线程
            t.Start();
        }
예제 #2
0
        /// <summary>
        /// 合并Flv视频
        /// </summary>
        /// <param name="fileName"></param>
        /// <param name="fileParts"></param>
        /// <returns></returns>
        public bool CombineFlvFile(string fileName, string[] fileParts)
        {
            string appdata      = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
            string file_flvbind = Path.Combine(appdata, "Kaedei" + Path.DirectorySeparatorChar + "FlvCombine" + Path.DirectorySeparatorChar + "FlvBind.exe");
            string file_flvlib  = Path.Combine(appdata, "Kaedei" + Path.DirectorySeparatorChar + "FlvCombine" + Path.DirectorySeparatorChar + "FLVLib.dll");

            //如果文件不存在则释放文件
            if (!File.Exists(file_flvbind) || !File.Exists(file_flvlib))
            {
                var helper = new VideoCombineHelper();
                helper.ReleaseFlvCombineFile();
            }

            //生成ProcessStartInfo
            ProcessStartInfo pinfo = new ProcessStartInfo(file_flvbind);
            //设置参数
            StringBuilder sb = new StringBuilder();

            sb.Append("\"" + fileName + "\"");
            foreach (string item in fileParts)
            {
                sb.Append(" \"" + item + "\"");
            }
            pinfo.Arguments = sb.ToString();
            //隐藏窗口
            pinfo.WindowStyle = ProcessWindowStyle.Hidden;
            //启动程序
            Process p = Process.Start(pinfo);

            p.WaitForExit();
            if (p.ExitCode == 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #3
0
파일: FormMain.cs 프로젝트: kwedr/acdown
		//合并视频
		private void toolCombineVideo_Click(object sender, EventArgs e)
		{
			if (!VideoCombineHelper.CheckFileExists())
			{
				var result = MessageBox.Show("尚未安装视频合并所需要的插件,是否立即下载?", "视频合并插件",
					MessageBoxButtons.YesNo, MessageBoxIcon.Question);
				if (result == System.Windows.Forms.DialogResult.Yes)
				{
					FormNew.ShowForm("视频合并插件");
				}
				return;
			}
			ListViewItem item = lsv.SelectedItems[0];
			TaskInfo task = GetTask(new Guid((string)item.Tag));
			new Thread(new ThreadStart(() =>
			{
				var arr = task.Settings["VideoCombine"].Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
				if (arr.Length >= 3)
				{
					task.Settings["VideoCombineInProgress"] = "true";
					string output = arr[arr.Length - 1];
					Array.Resize<string>(ref arr, arr.Length - 1);
					var helper = new VideoCombineHelper();
					helper.Combine(arr, output, (o) =>
					{
						this.Invoke(new Action<int>((progress) =>
						{
							item.SubItems[GetColumn("Name")].Text = "正在合并: " + progress.ToString() + "%";
						}), o);
					});
					task.Settings.Remove("VideoCombineInProgress");
				}

				//更新UI
				this.Invoke(new MethodInvoker(() =>
				{
					item.SubItems[GetColumn("Name")].Text = task.Title;
				}));
			})).Start();
			lsv.SelectedIndices.Clear();
		}
예제 #4
0
파일: FormMain.cs 프로젝트: kwedr/acdown
		}//end TipText

		/// <summary>
		/// 下载完成(需要判断下载完成还是用户手动停止)
		/// </summary>
		public void Finish(object e)
		{
			//非UI线程中执行
			ParaFinish p = (ParaFinish)e;
			TaskInfo task = p.SourceTask;
			ListViewItem item = (ListViewItem)task.UIItem;
			//如果下载成功
			if (p.Successed)
			{
				this.Invoke(new MethodInvoker(() =>
				{
					item.SubItems[GetColumn("Status")].Text = task.Status.ToString();
					item.SubItems[GetColumn("Progress")].Text = @"100.00%"; //下载进度
					item.SubItems[GetColumn("Speed")].Text = ""; //下载速度
				}));

				//视频合并 - 
				if (!Tools.IsRunningOnMono &&
					chkAutoCombine.Checked &&
					task.Settings.ContainsKey("VideoCombine"))
				{
					var arr = task.Settings["VideoCombine"].Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
					
					if (arr.Length >= 3)
					{
						task.Settings["VideoCombineInProgress"] = "true";
						string output = arr[arr.Length - 1];
						Array.Resize<string>(ref arr, arr.Length - 1);
						var helper = new VideoCombineHelper();
						helper.Combine(arr, output, (o) =>
							{
								this.Invoke(new Action<int>((progress) =>
									{
										item.SubItems[GetColumn("Name")].Text = "正在合并: " + progress.ToString() + "%";
									}), o);
							});
						task.Settings.Remove("VideoCombineInProgress");
					}
				}

				//更新UI
				this.Invoke(new MethodInvoker(() =>
					{
						item.SubItems[GetColumn("Name")].Text = task.Title;
					}));

				//打开文件夹
				if (CoreManager.ConfigManager.Settings.OpenFolderAfterComplete && !Tools.IsRunningOnMono)
					Process.Start(CoreManager.ConfigManager.Settings.SavePath);
				//播放声音
				if (CoreManager.ConfigManager.Settings.PlaySound)
				{
					try
					{
						System.Media.SoundPlayer player = new System.Media.SoundPlayer();
						//优先播放设置文件中的声音(必须是wav格式&忽略大小写)
						if (File.Exists(CoreManager.ConfigManager.Settings.SoundFile) && CoreManager.ConfigManager.Settings.SoundFile.EndsWith(".wav", StringComparison.CurrentCultureIgnoreCase))
						{
							player.SoundLocation = CoreManager.ConfigManager.Settings.SoundFile;
						}
						else
						{
							//然后播放程序目录下的msg.wav文件
							if (File.Exists(Path.Combine(Application.StartupPath, "msg.wav")))
							{
								player.SoundLocation = Path.Combine(Application.StartupPath, "msg.wav");
							}
							else //如果都没有则播放资源文件中的声音文件
							{
								player.Stream = Resources.remind;
							}
						}
						player.Load();
						player.Play();
						player.Dispose();
					}
					catch { }
				}
			}
			else //如果用户取消下载
			{
				if (item != null)
				{
					//更新item
					this.Invoke(new MethodInvoker(() =>
						{
							item.SubItems[GetColumn("Status")].Text = task.Status.ToString();
							item.SubItems[GetColumn("Speed")].Text = ""; //下载速度
						}));
				}
			}
			//移除item
			this.Invoke(new MethodInvoker(() =>
					{
						if (lsv.Items.Contains(item))
							if (!IsMatchCurrentFilter(task))
								lsv.Items.Remove(item);
					}));
		}
예제 #5
0
		/// <summary>
		/// 合并Flv视频
		/// </summary>
		/// <param name="fileName"></param>
		/// <param name="fileParts"></param>
		/// <returns></returns>
		public bool CombineFlvFile(string fileName, string[] fileParts)
		{
			string appdata = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
			string file_flvbind = Path.Combine(appdata, "Kaedei" + Path.DirectorySeparatorChar + "FlvCombine" + Path.DirectorySeparatorChar + "FlvBind.exe");
			string file_flvlib = Path.Combine(appdata, "Kaedei" + Path.DirectorySeparatorChar + "FlvCombine" + Path.DirectorySeparatorChar + "FLVLib.dll");

			//如果文件不存在则释放文件
			if (!File.Exists(file_flvbind) || !File.Exists(file_flvlib))
			{
				var helper = new VideoCombineHelper();
				helper.ReleaseFlvCombineFile();
			}

			//生成ProcessStartInfo
			ProcessStartInfo pinfo = new ProcessStartInfo(file_flvbind);
			//设置参数
			StringBuilder sb = new StringBuilder();
			sb.Append("\"" + fileName + "\"");
			foreach (string item in fileParts)
			{
				sb.Append(" \"" + item + "\"");
			}
			pinfo.Arguments = sb.ToString();
			//隐藏窗口
			pinfo.WindowStyle = ProcessWindowStyle.Hidden;
			//启动程序
			Process p = Process.Start(pinfo);
			p.WaitForExit();
			if (p.ExitCode == 0)
				return true;
			else
				return false;
		}