I'm trying to write code to read aloud an incoming Toast (this was trivial in WP8.1) I have this so far
- Using MediaElement doesn't seem to work (code runs but no audio) either on the phone or in the emulator
- Using BackgroundMediaPlayer works in the emulator but not on the phone
I've tried both from the UI thread (MediaElement only works on the UI thread) and BackgroundMediaPlayer from the thread that handles the incoming toast
var mediaElement = new MediaElement();
using (var tts = new SpeechSynthesizer())
{
using (var ttsStream = await tts.SynthesizeSsmlToStreamAsync(ssml))
{
//BackgroundMediaPlayer.Current.SetStreamSource(ttsStream);
mediaElement.SetSource(ttsStream, ttsStream.ContentType);
mediaElement.Play();
}
}
I'm obviously missing something simple here but I'm out of ideas how to make this work. The SSML is correct, I think it's probably something to do with scoping and threads