/// <summary> /// Constructs and initializes a new instance of <see /// cref="AppleTag" /> for a specified ISO user data box. /// </summary> /// <param name="box"> /// A <see cref="IsoUserDataBox" /> from which the tag is to /// be read. /// </param> public AppleTag(IsoUserDataBox box) { if (box == null) { throw new ArgumentNullException("box"); } meta_box = box.GetChild(BoxType.Meta) as IsoMetaBox; if (meta_box == null) { meta_box = new IsoMetaBox("mdir", null); box.AddChild(meta_box); } ilst_box = meta_box.GetChild(BoxType.Ilst) as AppleItemListBox; if (ilst_box == null) { ilst_box = new AppleItemListBox(); meta_box.AddChild(ilst_box); } }
/// <summary> /// Reads the file with a specified read style. /// </summary> /// <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> private void Read(ReadStyle propertiesStyle) { // TODO: Support Id3v2 boxes!!! tag = new CombinedTag(); Mode = AccessMode.Read; try { FileParser parser = new FileParser(this); if (propertiesStyle == ReadStyle.None) { parser.ParseTag(); } else { parser.ParseTagAndProperties(); } InvariantStartPosition = parser.MdatStartPosition; InvariantEndPosition = parser.MdatEndPosition; udta_box = parser.UserDataBox; if (udta_box != null && udta_box.GetChild(BoxType.Meta) != null && udta_box.GetChild(BoxType.Meta ).GetChild(BoxType.Ilst) != null) { TagTypesOnDisk |= TagTypes.Apple; } if (udta_box == null) { udta_box = new IsoUserDataBox(); } apple_tag = new AppleTag(udta_box); tag.SetTags(apple_tag); // If we're not reading properties, we're done. if (propertiesStyle == ReadStyle.None) { Mode = AccessMode.Closed; return; } // Get the movie header box. IsoMovieHeaderBox mvhd_box = parser.MovieHeaderBox; if (mvhd_box == null) { Mode = AccessMode.Closed; throw new CorruptFileException( "mvhd box not found."); } IsoAudioSampleEntry audio_sample_entry = parser.AudioSampleEntry; IsoVisualSampleEntry visual_sample_entry = parser.VisualSampleEntry; // Read the properties. properties = new Properties(mvhd_box.Duration, audio_sample_entry, visual_sample_entry); } finally { Mode = AccessMode.Closed; } }
/// <summary> /// Reads the file with a specified read style. /// </summary> /// <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> private void Read (ReadStyle propertiesStyle) { // TODO: Support Id3v2 boxes!!! tag = new CombinedTag (); Mode = AccessMode.Read; try { FileParser parser = new FileParser (this); if (propertiesStyle == ReadStyle.None) parser.ParseTag (); else parser.ParseTagAndProperties (); InvariantStartPosition = parser.MdatStartPosition; InvariantEndPosition = parser.MdatEndPosition; udta_box = parser.UserDataBox; if (udta_box != null && udta_box.GetChild (BoxType.Meta) != null && udta_box.GetChild (BoxType.Meta ).GetChild (BoxType.Ilst) != null) TagTypesOnDisk |= TagTypes.Apple; if (udta_box == null) udta_box = new IsoUserDataBox (); apple_tag = new AppleTag (udta_box); tag.SetTags (apple_tag); // If we're not reading properties, we're done. if (propertiesStyle == ReadStyle.None) { Mode = AccessMode.Closed; return; } // Get the movie header box. IsoMovieHeaderBox mvhd_box = parser.MovieHeaderBox; if(mvhd_box == null) { Mode = AccessMode.Closed; throw new CorruptFileException ( "mvhd box not found."); } IsoAudioSampleEntry audio_sample_entry = parser.AudioSampleEntry; IsoVisualSampleEntry visual_sample_entry = parser.VisualSampleEntry; // Read the properties. properties = new Properties (mvhd_box.Duration, audio_sample_entry, visual_sample_entry); } finally { Mode = AccessMode.Closed; } }