예제 #1
0
 private void OnSourceCallbackChanged(object newValue)
 {
     if (newValue != null)
     {
         Element?.Play();
         _timer.Start();
     }
 }
예제 #2
0
 void PlaySound()
 {
     Task.Run(async() => {
         await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal,
                                                                                                     () =>
         {
             startTime             = lastRequestedTime;
             nextSequenceStepIndex = 0;
             currentSound?.Play();
         });
     });
     isPlayingSequence = true;
 }
예제 #3
0
        private async void S_ValueChanged(GattCharacteristic sender, GattValueChangedEventArgs args)
        {
            var b = DataReader.FromBuffer(args.CharacteristicValue);

            var bytes = new byte[b.UnconsumedBufferLength];

            b.ReadBytes(bytes);

            await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                                                                          () =>
            {
                var m = new MeasuredValue(ConvertToMillimeters(bytes));
                _receivedValues.Add(m);
                listViewValues.ScrollIntoView(m);

                UpdateGui();

                if ((bool)beepSwitch.IsChecked)
                {
                    _beep?.Play();
                }
            }
                                                                          );
        }
예제 #4
0
        public void Run(string sourceFilename)
        {
            SourceFilename = sourceFilename;
            ME             = new MediaElement()
            {
                Source         = new Uri(SourceFilename),
                LoadedBehavior = MediaState.Manual,
                Margin         = new Thickness(10),
                Volume         = 0
            };
            ME.Loaded += (s, e) =>
            {
                if (ME == null)
                {
                    return;
                }
                ME.Position = TimeSpan.Zero;
                ME?.Play();
            };
            ME.MediaEnded += (s, e) =>
            {
                if (ME == null)
                {
                    return;
                }
                ME.Position = TimeSpan.Zero;
                ME.Play();
            };
            foreach (var el in Panel.Children)
            {
                if (el is FrameworkElement)
                {
                    ((FrameworkElement)el).Visibility = System.Windows.Visibility.Hidden;
                }
            }

            Panel.Children.Add(ME);
        }
예제 #5
0
        // yhteentörmäyksen tarkastelu
        private void CheckCollision()
        {
            // loop flowers list
            foreach (Flower flower in flowers)
            {
                //get rects
                Rect BRect = new Rect(
                    butterfly.LocationX,
                    butterfly.LocationY,
                    butterfly.ActualWidth,
                    butterfly.ActualHeight
                    );
                Rect FlowerRect = new Rect(
                    flower.LocationX,
                    flower.LocationY,
                    flower.ActualWidth,
                    flower.ActualHeight
                    );

                // does objects intersects
                BRect.Intersect(FlowerRect);
                if (!BRect.IsEmpty)
                {
                    // collision! area is not empty
                    // remove blower from canvas
                    MyCanvas.Children.Remove(flower);
                    // remove from list
                    flowers.Remove(flower);
                    //play audio
                    mediaElement.Play();
                    break;
                }
                ;
            }
            ;
        }
예제 #6
0
        public async Task Speak(string text)
        {
            var tts      = TinBotHelpers.WrapWithSSML(text);
            var ssStream = await Synth.SynthesizeSsmlToStreamAsync(tts);

            await ExecuteOnMainThread(() =>
            {
                MediaElement.MarkerReached -= MediaElementOnMarkerReached;
                MediaElement.MarkerReached += MediaElementOnMarkerReached;

                MediaElement.Markers.Clear();
                ssStream.Markers.ToList()
                .ForEach(x => MediaElement.Markers.Add(new TimelineMarker {
                    Text = x.Text, Time = x.Time
                }));

                MediaElement.SetSource(ssStream, ssStream.ContentType);
                MediaElement.Play();
            });

            await Task.Delay(500);

            var playing = true;

            while (playing)
            {
                await ExecuteOnMainThread(() =>
                {
                    playing = MediaElement.CurrentState == MediaElementState.Playing ||
                              MediaElement.CurrentState == MediaElementState.Buffering ||
                              MediaElement.CurrentState == MediaElementState.Opening;
                });

                await Task.Delay(500);
            }
        }
    public async Task Play(CoreDispatcher dispatcher)
    {
        Playing = true;
        MediaElement        playback = new MediaElement();
        IRandomAccessStream audio    = buffer.CloneStream();

        if (audio == null)
        {
            throw new ArgumentNullException("buffer");
        }

        //Creates folder locally on user device for the recorded sound
        StorageFolder storageFolder = Windows.ApplicationModel.Package.Current.InstalledLocation;

        if (!string.IsNullOrEmpty(filename))
        {
            StorageFile original = await storageFolder.GetFileAsync(filename);

            await original.DeleteAsync();
        }
        await dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() =>
        {
            StorageFile storageFile = await storageFolder.CreateFileAsync(audioFilename, CreationCollisionOption.GenerateUniqueName);
            filename = storageFile.Name;
            using (IRandomAccessStream fileStream = await storageFile.OpenAsync(FileAccessMode.ReadWrite))
            {
                await RandomAccessStream.CopyAndCloseAsync(audio.GetInputStreamAt(0), fileStream.GetOutputStreamAt(0));
                await audio.FlushAsync();
                audio.Dispose();
            }
            IRandomAccessStream stream = await storageFile.OpenAsync(FileAccessMode.Read);
            playback.SetSource(stream, storageFile.FileType);

            playback.Play();
        });
    }
예제 #8
0
        private async void Button_Click_Venus(object sender, RoutedEventArgs e)
        {
            MediaElement mediaElement = new MediaElement();
            var          synth        = new Windows.Media.SpeechSynthesis.SpeechSynthesizer();

            Windows.Media.SpeechSynthesis.SpeechSynthesisStream stream = await synth.SynthesizeTextToStreamAsync("Venus is the second planet from the sun.\n" +
                                                                                                                 " It has a hot dense atmosphere composed mainly of carbon dioxide.\n" +
                                                                                                                 " Its atmospheric pressure is 92 times that of Earth.\n");

            mediaElement.SetSource(stream, stream.ContentType);
            mediaElement.Play();

            DisplayPlanet.Source = new BitmapImage(new Uri(base.BaseUri, "Assets/Venus.jpg"));
            PName.Text           = "Name: Venus";
            PDesignation.Text    = "Designation: Second planet in the Solar System";
            PType.Text           = "Type: Terrestrial Planet";
            PRadius.Text         = "Radius: 6052 km";
            PVolume.Text         = "Volume: 9.38 x 10^11 km3";
            PMass.Text           = "Mass: 4.867 × 10^24 kg";
            PGravity.Text        = "Surface Gravity: 8.87 m/s2";
            PDescription.Text    = "Description: Venus is the second planet from the sun.\n" +
                                   "It has a hot dense atmosphere composed mainly of CO2.\n" +
                                   "Its atmospheric pressure is 92 times that of Earth.\n";
        }
예제 #9
0
        private async void Button_Click_Pluto(object sender, RoutedEventArgs e)
        {
            MediaElement mediaElement = new MediaElement();
            var          synth        = new Windows.Media.SpeechSynthesis.SpeechSynthesizer();

            Windows.Media.SpeechSynthesis.SpeechSynthesisStream stream = await synth.SynthesizeTextToStreamAsync("Pluto is a dwarf planet in the Kuiper belt, a ring of bodies beyond Neptune.\n" +
                                                                                                                 " It was the first Kuiper belt object to be discovered.\n" +
                                                                                                                 " It was named after the god of the underworld from classical mythology.\n");

            mediaElement.SetSource(stream, stream.ContentType);
            mediaElement.Play();

            DisplayPlanet.Source = new BitmapImage(new Uri(base.BaseUri, "Assets/Pluto.jpg"));
            PName.Text           = "Name: Pluto";
            PDesignation.Text    = "Minor-planet Designation: 134340 Pluto (Formerly classified as a planet)";
            PType.Text           = "Type: Dwarf Planet";
            PRadius.Text         = "Radius: 1188km";
            PVolume.Text         = "Volume: (7.057±0.004) × 10^9 km3";
            PMass.Text           = "Mass: (1.303±0.003) × 10^22 kg";
            PGravity.Text        = "Surface Gravity: 0.620 m/s2";
            PDescription.Text    = "Description: Pluto is a dwarf planet in the Kuiper belt, a ring of bodies beyond Neptune.\n" +
                                   "It was the first Kuiper belt object to be discovered.\n" +
                                   "It was named after the god of the underworld from classical mythology.\n";
        }
예제 #10
0
        private async void Button_Click_Uranus(object sender, RoutedEventArgs e)
        {
            MediaElement mediaElement = new MediaElement();
            var          synth        = new Windows.Media.SpeechSynthesis.SpeechSynthesizer();

            Windows.Media.SpeechSynthesis.SpeechSynthesisStream stream = await synth.SynthesizeTextToStreamAsync("Uranus is the seventh planet from the sun.\n" +
                                                                                                                 " It is composed mainly of hydrogen and helium, but also contains more 'ices' such as water, ammonia and methane.\n" +
                                                                                                                 " At -224 degrees Celsius, it has the coldest atmosphere of any planet in the Solar System.\n");

            mediaElement.SetSource(stream, stream.ContentType);
            mediaElement.Play();

            DisplayPlanet.Source = new BitmapImage(new Uri(base.BaseUri, "Assets/Uranus.jpg"));
            PName.Text           = "Name: Uranus";
            PDesignation.Text    = "Designation: Seventh planet in the Solar System";
            PType.Text           = "Type: Ice Giant";
            PRadius.Text         = "Radius: 25362km";
            PVolume.Text         = "Volume: 6.833 × 10^13 km3";
            PMass.Text           = "Mass: (8.6810±0.0013) × 10^25 kg";
            PGravity.Text        = "Surface Gravity: 8.69 m/s2";
            PDescription.Text    = "Description: Uranus is the seventh planet from the sun.\n" +
                                   "It is composed mainly of hydrogen and helium, but also contains more 'ices' \nsuch as water, ammonia and methane.\n" +
                                   "At -224 degrees Celsius, it has the coldest atmosphere of any planet \nin the Solar System.\n";
        }
예제 #11
0
        private async void Button_Click_Saturn(object sender, RoutedEventArgs e)
        {
            MediaElement mediaElement = new MediaElement();
            var          synth        = new Windows.Media.SpeechSynthesis.SpeechSynthesizer();

            Windows.Media.SpeechSynthesis.SpeechSynthesisStream stream = await synth.SynthesizeTextToStreamAsync("Saturn is the sixth planet from the sun, and the second largest in the Solar System.\n" +
                                                                                                                 " It is named after the Roman god of agriculture.\n" +
                                                                                                                 " It is most known for its visible rings composed mainly of ice particles.\n");

            mediaElement.SetSource(stream, stream.ContentType);
            mediaElement.Play();

            DisplayPlanet.Source = new BitmapImage(new Uri(base.BaseUri, "Assets/Saturn.jpg"));
            PName.Text           = "Name: Saturn";
            PDesignation.Text    = "Designation: Sixth planet in the Solar System";
            PType.Text           = "Type: Gas Giant";
            PRadius.Text         = "Radius: 58232km";
            PVolume.Text         = "Volume: 8.2713 × 10^14 km3";
            PMass.Text           = "Mass: 5.6834 × 10^26 kg";
            PGravity.Text        = "Surface Gravity: 10.44 m/s2";
            PDescription.Text    = "Description: Saturn is the sixth planet from the sun, and the second largest in the \nSolar System.\n" +
                                   "It is named after the Roman god of agriculture.\n" +
                                   "It is most known for its visible rings composed mainly of ice particles.\n";
        }
예제 #12
0
        private static async Task PlayAnnouncementAudioStreamAsync(SpeechSynthesisStream stream, VoiceMode voiceMode)
        {
            await await CrystalApplication.Dispatcher.RunWhenIdleAsync(async() =>
            {
                var source = MediaSource.CreateFromStream(stream, stream.ContentType);

                //media.AudioCategory = MediaPlayerAudioCategory.Speech;
                if (voiceMode == VoiceMode.Bluetooth)
                {
                    announcementMediaElement.AudioCategory = Windows.UI.Xaml.Media.AudioCategory.Media; //Speech is too low.
                }
                else if (voiceMode == VoiceMode.Headphones)
                {
                    announcementMediaElement.AudioCategory = Windows.UI.Xaml.Media.AudioCategory.Alerts;
                }

                //media.CommandManager.IsEnabled = false;
                announcementMediaElement.Volume = 1.0;

                announcementMediaElement.SetPlaybackSource(source);

                Task mediaOpenTask = announcementMediaElement.WaitForMediaOpenAsync();

                announcementMediaElement.Play();

                await mediaOpenTask;

                await Task.Delay((int)announcementMediaElement.NaturalDuration.TimeSpan.TotalMilliseconds);

                source.Dispose();

                stream.Dispose();

                //media.Dispose();
            });
        }
예제 #13
0
        private async void Button_Click_Jupiter(object sender, RoutedEventArgs e)
        {
            MediaElement mediaElement = new MediaElement();
            var          synth        = new Windows.Media.SpeechSynthesis.SpeechSynthesizer();

            Windows.Media.SpeechSynthesis.SpeechSynthesisStream stream = await synth.SynthesizeTextToStreamAsync("Jupiter is the fifth planet from the sun, and the largest planet in the Solar System.\n" +
                                                                                                                 " It is one of four giant planets, the others being Saturn, Uranus and Neptune.\n" +
                                                                                                                 " It is a gas giant, and thus has no real 'surface' to speak of - the atmosphere simply gets denser towards the core of the planet.\n");

            mediaElement.SetSource(stream, stream.ContentType);
            mediaElement.Play();

            DisplayPlanet.Source = new BitmapImage(new Uri(base.BaseUri, "Assets/Jupiter.jpg"));
            PName.Text           = "Name: Jupiter";
            PDesignation.Text    = "Designation: Fifth planet in the Solar System";
            PType.Text           = "Type: Gas Giant";
            PRadius.Text         = "Radius: 69911km";
            PVolume.Text         = "Volume: 1.4313 × 10^15 km3";
            PMass.Text           = "Mass: 1.8982 × 10^27 kg";
            PGravity.Text        = "Surface Gravity: 24.79 m/s2";
            PDescription.Text    = "Description: Jupiter is the fifth planet from the sun, and the largest planet \nin the Solar System.\n" +
                                   "It is one of four giant planets, the others being Saturn, Uranus and Neptune.\n" +
                                   "It is a gas giant, and thus has no real 'surface' to speak of - the atmosphere \nsimply gets denser towards the core of the planet.\n";
        }
예제 #14
0
        public static async Task ResponsePlayStreamAsync(
            //? this MediaElement mediaElement,
            this MediaElement mediaElement,
            IRandomAccessStream stream,
            bool disposeStream = true)
        {
            // bool is irrelevant here, just using this to flag task completion.
            TaskCompletionSource <bool> taskCompleted = new TaskCompletionSource <bool>();

            // Note that the MediaElement needs to be in the UI tree for events
            // like MediaEnded to fire.
            RoutedEventHandler endOfPlayHandler = (s, e) =>
            {
                if (disposeStream)
                {
                    stream.Dispose();
                }
                taskCompleted.SetResult(true);
            };

            mediaElement.MediaEnded += endOfPlayHandler;

            mediaElement.SetSource(stream, string.Empty);
            mediaElement.Play();
            ////HERE - get sender/caller
            //RepeaterUserControl repeaterUC = new RepeaterUserControl();
            //RepeaterUserControl2 repeaterUC2 = new RepeaterUserControl2();
            ////QnAPage qnAPage = new QnAPage();
            //if (repeaterUC2.MySender == "BtnRepeatMediaOutAsync2")
            //{
            //    Debug.WriteLine("Sender is RepeaterUserControl: " + repeaterUC2.MySender.ToString());
            //}
            //else if(repeaterUC2.MySender == "BtnRepeatMediaOutAsync2")
            //{
            //    Debug.WriteLine("Sender is RepeaterUserControl2: " + repeaterUC2.MySender.ToString());
            //}
            //else
            //{
            //    Debug.WriteLine("Sender undetermined");
            //}

            //Code-Set Get Amount of time takes for Async Task - await takes
            Int32    secs           = 0;
            Int32    secs2          = 0;
            TimeSpan tsCombinedSecs = new TimeSpan(0, 0, secs);
            var      sw             = new Stopwatch();

            sw.Start();
            try
            {
                bool IsValid = await taskCompleted.Task;
                Debug.WriteLine("\nbool IsValid : " + IsValid.ToString());
            }
            catch (Exception ex)
            {
                Debug.WriteLine("\n bool IsValid =  await taskCompleted.Task; : " + ex.Message.ToString());
            }

            try
            {
                sw.Stop();
                TimeSpan tsElapsedSecs = sw.Elapsed;
                Debug.WriteLine("\nTimeSpan tsElapsedSecs = sw.Elapsed; : " + tsElapsedSecs.ToString());
                double secsElapsed = sw.Elapsed.TotalSeconds;
                Debug.WriteLine("\ndouble secsElapsed = sw.Elapsed.TotalSeconds; : " + secsElapsed.ToString());
            }
            catch (Exception ex)
            {
                Debug.WriteLine("\n sw.Stop(); : " + ex.Message.ToString());
            }

            try
            {
                //Do not think this is doing anything, as secs2 is no value,
                //but may be hhelping w/thread locked
                Interlocked.Add(ref secs, secs2);
                Debug.WriteLine("\nsecs : " + secs.ToString());
            }
            catch (Exception ex)
            {
                Debug.WriteLine("\n  Interlocked.Add(ref secs, secs2); : " + ex.Message.ToString());
            }

            mediaElement.MediaEnded -= endOfPlayHandler;
        }
        private async void ButtonAUTOCURVE2(object sender, RoutedEventArgs e)
        {
            stackpanelWaitTime1.Visibility = Visibility.Collapsed;

            if (textboxAUTOCURVE.Text.Length != 0)
            {
                char[] buffer = new char[textboxAUTOCURVE.Text.Length];
                textboxAUTOCURVE.Text.CopyTo(0, buffer, 0, textboxAUTOCURVE.Text.Length);
                double waitTime = 0;
                try
                {
                    waitTime = Convert.ToDouble(new string(buffer));
                }
                catch
                {
                    rootPage.NotifyUser("Please enter a valid value.", NotifyType.ErrorMessage);
                    stackpanelWaitTime1.Visibility = Visibility.Visible;
                    return;
                }

                output.Text = "Preparation time...";
                await SetLight(0);

                await Task.Delay((int)waitTime * 1000);
            }

            double ambientLux1 = 0, ambientLux2 = 0, ambientLuxCurrent = 0;
            double screenLux1 = 0, screenLux2 = 0, screenLuxCurrent = 0;

            try
            {
                var csv = new System.Text.StringBuilder();
                await SetConversionTime(100);

                csv.AppendLine("Light Level,Ambient Lux,Screen Lux");

                output.Text = "Auto Brightness test running...";

                // Move the light up in increments of 5 to speed the test up further.
                for (uint i = 500; i <= 2600; i += 5)
                {
                    await Task.Delay(150);
                    await SetLight(i);

                    await Task.Delay(150);

                    ambientLux1 = await GetAmbientLux();

                    screenLux1 = await GetScreenLux();

                    await Task.Delay(150);

                    ambientLux2 = await GetAmbientLux();

                    screenLux2 = await GetScreenLux();

                    await Task.Delay(150);

                    ambientLuxCurrent = await GetAmbientLux();

                    screenLuxCurrent = await GetScreenLux();

                    while (screenLux1 != screenLux2 || screenLux2 != screenLuxCurrent)
                    {
                        ambientLux1 = ambientLux2;
                        screenLux1  = screenLux2;

                        ambientLux2 = ambientLuxCurrent;
                        screenLux2  = screenLuxCurrent;

                        await Task.Delay(150);

                        ambientLuxCurrent = await GetAmbientLux();

                        screenLuxCurrent = await GetScreenLux();
                    }

                    csv.AppendLine(string.Format("{0},{1},{2}", i, ambientLuxCurrent, screenLuxCurrent));
                }

                await Task.Run(() => { File.WriteAllText(tmp.Path, csv.ToString()); });

                await tmp.CopyAndReplaceAsync(file);

                output.Text = "Successfully written data to " + file.Path.ToString();
                restartButton.Visibility = Visibility.Visible;

                var mediaElement = new MediaElement();
                var folder       = await Package.Current.InstalledLocation.GetFolderAsync("Music");

                var wav = await folder.GetFileAsync("Alarm05.wav");

                var stream = await wav.OpenAsync(FileAccessMode.Read);

                mediaElement.SetSource(stream, "");
                mediaElement.Play();

                rootPage.EnableScenarioSelect();
            }
            catch (Exception exception)
            {
                output.Text = exception.Message;
                rootPage.EnableScenarioSelect();
            }
        }
예제 #16
0
        static public void Play_Execute(object parameter)
        {
            MediaElement media = parameter as MediaElement;

            media.Play();
        }
예제 #17
0
 private void WorldMap_Loaded(object sender, RoutedEventArgs e)
 {
     music.Source = new Uri("../../Menu.wav", UriKind.Relative);
     music.Play();
 }
예제 #18
0
        private async void dispatcherTimer_Tick(object sender, object e)
        {
            // Bouton Noir
            if (_pin18.Read() == GpioPinValue.High)
            {
                MediaElement          mediaElement = new MediaElement();
                var                   synth        = new SpeechSynthesizer();
                SpeechSynthesisStream stream       = await synth.SynthesizeTextToStreamAsync("Salinger");

                mediaElement.SetSource(stream, stream.ContentType);
                mediaElement.Play();

                string html = @"<iframe src=""https://www.youtube.com/embed/2SXKukJN8HM"" width=""560"" height=""315"" allow=""autoplay; encrypted - media"" frameborder=""0""></iframe>";

                this.Navigateur.NavigateToString(html);
            }

            // Bouton Gris
            if (_pin23.Read() == GpioPinValue.High)
            {
                MediaElement          mediaElement = new MediaElement();
                var                   synth        = new SpeechSynthesizer();
                SpeechSynthesisStream stream       = await synth.SynthesizeTextToStreamAsync("Oracle");

                mediaElement.SetSource(stream, stream.ContentType);
                mediaElement.Play();

                this.Navigateur.Source = new Uri("https://www.boursorama.com/cours/ORCL/");
            }

            // Bouton Blanc
            if (_pin24.Read() == GpioPinValue.High)
            {
                MediaElement          mediaElement = new MediaElement();
                var                   synth        = new SpeechSynthesizer();
                SpeechSynthesisStream stream       = await synth.SynthesizeTextToStreamAsync("Justine !!!");

                mediaElement.SetSource(stream, stream.ContentType);
                mediaElement.Play();
            }

            // Bouton Rouge
            if (_pin25.Read() == GpioPinValue.High)
            {
                MediaElement          mediaElement = new MediaElement();
                var                   synth        = new SpeechSynthesizer();
                SpeechSynthesisStream stream       = await synth.SynthesizeTextToStreamAsync("Justine !!!");

                mediaElement.SetSource(stream, stream.ContentType);
                mediaElement.Play();

                mediaPlayerRouge.Play();
            }

            // Bouton Vert
            if (_pin12.Read() == GpioPinValue.High)
            {
                MediaElement          mediaElement = new MediaElement();
                var                   synth        = new SpeechSynthesizer();
                SpeechSynthesisStream stream       = await synth.SynthesizeTextToStreamAsync("Justine !!!");

                mediaElement.SetSource(stream, stream.ContentType);
                mediaElement.Play();
            }

            // Bouton Bleu
            if (_pin16.Read() == GpioPinValue.High)
            {
                MediaElement          mediaElement = new MediaElement();
                var                   synth        = new SpeechSynthesizer();
                SpeechSynthesisStream stream       = await synth.SynthesizeTextToStreamAsync("Microsoft");

                mediaElement.SetSource(stream, stream.ContentType);
                mediaElement.Play();

                this.Navigateur.Source = new Uri("https://www.boursorama.com/cours/MSFT/");
            }

            // Bouton Jaune
            if (_pin20.Read() == GpioPinValue.High)
            {
                MediaElement          mediaElement = new MediaElement();
                var                   synth        = new SpeechSynthesizer();
                SpeechSynthesisStream stream       = await synth.SynthesizeTextToStreamAsync("Yellow");

                mediaElement.SetSource(stream, stream.ContentType);
                mediaElement.Play();
            }
        }
예제 #19
0
 private void MediaElement_MediaOpened(object sender, RoutedEventArgs e)
 {
     ShowMediaControls();
     MediaElement.Play();
     MediaElement.Visibility = Visibility.Visible;
 }
예제 #20
0
 void mediaPlay(Object sender, EventArgs e, MediaElement myMedia)
 {
     myMedia.Play();
 }
예제 #21
0
 public static void getgif(MediaElement sm, string road)
 {
     sm.Source = new Uri(Environment.CurrentDirectory + "\\" + road);
     sm.Volume = 100; sm.Play();
 }
예제 #22
0
        //Обработка двойного нажатия на элемент листа
        private void List_Click_Item(object sender, MouseButtonEventArgs e)
        {
            string listItem       = listik.SelectedItem.ToString();
            string listItemFormat = getFileExtension(listItem);

            switch (listItemFormat)
            {
            case "doc":
            case "docx":
                MdiContainer.Children.Clear();
                MdiContainer.Children.Add(mdiChildWord);
                LoadDocx(listItem);
                break;

            case "pdf":
                MdiContainer.Children.Clear();
                MdiContainer.Children.Add(mdiChildPDF);
                Uri siteUri = new Uri(EXE_DIRECTORY + FOLDER + listItem);
                webBrowser.Navigate(siteUri);
                break;

            //".mp4", ".avi", ".flv", ".mov", ".ogg"
            case "avi":
            case "mp4":
            case "ogg":
            case "flv":
            case "mov":
                MdiContainer.Children.Clear();
                MdiContainer.Children.Add(mdiChildVideo);

                //  MediaElement mediaElement = new MediaElement()
                //  {
                //      VerticalAlignment = VerticalAlignment.Stretch,
                //      HorizontalAlignment = HorizontalAlignment.Stretch
                //  };

                //StackPanel stackPanelV = new StackPanel()
                //{
                //  Orientation = Orientation.Vertical
                //};

                //StackPanel stackPanelH = new StackPanel()
                //{
                //  Orientation = Orientation.Horizontal
                //};
                //Button ButtonStop = new Button()
                //{
                // Name = "ButtonStop",
                // Width = 100,
                //  Height = 30,
                //  VerticalAlignment = VerticalAlignment.Bottom,
                //  HorizontalAlignment = HorizontalAlignment.Center,
                //  Content = "Stop",
                // };
                // Button ButtonPlay = new Button()
                // {
                //   Name = "ButtonPlay",
                //   Width = 100,
                //   Height = 30,
                //   VerticalAlignment = VerticalAlignment.Bottom,
                //   HorizontalAlignment = HorizontalAlignment.Center,
                //   Content = "Play",
                // };

                mdiChildVideo.Content = stackPanelV;
                ButtonStop.Click     += ButtonStopOnClick;
                ButtonPlay.Click     += ButtonPlayOnClick;
                stackPanelV.Children.Add(mediaElement);
                stackPanelV.Children.Add(stackPanelH);
                stackPanelH.Children.Add(ButtonStop);
                stackPanelH.Children.Add(ButtonPlay);
                mediaElement.Source         = new Uri(EXE_DIRECTORY + FOLDER + listItem);
                mediaElement.LoadedBehavior = MediaState.Manual;
                mediaElement.Stretch        = Stretch.Fill;
                mediaElement.Play();
                break;

            case "ppt":
            case "pptx":
                System.Diagnostics.Process.Start(FULLFOLDER + listItem);
                break;
            }
        }
예제 #23
0
 public void ControlVisible()
 {
     mebg.Play();
 }
예제 #24
0
        // method that holds the game over code
        public void GameOver(bool won)
        {
            ButtonDeactivated(buttonRed, false);
            ButtonDeactivated(buttonGreen, false);
            ButtonDeactivated(buttonBlue, false);
            ButtonDeactivated(buttonYellow, false);

            gameActive = false;

            btnStart.IsEnabled = true;

            lastPaths.Clear();
            // add to list of last paths
            for (int i = 0; i < currentRound; i++)
            {
                try
                {
                    if (randomPaths[i] != null & randomPaths[i].Name != "Add")
                    {
                        lastPaths.Add(randomPaths[i]);
                    }
                }
                catch
                {
                    break;
                }
            }

            if (lastPaths.Count > longestPaths.Count)
            {
                longestPaths.Clear();
                for (int i = 0; i < lastPaths.Count; i++)
                {
                    longestPaths.Add(lastPaths[i]);
                }

                if (longestPaths.Count > MainSettings.LongestGame)
                {
                    MainSettings.LongestGame = longestPaths.Count;
                }
            }

            SimonWindow.IsHitTestVisible = false;

            currentRound = 0;
            roundIndex   = 0;

            // stop the timer
            timeoutTimer.Stop();
            timeoutTimer.Tick -= timeoutTimer_Tick;
            timeoutTimer       = null;

            roundTimer.Stop();
            roundTimer.Tick -= roundTimer_Tick;
            roundTimer       = null;

            delaytimer.Stop();
            delaytimer.Tick -= delayTimer_Tick;
            delaytimer       = null;

            TimertoWaitForNextSequence.Stop();
            TimertoWaitForNextSequence.Tick -= TimertoWaitForNextSequence_Tick;
            TimertoWaitForNextSequence       = null;

            roundTimer = new DispatcherTimer();
            delaytimer = new DispatcherTimer();

            // time-out timer
            timeoutTimer = new DispatcherTimer();
            TimertoWaitForNextSequence = new DispatcherTimer();

            // disable all buttons <-- Do we want to do something like this?
            if (won == true)
            {
                playWinSequence();
                MessageBox.Show("You've won!");

                winSequenceTimer.Stop();
                winSequenceTimer.Tick -= winSequenceTimer_Tick;
                winSequenceTimer       = null;
                winSequenceIndex       = 0;
            }
            else
            {
                //game over sound.  Might need to be set on a timer. For this, I guess I could just recreate the audio file for the exact time length
                me = buttonSounds[4];
                me.Play();
                me.Position = new TimeSpan(0);
            }
            SimonWindow.IsHitTestVisible = true;
            gameIsOver = true;
        }
예제 #25
0
 public void Button_Click(object sender, RoutedEventArgs e)
 {
     MediaElement.Play();
 }
예제 #26
0
 private void Play()
 {
     SetPauseShape();
     video.Play();
 }
예제 #27
0
 public void ChangeSource(Uri uri)
 {
     myPlayer.Stop();
     myPlayer.Source = uri;
     myPlayer.Play();
 }
 private void player_MediaEnded(object sender, RoutedEventArgs e)
 {
     player.Position = TimeSpan.FromSeconds(Item.StartPos.HasValue ? Item.StartPos.Value : 0);
     player.Play();
 }
예제 #29
0
 public void PlayMusic()
 {
     musicPlaying    = true;
     MusicVisibility = Visibility.Visible;
     playingSong?.Play();
 }
예제 #30
0
 internal static async Task ExplodeSoundAsync(MediaElement mysong)
 {
     await UiThreadHelper.RunAsync(CoreDispatcherPriority.Normal,
                                   () => mysong.Play());
 }