private void WaveFormPlayButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                double timeInSeconds = (double)startTimeOffset / 1000;
                using(AsfStream asfStream = new AsfStream(AsfStreamType.asfAudio, ViewModelLocator.MainStatic.FileName, timeInSeconds))
                using (AsfAudio asfAudio = new AsfAudio(asfStream))
                {
                    //play a two second sample
                    byte[] data = asfAudio.GetSampleBytes(2 * (int)  asfStream.Configuration.AudioSampleRate  * asfStream.Configuration.AudioChannels);

                    WaveMemoryStream mwav = new WaveMemoryStream(data, (int)asfStream.Configuration.AudioSampleRate, asfStream.Configuration.AudioBitsPerSample, asfStream.Configuration.AudioChannels);
                    SoundPlayer sp = new SoundPlayer(mwav);
                    sp.Play();
                }
            }
            catch (AsfStreamException) { }
        }
Example #2
0
        public void GetAudioSamples()
        {
            AsfStream asfStream = new AsfStream(AsfStreamType.asfAudio, testVideoFileName, 1.0, 10.0);
            AsfAudio asfAudio = new AsfAudio(asfStream);
            int requestedSampleCount = 10000;

            byte[] data = asfAudio.GetSampleBytes(requestedSampleCount);
            Assert.AreEqual(requestedSampleCount, data.Length);
        }