Example #1
0
        public async void Speak(string text)
        {
            var stream = await _synthesizer.SynthesizeTextToStreamAsync(text);

            _mediaElement.SetSource(stream, stream.ContentType);
            _mediaElement.Play();
        }
Example #2
0
 public static async Task PlaySound(string asset)
 {
     var mysong = new Windows.UI.Xaml.Controls.MediaElement();
     var folder = await (await Package.Current.InstalledLocation.GetFolderAsync("Assets")).GetFolderAsync("Audio");
     var file = await folder.GetFileAsync(asset);
     var stream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read);
     mysong.Volume = 1;
     mysong.SetSource(stream, file.ContentType);
     mysong.Play();
 }
        private async Task Speech()
        {
            using (var ss = new SpeechSynthesizer())
            {
                var stream = await ss.SynthesizeTextToStreamAsync(Model.InputMeaning);

                var mediaElement = new Windows.UI.Xaml.Controls.MediaElement();
                mediaElement.SetSource(stream, stream.ContentType);
                mediaElement.Play();
            }
        }
        public async void Speak(string text)
        {
            using (var speech = new SpeechSynthesizer())
            {
                var stream = await speech.SynthesizeTextToStreamAsync(text);

                var mediaElement = new Windows.UI.Xaml.Controls.MediaElement();
                mediaElement.SetSource(stream, stream.ContentType);
                mediaElement.Play();
            }
        }
Example #5
0
        public async void PlayAudioFile(string fileName)
        {
            var element = new Windows.UI.Xaml.Controls.MediaElement();
            var folder  = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFolderAsync("MyFolder");

            var file = await folder.GetFileAsync(fileName);

            var stream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read);

            element.SetSource(stream, "");
            element.Play();
        }
Example #6
0
        public static async Task PlaySound(string asset)
        {
            var mysong = new Windows.UI.Xaml.Controls.MediaElement();
            var folder = await(await Package.Current.InstalledLocation.GetFolderAsync("Assets")).GetFolderAsync("Audio");
            var file   = await folder.GetFileAsync(asset);

            var stream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read);

            mysong.Volume = 1;
            mysong.SetSource(stream, file.ContentType);
            mysong.Play();
        }
Example #7
0
        public async Task PlaySound()
        {
            MediaElement mysong = new MediaElement();

            Windows.Storage.StorageFolder folder = await Windows.ApplicationModel.Package
                                                   .Current.InstalledLocation.GetFolderAsync("Assets");

            Windows.Storage.StorageFile file = await folder.GetFileAsync("guitar-m.mp3");

            var stream = await file.OpenReadAsync();

            mysong.SetSource(stream, file.ContentType);
            mysong.Play();
        }
        //play a newly synthesized audio clip
        public async static Task SpeakContentAsync(IInputStream file)
        {
            InMemoryRandomAccessStream stream = new InMemoryRandomAccessStream();

            await RandomAccessStream.CopyAsync(file, stream);

            stream.Seek(0);

            Windows.UI.Xaml.Controls.MediaElement element = new Windows.UI.Xaml.Controls.MediaElement();
            element.SetSource(stream, "audio/x-wav");
            element.Play();

            return;
        }
Example #9
0
        protected override void DrawSegment()
        {
            // OMG this thingy were prerendered video :)

            if (!playing)
            {
                SecondRealityponyWinRT.GamePage gamePage = Windows.UI.Xaml.Window.Current.Content as SecondRealityponyWinRT.GamePage;
                videoPlayer = gamePage.TheVideoPlayer;
                videoPlayer.Source = new Uri("ms-appx:/Content/World.wmv", UriKind.Absolute);
                videoPlayer.Play();
                videoPlayer.MediaEnded += videoPlayer_MediaEnded;
                playing = true;
            }
        }