Exemplo n.º 1
0
		public WmvVideoStream(string filepath)
		{
			this.filepath = filepath;
			asf = new AsfFile(filepath);
			var audioStream = new AsfStream(asf, AsfStreamType.asfAudio, 0);
			soundStream = new AsfAudio(audioStream).GetWaveStream();
			video = new AsfImageLoader(asf);
		}
Exemplo n.º 2
0
		public WmaMusicStream(string filepath)
		{
			this.filepath = filepath;
			var asf = new AsfFile(filepath);
			Channels = asf.PacketConfiguration.AudioChannels;
			Samplerate = (int)asf.PacketConfiguration.AudioSampleRate;
			LengthInSeconds = (float)asf.PacketConfiguration.Duration;
			asf.Open();
			soundStream = new AsfAudio(new AsfStream(asf, AsfStreamType.asfAudio, 0)).GetWaveStream();
			asf.Close();
		}
Exemplo n.º 3
0
        public void CreatePlayableWaveMemoryStreamManual()
        {
            //WaveStreamFromFile
            using(AsfStream asfStream = new AsfStream(AsfStreamType.asfAudio, testVideoFileName, 1.0, 4.0))
            using (AsfAudio asfAudio = new AsfAudio(asfStream))
            {
                WaveMemoryStream waveMemoryStream = asfAudio.GetWaveStream();
                Assert.IsNotNull(waveMemoryStream);

                //Soundplayer will throw an exception if this is not a valid Wave stream
                SoundPlayer soundPlayer = new SoundPlayer(waveMemoryStream);
            }
        }
Exemplo n.º 4
0
        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) { }
        }
Exemplo n.º 5
0
        public void ComputeWaveForm(UInt32 presentationTime)
        {
            try
            {
                double timeInSeconds = presentationTime;
                timeInSeconds /= 1000;

                float[] samples;

                using (AsfStream asfStream = new AsfStream(AsfStreamType.asfAudio, ViewModelLocator.MainStatic.FileName, timeInSeconds))
                using (AsfAudio asfAudio = new AsfAudio(asfStream))
                {
                    int sampleCountForTwoSeconds = (int) (2 * asfStream.Configuration.AudioSampleRate);
                    samples = asfAudio.GetSamples(sampleCountForTwoSeconds).Select(sample => sample.Left).ToArray();
                }
                Dispatcher.BeginInvoke((Action)(() => DrawAudio(samples)));
            }
            catch (AsfStreamException) { }
        }
Exemplo n.º 6
0
 public static WaveMemoryStream FromFile(string fileName, double startOffset, double endOffset)
 {
     using (AsfStream asfStream = new AsfStream(AsfStreamType.asfAudio, fileName, startOffset, endOffset))
     using (AsfAudio asfAudio = new AsfAudio(asfStream))
         return asfAudio.GetWaveStream();
 }
Exemplo n.º 7
0
 public static WaveMemoryStream FromFile(string fileName, double startOffset, double endOffset)
 {
     using (AsfStream asfStream = new AsfStream(AsfStreamType.asfAudio, fileName, startOffset, endOffset))
         using (AsfAudio asfAudio = new AsfAudio(asfStream))
             return(asfAudio.GetWaveStream());
 }
Exemplo n.º 8
0
 public void IterateAudioSamples()
 {
     AsfStream asfStream = new AsfStream(AsfStreamType.asfAudio, testVideoFileName, 1.0, 10.0);
     AsfAudio asfAudio = new AsfAudio(asfStream);
     int requestedSampleCount = 10000;
     int receivedSampleCount = 0;
     foreach (AudioSample audioSample in asfAudio.GetSamples(requestedSampleCount))
     {
         receivedSampleCount++;
     }
     Assert.AreEqual(requestedSampleCount, receivedSampleCount);
 }
Exemplo n.º 9
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);
        }