public void SetUp() { string directory = TestUtilities.GetTestFileDirectory(); string fileName = Path.Combine(directory, "TVEpisode.m4v"); this.file = MP4File.Open(fileName); }
public Mp4Data(string path) { var file = MP4File.Open(path); if (file.Chapters == null) { return; } Chapter = new ChapterInfo(); var index = 0; foreach (var chapterClip in file.Chapters) { Chapter.Chapters.Add(new Chapter(chapterClip.Title, Chapter.Duration, ++index)); Chapter.Duration += chapterClip.Duration; } }
private void RunSetValueTest(string propertyName, object expectedPropertyValue) { // We're going to use reflection to test setting of properties, so that // we can avoid massive amounts of duplicated code. The reflection code // below is equivalent of running the below code with ".PropertyName" // replaced by the actual property name. // // this.file.PropertyName = expectedPropertyValue; // this.file.WriteTags(); // this.file = new MP4File(fileCopy); // this.file.ReadTags(); // if (expectedPropertyValue == null) // { // Assert.IsNull(this.file.PropertyName); // } // else // { // Assert.AreEqual(expectedPropertyValue, this.file.PropertyName); // } PropertyInfo propInfo = this.file.Tags.GetType().GetProperty(propertyName); if (propInfo == null) { throw new InvalidOperationException("No property on the object with the name " + propertyName); } object originalValue = propInfo.GetValue(this.file.Tags, null); propInfo.SetValue(this.file.Tags, expectedPropertyValue, null); this.file.Save(); this.file = MP4File.Open(this.fileCopy); propInfo = this.file.Tags.GetType().GetProperty(propertyName); if (expectedPropertyValue == null) { Assert.IsNull(propInfo.GetValue(this.file.Tags, null)); } else { Assert.AreEqual(expectedPropertyValue, propInfo.GetValue(this.file.Tags, null)); } }
public void Read() { this.file = MP4File.Open(fileCopy); }
public void ShouldNotAllowFileNameWhichDoesNotExist() { MP4File file = MP4File.Open(@"C:\This\Path\Does\Not\Exist\Nor\Does\This\File.m4v"); }
public void ShouldNotAllowEmptyStringFileName() { MP4File file = MP4File.Open(string.Empty); }
public void ShouldNotAllowNullFileName() { MP4File file = MP4File.Open(null); }
private void goButton_Click(object sender, RoutedEventArgs e) { this.Cursor = Cursors.Wait; try { foreach (object item in this.episodeListDataGrid.Items) { FileMetaDataInfo infoItem = item as FileMetaDataInfo; if (!string.IsNullOrEmpty(infoItem.LocalFileName) && infoItem.UpdateFile) { MP4File currentFile = MP4File.Open(infoItem.LocalFileName); currentFile.Tags.Album = this.albumTextBox.Text; currentFile.Tags.AlbumArtist = this.showTextBox.Text; currentFile.Tags.Artist = this.showTextBox.Text; currentFile.Tags.TVShow = this.showTextBox.Text; currentFile.Tags.SeasonNumber = int.Parse(this.seasonNumberTextBox.Text); currentFile.Tags.EpisodeNumber = infoItem.Metadata.TrackNumber; currentFile.Tags.Title = infoItem.Metadata.TrackName; currentFile.Tags.TrackNumber = Convert.ToInt16(infoItem.Metadata.TrackNumber); currentFile.Tags.TotalTracks = Convert.ToInt16(infoItem.Metadata.TrackCount); currentFile.Tags.DiscNumber = Convert.ToInt16(infoItem.Metadata.DiscNumber); currentFile.Tags.TotalDiscs = Convert.ToInt16(infoItem.Metadata.DiscCount); currentFile.Tags.Description = infoItem.Metadata.ShortDescription; currentFile.Tags.LongDescription = infoItem.Metadata.LongDescription; currentFile.Tags.EpisodeId = string.Format("S{0}E{1}", this.seasonNumberTextBox.Text, infoItem.Metadata.TrackNumber); System.Drawing.Image artwork = System.Drawing.Image.FromFile(this.artworkFile); currentFile.Tags.Artwork = artwork; if (this.albumTextBox.Text.StartsWith("a ", StringComparison.InvariantCultureIgnoreCase) || this.albumTextBox.Text.StartsWith("an ", StringComparison.InvariantCultureIgnoreCase) || this.albumTextBox.Text.StartsWith("the ", StringComparison.InvariantCultureIgnoreCase)) { string sortAlbumValue = this.albumTextBox.Text.Substring(this.albumTextBox.Text.IndexOf(' ') + 1); currentFile.Tags.SortAlbum = sortAlbumValue; } if (this.showTextBox.Text.StartsWith("a ", StringComparison.InvariantCultureIgnoreCase) || this.showTextBox.Text.StartsWith("an ", StringComparison.InvariantCultureIgnoreCase) || this.showTextBox.Text.StartsWith("the ", StringComparison.InvariantCultureIgnoreCase)) { string sortShowValue = this.showTextBox.Text.Substring(this.showTextBox.Text.IndexOf(' ') + 1); currentFile.Tags.SortTVShow = sortShowValue; currentFile.Tags.SortArtist = sortShowValue; currentFile.Tags.SortAlbumArtist = sortShowValue; } if (infoItem.Metadata.TrackName.StartsWith("a ", StringComparison.InvariantCultureIgnoreCase) || infoItem.Metadata.TrackName.StartsWith("an ", StringComparison.InvariantCultureIgnoreCase) || infoItem.Metadata.TrackName.StartsWith("the ", StringComparison.InvariantCultureIgnoreCase)) { string sortNameValue = infoItem.Metadata.TrackName.Substring(infoItem.Metadata.TrackName.IndexOf(' ') + 1); currentFile.Tags.SortName = sortNameValue; } currentFile.Tags.ContentId = infoItem.Metadata.TrackId; currentFile.Tags.ReleaseDate = infoItem.Metadata.ReleaseDate.ToString("yyyy-MM-dd"); currentFile.Tags.MediaType = MediaKind.TVShow; currentFile.Save(); infoItem.UpdateFile = false; } } this.episodeListDataGrid.Items.Refresh(); } finally { this.Cursor = null; } }