예제 #1
0
 public async Task PlayAudio(string uri)
 {
     using (var client = new HttpClient())
         using (var stream = await client.GetStreamAsync(uri))
             using (var memstream = new MemoryStream())
             {
                 stream.CopyTo(memstream);
                 memstream.Position = 0;
                 using (var accessStream = memstream.AsRandomAccessStream())
                 {
                     await _audioPlayer.PlayStreamAsync(accessStream);
                 }
             }
 }
        public static async Task SpeakTextAsync(this MediaElement mediaElement, string text)
        {
            using (SpeechSynthesizer synthesizer = new SpeechSynthesizer())
            {
                var stream = await synthesizer.SynthesizeTextToStreamAsync(text);

                await mediaElement.PlayStreamAsync(stream, true);
            }
        }
        async Task SpeakTextAsync(string text, MediaElement mediaElement)
        {
            //TODO: ARS use link below to stop async tasks
            //https://stackoverflow.com/questions/15614991/simply-stop-an-async-method

            //if(TgsRepeats.IsOn)
            //{
            //    BtnStopPauseRepeatMediaOutAsync.Visibility = Visibility.Visible;
            //    BtnRepeatMediaOutAsync.Visibility = Visibility.Collapsed;
            //    stpStatus.Visibility = Visibility.Visible;
            //}
            IRandomAccessStream stream = await this.SynthesizeTextToSpeechAsync(text);

            await mediaElement.PlayStreamAsync(stream, true);
        }
예제 #4
0
        public async Task SpeakTextAsync(string text, MediaElement mediaElement)
        {
            IRandomAccessStream stream = await SynthesizeTextToSpeechAsync(text);

            await mediaElement.PlayStreamAsync(stream, true);
        }