Beispiel #1
0
		/// <summary>
		/// Internal Constructor
		/// </summary>
		/// <param name="format">MediaFormatInfo</param>
		/// <param name="streams">list of MediaStreamInfo objects</param>
		internal MediaInfo(MediaFormatInfo format, IList<MediaStreamInfo> streams) {
			this.format = format;
			this.streams = streams;
		}
Beispiel #2
0
		/// <summary>
		/// Internal Constructor
		/// </summary>
		/// <param name="format">MediaFormatInfo</param>
		internal MediaInfo(MediaFormatInfo format) {
			this.format = format;
			streams = new List<MediaStreamInfo>();
		}
		/// <summary>
		/// Creates MediaFormatInfo from XmlDocument
		/// </summary>
		/// <param name="xmlDoc">XmlDocument containing data for creating MediaFormatInfo object.</param>
		/// <returns>MediaFormatInfo object</returns>
		public static MediaFormatInfo CreateFromXml(XmlDocument xmlDoc) {
			MediaFormatInfo mediaFormatInfo = null;

			if (xmlDoc.DocumentElement != null) {
				XmlNode formatNode = xmlDoc.DocumentElement.SelectSingleNode(FORMAT_NODE);

				if (formatNode != null && formatNode.Attributes != null) {
					var fileName = formatNode.Attributes[FILE_NAME] != null ? formatNode.Attributes[FILE_NAME].InnerText : null;
					var format = formatNode.Attributes[FORMAT] != null ? formatNode.Attributes[FORMAT].InnerText : null;

					if(fileName != null && format != null) {
						mediaFormatInfo = new MediaFormatInfo(fileName, format);

						if (formatNode.Attributes[FORMAT_LONG_NAME] != null) {
							mediaFormatInfo.FormatLongName = formatNode.Attributes[FORMAT_LONG_NAME].InnerText;
						}

						if(formatNode.Attributes[BIT_RATE] != null) {
							try {
								mediaFormatInfo.Bitrate = Decimal.Parse(formatNode.Attributes[BIT_RATE].InnerText, CultureInfo.InvariantCulture);	
							} catch(Exception) {
								mediaFormatInfo.Bitrate = 0;
							}
						}
						
						if(formatNode.Attributes[DURATION] != null) {
							try {
								mediaFormatInfo.Duration = Decimal.Parse(formatNode.Attributes[DURATION].InnerText, CultureInfo.InvariantCulture);		
							} catch(Exception) {
								mediaFormatInfo.Duration = 0;
							}
						}

						if (formatNode.Attributes[START_TIME] != null) {
							try {
								mediaFormatInfo.StartTime = Decimal.Parse(formatNode.Attributes[START_TIME].InnerText, CultureInfo.InvariantCulture);	
							} catch(Exception) {
								mediaFormatInfo.StartTime = 0;
							}
						}

						if (formatNode.Attributes[FILE_SIZE] != null) {
							try {
								mediaFormatInfo.FileSize = Decimal.Parse(formatNode.Attributes[FILE_SIZE].InnerText, CultureInfo.InvariantCulture);	
							} catch(Exception) {
								mediaFormatInfo.FileSize = 0;
							}
						}
						
					}

				}
			}

			return mediaFormatInfo;
		}