How to play Windows Phone 8 SpeechSynthesizer during lock screen?

149 Views Asked by At

I have the following code to synthesize text to speech in a Windows Phone 8 application, however I can't seem to figure out how to have it continuously play during lock screen/screen off/or in the background. Does anyone have a suggestion or snippit of code on how to do this?

SpeechSynthesizer synth = new SpeechSynthesizer();
await synth.SpeakTextAsync("Text to read during screen off/lock screen/background");
2

There are 2 best solutions below

0
On BEST ANSWER

It is just an suggestion, but why don't you simply allow you app to run under lock screen.

In Application_Launching and Application_Activated events just add:

PhoneApplicationService.Current.ApplicationIdleDetectionMode = IdleDetectionMode.Disabled;
0
On

I don't think you can do it directly.

You may be able to do it by playing background audio in your app, and using the SpeechSynthesizer.SetOutputToWaveFile and then schedule that to play in the background.

However, you still have to keep your app alive somehow, as WP will want to suspend it unless you have some other thing going on (like background location tracking).