コード例 #1
0
ファイル: AacReader.cs プロジェクト: rdingwall/mixplanner
        public bool TryRead(string filename, out Tag tag)
        {
            if (filename == null) throw new ArgumentNullException("filename");

            try
            {
                var file = new File(filename);

                LogWarnings(filename, file);

                var t = new Tag();
                PopulateFromTag(file, t);
                PopulateFallbackValues(t);

                if (file.Properties != null)
                    t.Duration = file.Properties.Duration;

                tag = t;
                return true;
            }
            catch (Exception e)
            {
                Log.Error(String.Format("Error reading M4A tag from {0}.", filename), e);
                tag = null;
                return false;
            }
        }
コード例 #2
0
ファイル: AacReader.cs プロジェクト: rdingwall/mixplanner
        static void LogWarnings(string filename, File file)
        {
            if (!file.PossiblyCorrupt)
                return;

            foreach (var reason in file.CorruptionReasons)
                Log.WarnFormat("{0} is possibly corrupt: {1}", filename, reason);
        }
コード例 #3
0
ファイル: AacReader.cs プロジェクト: rdingwall/mixplanner
        static byte[] GetImageData(File file)
        {
            var picture = file.Tag.Pictures.FirstOrDefault(p => p.Description.Contains("FrontCover")) ??
                          file.Tag.Pictures.FirstOrDefault();

            if (picture == null)
                return null;

            return picture.Data.Data;
        }
コード例 #4
0
ファイル: AacReader.cs プロジェクト: rdingwall/mixplanner
        void PopulateFromTag(File file, Tag tag)
        {
            //if (!file.TagTypes.HasFlag(TagTypes.Id3v2))
            //    return;

            tag.ImageData = GetImageData(file);

            // ID3v2 Tags Reference: http://id3.org/id3v2.4.0-frames
            tag.Artist = JoinPerformers(file.Tag.Performers);
            tag.Title = file.Tag.Title;
            tag.Year = ToStringOrDefault(file.Tag.Year);
            tag.Genre = file.Tag.JoinedGenres;
            tag.Publisher = file.Tag.Grouping;
            tag.Bpm = ToStringOrDefault(file.Tag.BeatsPerMinute);
        }
コード例 #5
0
ファイル: File.cs プロジェクト: joconno4/MediaPortal-2
		/// <summary>
		///    Constructs and initializes a new instance of <see
		///    cref="File" /> for a specified file abstraction with an
		///    average read style.
		/// </summary>
		/// <param name="abstraction">
		///    A <see cref="IFileAbstraction" /> object to use when
		///    reading from and writing to the file.
		/// </param>
		/// <exception cref="ArgumentNullException">
		///    <paramref name="abstraction" /> is <see langword="null"
		///    />.
		/// </exception>
		public File (File.IFileAbstraction abstraction)
			: this (abstraction, ReadStyle.Average)
		{
		}
コード例 #6
0
ファイル: File.cs プロジェクト: joconno4/MediaPortal-2
		/// <summary>
		///    Constructs and initializes a new instance of <see
		///    cref="File" /> for a specified file abstraction and
		///    specified read style.
		/// </summary>
		/// <param name="abstraction">
		///    A <see cref="IFileAbstraction" /> object to use when
		///    reading from and writing to the file.
		/// </param>
		/// <param name="propertiesStyle">
		///    A <see cref="ReadStyle" /> value specifying at what level
		///    of accuracy to read the media properties, or <see
		///    cref="ReadStyle.None" /> to ignore the properties.
		/// </param>
		/// <exception cref="ArgumentNullException">
		///    <paramref name="abstraction" /> is <see langword="null"
		///    />.
		/// </exception>
		public File (File.IFileAbstraction abstraction,
		                ReadStyle propertiesStyle)
		: base (abstraction)
		{
			Read (propertiesStyle);
		}
コード例 #7
0
		/// <summary>
		///    Overwrites the existing box in the file after updating
		///    the table for a size change.
		/// </summary>
		/// <param name="file">
		///    A <see cref="File" /> object containing the file to which
		///    the current instance belongs and wo which modifications
		///    must be applied.
		/// </param>
		/// <param name="sizeDifference">
		///    A <see cref="long" /> value containing the size
		///    change that occurred in the file.
		/// </param>
		/// <param name="after">
		///    A <see cref="long" /> value containing the position in
		///    the file after which offsets will be invalidated. If an
		///    offset is before this point, it won't be updated.
		/// </param>
		/// <exception cref="ArgumentNullException">
		///    <param name="file" /> is <see langword="null" />.
		/// </exception>
		public void Overwrite (File file, long sizeDifference,
		                       long after)
		{
			if (file == null)
				throw new ArgumentNullException ("file");
			
			file.Insert (Render (sizeDifference, after),
				Header.Position, Size);
		}