Reputation: 1099
I am playing audio with media element by converting text to speech in my app. here is my code
var synth = new SpeechSynthesizer();
var voice=SpeechSynthesizer.AllVoices;
synth.Voice = voice[2];
var text = "My name is John";
var stream = await synth.SynthesizeTextToStreamAsync(text);
var me = new MediaElement();
me.SetSource(stream, stream.ContentType);
me.Play();
Audio here being played is fast .I want that audio should play slowly. I tried Playback property of media element but its does not work.How to control speed of play back in media element?
Upvotes: 1
Views: 1482
Reputation: 11302
Use DefaultPlaybackRate
property:
var me = new MediaElement();
me.DefaultPlaybackRate = 0.5;
me.SetSource(stream, stream.ContentType);
me.Play();
You can also use PlaybackRate
property if you don't want it to persist throughout the lifetime of the MediaElement
. This happens because PlaybackRate
will have DefaultPlaybackRate
value when Play
method is called till playback ends.
Upvotes: 2