Пример #1
0
 /// <summary>
 /// 从文件中读取设置(不刷新用户界面)
 /// </summary>
 /// <param name="filePath"></param>
 private void LoadConfigFromFile(string filePath)
 {
     try
     {
         using (var fs = new FileStream(filePath, FileMode.Open))
         {
             XmlSerializer s = new XmlSerializer(typeof(AcPlayConfiguration));
             config = (AcPlayConfiguration)s.Deserialize(fs);
         }
     }
     catch
     {
         MessageBox.Show("配置文件读取失败", "AcPlay", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Пример #2
0
        /// <summary>
        /// 生成acplay配置文件
        /// </summary>
        /// <param name="pr">Parser的解析结果</param>
        /// <param name="title">文件标题</param>
        private string GenerateAcplayConfig(ParseResult pr)
        {
            if (Tools.IsRunningOnMono)
            {
                return("");
            }
            try
            {
                //生成新的配置
                var c = new AcPlayConfiguration
                {
                    PlayerName      = "acfun",
                    PlayerUrl       = Info.Settings["PlayerUrl"],
                    HttpServerPort  = 7776,
                    ProxyServerPort = 7777,
                    Videos          = new Video[Info.FilePath.Count],
                    WebUrl          = Info.Url
                };
                for (int i = 0; i < Info.FilePath.Count; i++)
                {
                    c.Videos[i]          = new Video();
                    c.Videos[i].FileName = Path.GetFileName(Info.FilePath[i]);
                    if (pr != null)
                    {
                        if (pr.Items[i].Information.ContainsKey("length"))
                        {
                            c.Videos[i].Length = int.Parse(pr.Items[i].Information["length"]);
                        }
                    }
                    if (pr != null)
                    {
                        if (pr.Items[i].Information.ContainsKey("order"))
                        {
                            c.Videos[i].Order = int.Parse(pr.Items[i].Information["order"]);
                        }
                    }
                }
                //弹幕
                c.Subtitles = new string[Info.SubFilePath.Count];
                for (int i = 0; i < Info.SubFilePath.Count; i++)
                {
                    c.Subtitles[i] = Path.GetFileName(Info.SubFilePath[i]);
                }
                //其他
                c.ExtraConfig = new SerializableDictionary <string, string>();
                if (pr != null)
                {
                    if (pr.SpecificResult.ContainsKey("totallength"))                     //totallength
                    {
                        c.ExtraConfig.Add("totallength", pr.SpecificResult["totallength"]);
                    }
                }
                if (pr != null)
                {
                    if (pr.SpecificResult.ContainsKey("src"))                     //src
                    {
                        c.ExtraConfig.Add("src", pr.SpecificResult["src"]);
                    }
                }
                if (pr != null)
                {
                    if (pr.SpecificResult.ContainsKey("framecount"))                     //framecount
                    {
                        c.ExtraConfig.Add("framecount", pr.SpecificResult["framecount"]);
                    }
                }

                //配置文件的生成地址
                var    renamehelper = new CustomFileNameHelper();
                string filename     = renamehelper.CombineFileName(m_customFileName,
                                                                   m_videoTitle, m_currentPartTitle, "", "acplay", m_acNumber, m_acSubNumber);
                filename = Path.Combine(Info.SaveDirectory.ToString(), filename);
                Info.FilePath.Add(filename);
                //string path = Path.Combine(Info.SaveDirectory.ToString(), title + ".acplay");
                //序列化到文件中
                using (var fs = new FileStream(filename, FileMode.Create))
                {
                    var s = new XmlSerializer(typeof(AcPlayConfiguration));
                    s.Serialize(fs, c);
                }
                return(filename);
            }
            catch
            {
                return("");
            }
        }
Пример #3
0
        /// <summary>
        /// 生成acplay配置文件
        /// </summary>
        /// <param name="pr">Parser的解析结果</param>
        /// <param name="title">文件标题</param>
        private string GenerateAcplayConfig(ParseResult pr, string title)
        {
            try
            {
                //生成新的配置
                AcPlayConfiguration c = new AcPlayConfiguration();
                //播放器
                c.PlayerName = "acfun";
                //播放器地址
                c.PlayerUrl = Info.Settings["PlayerUrl"];
                //端口
                c.HttpServerPort  = 7776;
                c.ProxyServerPort = 7777;
                //视频
                c.Videos = new Video[Info.FilePath.Count];
                for (int i = 0; i < Info.FilePath.Count; i++)
                {
                    c.Videos[i]          = new Video();
                    c.Videos[i].FileName = Path.GetFileName(Info.FilePath[i]);
                    if (pr != null)
                    {
                        if (pr.Items[i].Information.ContainsKey("length"))
                        {
                            c.Videos[i].Length = int.Parse(pr.Items[i].Information["length"]);
                        }
                    }
                    if (pr != null)
                    {
                        if (pr.Items[i].Information.ContainsKey("order"))
                        {
                            c.Videos[i].Order = int.Parse(pr.Items[i].Information["order"]);
                        }
                    }
                }
                //弹幕
                c.Subtitles = new string[Info.SubFilePath.Count];
                for (int i = 0; i < Info.SubFilePath.Count; i++)
                {
                    c.Subtitles[i] = Path.GetFileName(Info.SubFilePath[i]);
                }
                //其他
                c.ExtraConfig = new SerializableDictionary <string, string>();
                if (pr != null)
                {
                    if (pr.SpecificResult.ContainsKey("totallength"))                     //totallength
                    {
                        c.ExtraConfig.Add("totallength", pr.SpecificResult["totallength"]);
                    }
                }
                if (pr != null)
                {
                    if (pr.SpecificResult.ContainsKey("src"))                     //src
                    {
                        c.ExtraConfig.Add("src", pr.SpecificResult["src"]);
                    }
                }
                if (pr != null)
                {
                    if (pr.SpecificResult.ContainsKey("framecount"))                     //framecount
                    {
                        c.ExtraConfig.Add("framecount", pr.SpecificResult["framecount"]);
                    }
                }

                //配置文件的生成地址
                var    renamehelper = new CustomFileNameHelper();
                string filename     = renamehelper.CombineFileName(Settings["CustomFileName"],
                                                                   title, "", "", "acplay", Info.Settings["ACNumber"], Info.Settings["ACSubNumber"]);
                filename = Path.Combine(Info.SaveDirectory.ToString(), filename);
                //string path = Path.Combine(Info.SaveDirectory.ToString(), title + ".acplay");
                //序列化到文件中
                using (var fs = new FileStream(filename, FileMode.Create))
                {
                    XmlSerializer s = new XmlSerializer(typeof(AcPlayConfiguration));
                    s.Serialize(fs, c);
                }
                return(filename);
            }
            catch
            {
                return("");
            }
        }
Пример #4
0
		/// <summary>
		/// 从文件中读取设置(不刷新用户界面)
		/// </summary>
		/// <param name="filePath"></param>
		private void LoadConfigFromFile(string filePath)
		{
			try
			{
				using (var fs = new FileStream(filePath, FileMode.Open))
				{
					XmlSerializer s = new XmlSerializer(typeof(AcPlayConfiguration));
					config = (AcPlayConfiguration)s.Deserialize(fs);
				}
			}
			catch
			{
				MessageBox.Show("配置文件读取失败", "AcPlay", MessageBoxButtons.OK, MessageBoxIcon.Error);
				throw;
			}
		}
Пример #5
0
        private string GenerateAcplayConfig(ParseResult pr, string title)
        {
            if (Tools.IsRunningOnMono)
            {
                return("");
            }
            try
            {
                //生成新的配置
                AcPlayConfiguration c = new AcPlayConfiguration();
                //播放器
                c.PlayerName = "acfun";
                //播放器地址 (使用acfun播放器)
                c.PlayerUrl = "http://static.acfun.tv/player/ACFlashPlayer.201209271950.swf";
                //端口
                c.HttpServerPort  = 7776;
                c.ProxyServerPort = 7777;
                //视频
                c.Videos = new Video[Info.FilePath.Count];
                for (int i = 0; i < Info.FilePath.Count; i++)
                {
                    c.Videos[i]          = new Video();
                    c.Videos[i].FileName = Path.GetFileName(Info.FilePath[i]);
                    if (pr != null)
                    {
                        if (pr.Items[i].Information.ContainsKey("length"))
                        {
                            c.Videos[i].Length = int.Parse(pr.Items[i].Information["length"]);
                        }
                    }
                    if (pr != null)
                    {
                        if (pr.Items[i].Information.ContainsKey("order"))
                        {
                            c.Videos[i].Order = int.Parse(pr.Items[i].Information["order"]);
                        }
                    }
                }
                //弹幕
                c.Subtitles = new string[Info.SubFilePath.Count];
                for (int i = 0; i < Info.SubFilePath.Count; i++)
                {
                    c.Subtitles[i] = Path.GetFileName(Info.SubFilePath[i]);
                }
                //其他
                c.ExtraConfig = new SerializableDictionary <string, string>();
                if (pr != null)
                {
                    if (pr.SpecificResult.ContainsKey("totallength"))                     //totallength
                    {
                        c.ExtraConfig.Add("totallength", pr.SpecificResult["totallength"]);
                    }
                }
                if (pr != null)
                {
                    if (pr.SpecificResult.ContainsKey("src"))                     //src
                    {
                        c.ExtraConfig.Add("src", pr.SpecificResult["src"]);
                    }
                }
                if (pr != null)
                {
                    if (pr.SpecificResult.ContainsKey("framecount"))                     //framecount
                    {
                        c.ExtraConfig.Add("framecount", pr.SpecificResult["framecount"]);
                    }
                }


                string path = Path.Combine(Info.SaveDirectory.ToString(), title + ".acplay");
                //序列化到文件中
                using (var fs = new FileStream(path, FileMode.Create))
                {
                    XmlSerializer s = new XmlSerializer(typeof(AcPlayConfiguration));
                    s.Serialize(fs, c);
                }
                return(title);
            }
            catch
            {
                return("");
            }
        }