コード例 #1
0
        private void btnReadFile_Click(object sender, RoutedEventArgs e)
        {
            string ccFilePath = textBoxInputFile.Text.Trim();

            if (!File.Exists(ccFilePath))
            {
                string message = "File doesn't exist";
                DisplayStatusInfo(message);
                return;
            }

            string fileExtension = System.IO.Path.GetExtension(ccFilePath);
            List <ClosedCaptionConverter.Library.ClosedCaption> listOfClosedCaptions = null;

            if (fileExtension.ToLower() == ".vtt")
            {
                VTTHandler vttHandler = new VTTHandler();
                listOfClosedCaptions = vttHandler.ReadFile(ccFilePath);
            }
            else if (fileExtension.ToLower() == ".srt")
            {
                SRTHandler srtHandler = new SRTHandler();
                listOfClosedCaptions = srtHandler.ReadFile(ccFilePath);
            }
            else if (fileExtension.ToLower() == ".ttml" || fileExtension.ToLower() == ".xml")
            {
                TTMLHandler ttmlHandler = new TTMLHandler();
                listOfClosedCaptions = ttmlHandler.ReadFile(ccFilePath);
            }
            else
            {
                string message = "Your selected file type doesn't support.";
                DisplayStatusInfo(message);
            }

            if (listOfClosedCaptions != null)
            {
                listViewClosedCaptions.ItemsSource = listOfClosedCaptions;
                string message = $"Transcript loads successfully, total {listOfClosedCaptions.Count} lines.";

                DisplayStatusInfo(message);
            }
        }
コード例 #2
0
        public void ReadFileTestMethod2()
        {
            string inputFile = @"TestData\WebVTT_sample2.vtt";
            int    expectedClosedCaptionCount = 17;
            string expectedLastStartPoint     = "00:00:02.633";
            string expectedLastTranscript     = @"Hello! I am Anusha Muthiah and welcome to week 2 of the Introduction to HTML5.";

            VTTHandler vttHandler = new VTTHandler();
            var        CCs        = vttHandler.ReadFile(inputFile);

            Assert.AreEqual(expectedClosedCaptionCount, CCs.Count);

            if (CCs.Count == 17)
            {
                string actualLastStartPoint = CCs[0].StartPoint;

                Assert.AreEqual(expectedLastStartPoint, actualLastStartPoint);

                string actualLastTranscript = CCs[0].Transcript;
                Assert.AreEqual(expectedLastTranscript, actualLastTranscript);
            }
        }
コード例 #3
0
        public void ReadFileTestMethod1()
        {
            string inputFile = @"TestData\WebVTT_sample1.vtt";
            int    expectedClosedCaptionCount = 43;
            string expectedLastStartPoint     = "00:03:03.806";
            string expectedLastTranscript     = @"A variable can be incremented or";

            VTTHandler vttHandler = new VTTHandler();
            var        CCs        = vttHandler.ReadFile(inputFile);

            Assert.AreEqual(expectedClosedCaptionCount, CCs.Count);

            if (CCs.Count == 43)
            {
                string actualLastStartPoint = CCs[41].StartPoint;

                Assert.AreEqual(expectedLastStartPoint, actualLastStartPoint);

                string actualLastTranscript = CCs[41].Transcript;
                Assert.AreEqual(expectedLastTranscript, actualLastTranscript);
            }
        }