/// <summary>
        /// Initializes a new instance of the <see cref="MainWindow" /> class.
        /// </summary>
        public MainWindow()
        {
            InitializeComponent();

            // var streamURI = ipi.StreamUri; // new Uri(@"http://127.0.0.1:8072");
            var streamURI = new Uri(@"http://127.0.0.1:8072");

            var savedStreams = SavedUriHandler.Streams.ToList();

            var lss = new LivestreamerSettings() { StreamUri = savedStreams[0].StreamUri, StreamQuality = savedStreams[0].Quality };
            var lss2 = new LivestreamerSettings() { StreamUri = savedStreams[1].StreamUri, StreamQuality = savedStreams[1].Quality };

            launch = new LSLauncher(lss);
            launch.Launch();

            MediaPlayer player = new MediaPlayer();
            player.Open(streamURI);
            VideoDrawing vd = new VideoDrawing();
            vd.Rect = new Rect(0, 0, 1920, 1080);
            vd.Player = player;
            player.Play();
            videoImage.Drawing = vd;
            vd.Freeze();
            player.Freeze();
        }
Beispiel #2
0
 public void Play(string link)
 {
     System.Windows.Media.MediaPlayer sound = new System.Windows.Media.MediaPlayer();
     sound.Open(new System.Uri(link));
     sound.Volume = 100;
     sound.Play();
 }
Beispiel #3
0
 public static void play(string p)
 {
     MediaPlayer player = new MediaPlayer();
     player.Open(new Uri(p, UriKind.Relative));
     Console.WriteLine("撥放開始:" + p);
     player.Play();
     player.MediaEnded += new EventHandler(player_MediaEnded);
 }
 public void PlayOnce(string songPath)
 {
     var player = new MediaPlayer();
     player.Open(new Uri(songPath, UriKind.RelativeOrAbsolute));
     this.players.Add(player);
     player.MediaEnded += this.DelateMedia;
     player.Play();
 }
        public void Play()
        {
            _player.Play();
            _positionTimer.Start();

            IsPlaying = true;
            IsPaused  = false;
            IsStopped = false;
        }
Beispiel #6
0
        public void PlayAllways()
        {
            var player = new System.Windows.Media.MediaPlayer();

            // player.Open(new Uri(@"C:\Users\marina.oleinik\source\repos\Snake_2020\Snake_2020\Allways.mp3", UriKind.Relative));
            player.Open(new Uri("Allways.mp3", UriKind.Relative));
            player.Volume = 100;
            player.Play();
        }
Beispiel #7
0
		/// <summary>
		/// To record messages.
		/// </summary>
		/// <param name="messages">Debug messages.</param>
		protected override void OnWriteMessages(IEnumerable<LogMessage> messages)
		{
			var player = new MediaPlayer();
			player.Open(new Uri(FileName, UriKind.RelativeOrAbsolute));
			player.Play();

			if (messages.Any(message => message.IsDispose))
				Dispose();
		}
        private void bw_DoWork(object sender, DoWorkEventArgs e)
        {
            var worker = sender as BackgroundWorker;
            var b = (forUseByBackgroundWorker) e.Argument;
            var play = new MediaPlayer();

            play.Open(new Uri(b.filePath));
            play.Position = b.t;
            play.Play();
        }
Beispiel #9
0
        public static void PlayMusic(string Path)
        {
            player = new MediaPlayer();

            //player.SetBinding(MediaElement.VolumeProperty, musicBinding);
            player.Open(new Uri(Path, UriKind.Relative));
            player.MediaEnded += Music_MediaEnded;

            player.Play();
        }
 private void playSound(Uri path)
 {
     new Thread(() => {
         var c = new System.Windows.Media.MediaPlayer();
         c.Open(path);
         c.Play();
         Thread.Sleep(2000);
         c.Stop();
     }).Start();
 }
        public void GainAttention(MainWindow mainWindow)
        {
            mainWindow.WindowState = WindowState.Normal;
            mainWindow.Focus();

            var uri = new Uri("Resources/cheering-1.mp3", UriKind.Relative);

            var player = new MediaPlayer();
            player.Open(uri);
            player.Play();
        }
 /// <summary>
 /// Funkcja odtwarzania muzyki w tle
 /// </summary>
 public static void MusicFunc()
 {
     if (!music_stop)
     {
         mp = new MediaPlayer();
         mp.Open(new System.Uri(Path.GetFullPath(@"background_music.wav")));
         mp.Volume = (double)MusicVolumeTrackBar.Value / 10;
         if(!is_muted)
         mp.Play();
     }
 }
Beispiel #13
0
        private void Grid_PreviewTouchUp(object sender, TouchEventArgs e)
        {
            try
            {
                string speechstring = "http://translate.google.com/translate_tts?tl=de&q=" + "Es ist jetzt " + DateTime.Now.ToShortTimeString();
                player = new MediaPlayer();
                player.Open(new Uri(speechstring));
                player.Volume = 1.0f;

                player.Play();
            }
            catch { }
        }
Beispiel #14
0
        public bool Play_Sound(SoundPlayer player)
        {
            if (avaliable_sound_device.WaitOne(0))
            {
                Task t = Task.Run(() =>
                {
                    var wmplayer = new System.Windows.Media.MediaPlayer();
                    //player.Play();
                    if (player == soundPlayer_1)
                    {
                        wmplayer.Open(new System.Uri(@"C:\\sound\\dongdong2.wav"));
                        wmplayer.Play();
                    }
                    if (player == soundPlayer_2)
                    {
                        wmplayer.Open(new System.Uri(@"C:\\sound\\ci2.wav"));
                        wmplayer.Play();
                    }
                    //wmplayer.controls.play();
                    //wmplayer.close();

                    this.avaliable_sound_device.Release();
                });

                Task t2 = Task.Run(() =>
                {
                    // send a message to server
                    tcpClient.write1();
                });


                return(true);
            }
            else
            {
                System.Console.WriteLine("sound device not avaliable");
                return(false);
            }
        }
Beispiel #15
0
        public MainWindow()
        {
            InitializeComponent();

            var mp3Filename = "Final_Fantasy_7_Philharmonic_Suite_Part_I_OC_ReMix.mp3";
            var player = new MediaPlayer();
            var uri = new Uri(mp3Filename, UriKind.Relative);
            player.Open(uri);
            player.Play();

            this.KeyUp += OnKeyUp;

            this.BrandonButton.Click += BrandonButton_Click;
        }
Beispiel #16
0
        /// <summary>
        /// 播放声音
        /// </summary>
        /// <param name="soundName">声音名</param>
        public static void PalyAudio(string soundName, double volume)
        {
            if (String.IsNullOrEmpty(soundName) || soundName.Contains("无"))
            {
                return;
            }

            string path = Entity.App.AudioList[soundName].ToString();

            if (!System.IO.File.Exists(path))
            {
                return;
            }

            /*
             * SoundPlayer类特点
             * 1)仅支持.wav音频文件;
             * 2)不支持同时播放多个音频(任何新播放的操作将终止当前正在播放的);
             * 3)无法控制声音的音量;
             * if (path.EndsWith(".wav"))
             * {
             *    using (System.Media.SoundPlayer player = new System.Media.SoundPlayer(path))
             *    {
             *        player.Play();//播放波形文件
             *    }
             * }
             */
            if (_player != null)
            {
                StopAudio();
            }
            System.Windows.Application.Current.Dispatcher.Invoke(new Action(() =>
            {
                if (path.EndsWith(".mp3") || path.EndsWith(".wma") || path.EndsWith(".wav"))
                {
                    try
                    {
                        _player = new System.Windows.Media.MediaPlayer();
                        _player.Open(new Uri(path));
                        _player.Volume = volume / 100;//大小为0~1.0
                        _player.Play();
                        //_player.MediaOpened+=
                    }
                    catch (Exception ex)
                    {
                        Log.SaveLog("Core Common_PalyAudio", ex.ToString());
                    }
                }
            }));
        }
Beispiel #17
0
        public void Test(string waveFileName)
        {
            MediaPlayer player = new MediaPlayer();
            player.Open(new Uri(waveFileName));
            player.Play();

            //player.Balance
            //player.Volume

            //player.SpeedRatio            // wish it had pitch instead




        }
        private DispatcherTimer timer; // the game timer.

        #endregion Fields

        #region Constructors

        public MainWindow()
        {
            InitializeComponent();

            pinata = new Pinata();
            bat = new Bat();

            highestPlayers = new ThePlayer[10];
            mediaPlayer = new MediaPlayer();
            mediaPlayer.Open(new Uri("../../sounds/Epic Star Wars Music Compilation - Star Wars.mp3", UriKind.Relative));
            mediaPlayer.Play();
            startedGame = false;

            ToggleMainMenu(true);
        }
Beispiel #19
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="location"></param>
        /// <param name="volume"></param>
        public static void Play(string location, double volume = 0.5)
        {
            if (Settings.Default.PlaySound)
            {
                // Without a Thread, The MediaPlayer will not play it in more cases.
                ThreadPool.QueueUserWorkItem(args =>
                {
                    var player = new MediaPlayer();
                    player.Volume = volume;
                    player.Open(new Uri(location, UriKind.RelativeOrAbsolute));
                    player.Play();

                    Trace.TraceInformation(ResourceHelper.FindText("MediaFilePlayedInfo", location));
                });
            }
        }
        private void btnPlay_Click(object sender, RoutedEventArgs e)
        {
            MediaPlayer player;
            player = new MediaPlayer();

            player.Open(new Uri(@"Bear.wmv", UriKind.Relative));

            VideoDrawing aVideoDrawing = new VideoDrawing();

            aVideoDrawing.Rect = new Rect(0, 0, 100, 100);

            aVideoDrawing.Player = player;
            DrawingBrush db = new DrawingBrush(aVideoDrawing);
            rectangle1.Fill = db;
            //rectangle2.Fill = db;
            player.Play();
        }
Beispiel #21
0
        /// <summary>
        /// Plays an audio file that is build into the assembly as a resource. (This creates a new temporary player for every sound.)
        /// </summary>
        /// <param name="uri">The complete URI to the file. (Assembly;component/Folder/file.extension)</param>
        /// <param name="extension">The file extension (It seems necessary to give the random temp file the correct type in order for the MediaPlayer to use it.)</param>
        protected internal override void PlayResourceFile(Uri uri)
        {
            Uri __uri  = WriteResourceFileToTemp(uri); //Write it to the file system if it hasn't been played already

                #region Create a new MediaPlayer instance for every sound to not block or cut out sound effects
                    var __tempPlayer = new MediaPlayer();
                    __tempPlayer.Volume = this.Volume;
                    __tempPlayer.Open(__uri);

                    //Due to the fact that __tempPlayer is only a local variable it would get deleted by the garbage collector if we dont make sure its reference is held
                    _playerCache.Add(__tempPlayer);
                    #region Remove the object from the list after the media has finished
                        __tempPlayer.MediaEnded += new EventHandler(delegate { _playerCache.Remove(__tempPlayer); });
                    #endregion
                    __tempPlayer.Play();
                #endregion
        }
        public VideoForm()
        {
            InitializeComponent();

            MediaPlayer player = new MediaPlayer();

            player.Open(new Uri(@"test.mp4", UriKind.Relative));

            VideoDrawing aVideoDrawing = new VideoDrawing();

            aVideoDrawing.Rect = new Rect(0, 0, 100, 100);
            aVideoDrawing.Player = player;

            DrawingImage di = new DrawingImage(aVideoDrawing);

            // Play the video once.
            player.Play();
        }
Beispiel #23
0
        private void VideoDrawingAnimationWindow_OnLoaded(object sender, RoutedEventArgs e)
        {
            var player = new System.Windows.Media.MediaPlayer();

            player.MediaEnded += PlayerOnMediaEnded;

            player.Open(new Uri(@"AnimationPerformanceDemo\Assets\1.mp4", UriKind.RelativeOrAbsolute));

            var videoDrawing = new VideoDrawing {
                Rect = new Rect(0, 0, 1920, 1080), Player = player
            };

            var brush = new DrawingBrush(videoDrawing);

            Background = brush;

            player.Play();
        }
        private void cmdPlayCode_Click(object sender, RoutedEventArgs e)
        {
            // Create the MediaPlayer.
            MediaPlayer player = new MediaPlayer();
            player.Open(new Uri("test.mpg", UriKind.Relative));

            // Create the VideoDrawing.
            VideoDrawing videoDrawing = new VideoDrawing();
            videoDrawing.Rect = new Rect(150, 0, 100, 100);
            videoDrawing.Player = player;

            // Assign the DrawingBrush.
            DrawingBrush brush = new DrawingBrush(videoDrawing);
            this.Background = brush;

            // Start playback.
            player.Play();

        }
 public BackgroundSoundPlayer(string soundFileName)
 {
     _soundFileName = soundFileName;
     if (!System.IO.File.Exists(soundFileName))
         return;
     _bwSound = new BackgroundWorker();
     _bwSound.RunWorkerCompleted += (bcs, bce) => { };
     _bwSound.DoWork += (bcs, bce) =>
     {
         try
         {
             MediaPlayer _mpSound = new MediaPlayer();
             _mpSound.Open(new Uri(_soundFileName, UriKind.Absolute));
             _mpSound.IsMuted = false;
             _mpSound.Volume = 1.0d;
             _mpSound.Play();
         }
         catch { }
     };
 }
Beispiel #26
0
        public WaitingCardView()
        {
            InitializeComponent();

            //Load Video
            this.CenterMedia.Source = new Uri(videoUri + VideoUri.Waiting_Card, UriKind.Relative);

            //Handlers
            CenterMedia.MediaEnded += CenterMedia_MediaEnded;

            //Play
            CenterMedia.Play();

            //Audio
            this.Loaded += View_Loaded;
            this.Unloaded += View_Unloaded;
            audioPlayer = new MediaPlayer();
            audioPlayer.Open(new Uri(audioUri + AudioUri.WaitingCard, UriKind.Relative));
            audioPlayer.Play();
        }
        public void Play(Label txtKron, Playlist playlist, ProgressBar progress, bool isSpectrumOn)
        {
            _player             = new System.Windows.Media.MediaPlayer();
            _player.MediaEnded += delegate { NextSong(playlist, txtKron, progress, isSpectrumOn); };
            SongNameLabel(txtKron, playlist.listOfFiles[0][1]);
            if (playlist.listOfFiles[0][2] == ".wav" && isSpectrumOn == true)
            {
                //UnityLaunch();
                //Thread.Sleep(2150);
                //Thread.Sleep(2485);
                AsynchronousClient.StartClient(playlist.listOfFiles[0][0]);
            }
            Uri uri = new Uri(playlist.listOfFiles[0][0]);

            _player.Open(uri);
            _player.MediaOpened += delegate { SetMax(progress); };
            currentSongID        = 0;
            _player.Play();
            SetTimer(progress);
            _player.Volume = volume;
        }
        private void DoReward(object state)
        {
            _isPlaying = true;

            this.Dispatcher.Invoke(new Action(() => {
                pbLeft.Visibility = Visibility.Hidden;
                pbRight.Visibility = Visibility.Hidden;
                olaf.Visibility = Visibility.Visible;
            }));

            MediaPlayer mp = new MediaPlayer();
            mp.Open(new Uri(new System.IO.FileInfo(".\\OlafWarmHugs.mp3").FullName));
            mp.Play();
            System.Threading.Thread.Sleep(6000);

            this.Dispatcher.Invoke(new Action(() => {
                Reset();
            }));

            _isPlaying = false;
        }
Beispiel #29
0
        /// <summary>
        /// Starts playing the music on a seperate thread
        /// </summary>
        private void priv_StartMusic()
        {
            using (Stream file = File.OpenWrite(Sound_Name + ".mp3"))
            {
                byte[] entireFile = fileStream;
                file.Write(entireFile, 0, entireFile.Length);
            }

            MediaPlayer p1 = new MediaPlayer();
            p1.Open(new System.Uri(AppDomain.CurrentDomain.BaseDirectory + Sound_Name + ".mp3"));
            do
            {
                p1.Volume = 0.1;
                p1.Play();
                bool sleep = true;
                p1.MediaEnded += (sender, e) => sleep = false;
                while (sleep)
                {
                    Thread.Sleep(1000);
                }

            } while (Replay);
        }
Beispiel #30
0
        /// <summary>
        /// Callback function for the observable object to
        /// notify that a reminder is due for delivery.
        /// </summary>
        public void DeliverReminders(List<Reminder> reminders)
        {
            if (reminders == null || reminders.Count == 0)
                return;

            Logger.Write("Reminder", String.Format("Received {0} reminders to deliver.", reminders.Count));
            this.Dispatcher.Invoke((Action)(() =>
                {
                    upcomingReminders();
                    remindersBox.Items.Add(reminders[0].ToString());
                }));
            Reminder max = reminders[0];

            for (int i = 1; i < reminders.Count; i++)
            {
                log.Write("Got into for loop in deliverreminders");
                remindersBox.Items.Add(reminders[i].ToString());
                if (reminders[i].Time.Ticks > max.Time.Ticks)
                    max = reminders[i];
                
            }

            if (max.Time.Day < DateTime.Now.Day)
            {
                Logger.Write("Reminder", "Most recent reminder was yesterday. Not delivering.");

                for (int i = 1; i < reminders.Count; i++)
                {
                    reminders[i].Delivered = true;
                    reminders[i].Done = true;
                    diaryEntryCollection.Save();
                }

                return;
            }

            Logger.Write("Reminder", "Delivered most recent reminder.");

            remindersToShow = true;
            reminderToDeliver = max;

            // This gets called from a non-UI thread, so use the dispatcher
            Dispatcher.Invoke(new Action(delegate()
            {
                // Update the UI
              
                //DisplaySomething();
                if (reminderToDeliver.Mus == true)
                {
                    MediaPlayer mp = new MediaPlayer();
                    log.Write("Should be playing music now");
                    String filePath = "C:/Musicons/Canon.mp3";
                    try
                    {
                        mp.Open(new Uri(filePath, UriKind.Absolute));
                        mp.Play();
                        log.Write("Playing music file");
                    }
                    catch (Exception e)
                    {
                        log.Write("Something went bad with music playing");
                    }
                }
                if (reminderToDeliver.Not == true)
                {
                    UserNotifications.RequestNotification("The following reminder is due", reminderToDeliver.ToString());
                }
                if (reminderToDeliver.Abs == true)
                {
                    if (reminderToDeliver.Priority == ReminderPriority.High)
                    {
                        reminderBorder.BorderBrush = Brushes.Red;
                    }
                    else
                    {
                        reminderBorder.BorderBrush = Brushes.Yellow;
                    }
                    surfaceButton4.Visibility = System.Windows.Visibility.Visible;
                }

            }));
        }
 /// <summary>
 /// 播放警告声音
 /// </summary>
 public void Warning()
 {
     MediaPlayer player = new MediaPlayer();
     Uri uri = new Uri(@"alert.wav", UriKind.Relative);
     player.Open(uri);
     player.Play();
 }
Beispiel #32
0
 private void PlaySound(Uri u)
 {
      var me = new MediaPlayer();                
      me.Open(u);
      me.Play();
 }
        private void PlaySound(MediaPlayer player)
        {
            var paths = new Uri("file://" + Directory.GetCurrentDirectory() + "/Audio/babt.mp3", UriKind.Absolute);

            player.Open(paths);
            player.Play();
        }
Beispiel #34
0
 public void Play()
 {
     _mp.Play();
 }
Beispiel #35
0
 public void PlayMusic(string link)
 {
     player.Open(new System.Uri(link));
     player.Volume = 100;
     player.Play();
 }
Beispiel #36
0
 private void PlayClickedSound()
 {
     MediaPlayer audioPlayer = new MediaPlayer();
     audioPlayer.Open(new Uri(@"pack://siteoforigin:,,,/Image/Audio/Click.wav", UriKind.RelativeOrAbsolute));
     audioPlayer.Play();
 }
        public void setUpSimulate()
        {
            manager = new GameBoardManager(n, player);
            Application.Current.Dispatcher.BeginInvoke(new Action(() =>
            {

                mediaPlayer = new MediaPlayer();
                mediaPlayer.Open(new Uri(@"C:\Users\Ryan\Music\music\4 Non Blondes\heyhey.wav"));

                mediaPlayer.Play(); // can also use soundPlayer.PlaySync()
            }));

            //Application.Current.Dispatcher.BeginInvoke(new Action(() => { Application.Current.Shutdown(); }), null);
        }
Beispiel #38
0
        public void OnHostEvent(object sender, ProgressChangedEventArgs e)
        {
            if (e.UserState is Exception)
            {
                Exception ex = e.UserState as Exception;
                PopupString(ex.ToString() + "\r\n" + ex.StackTrace.ToString());
            }
            if (e.UserState is string)
            {
                /*
                 * string line = (string)e.UserState;
                 *
                 * textHistory.AppendText(line + "\r\n");
                 * textHistory.ScrollToEnd();
                 */
            }
            else if (e.UserState is EvalBundle)
            {
                EvalBundle b = (EvalBundle)e.UserState;
                ProcessEvals(b);
            }
            else if (e.UserState is DictBundle)
            {
                DictBundle b = (DictBundle)e.UserState;

                if (b.path == "download-result")
                {
                    OfferDownloads(b);
                    if (accessLibraryDlg != null)
                    {
                        accessLibraryDlg.Consider(b);
                    }
                }
                else
                {
                    if (b.path == "_gameaid/_filenames")
                    {
                        filenameDict = b.dict;
                    }

                    partyInfo1.Consider(b);
                    partyInfo2.Consider(b);
                    vs1.Consider(b);
                    readyRolls.Consider(b);

                    if (openSaveRollsDlg != null)
                    {
                        openSaveRollsDlg.Consider(b);
                    }

                    map1.Consider(b);
                    map2.Consider(b);

                    foreach (var sq in Squad.Children)
                    {
                        var sheet = sq as VirtualSheet;
                        if (sheet != null)
                        {
                            sheet.Consider(b);
                        }
                    }
                }
            }
            else if (e.UserState is DownloadFile)
            {
                DownloadFile file = e.UserState as DownloadFile;

                // Configure open file dialog box
                var dlg = new System.Windows.Forms.SaveFileDialog();
                dlg.Title           = "Save Download";
                dlg.FileName        = file.name;
                dlg.DefaultExt      = ".xlsx";                           // Default file extension
                dlg.Filter          = "Character Sheets (.xlsx)|*.xlsx"; // Filter files by extension
                dlg.OverwritePrompt = true;
                dlg.CheckPathExists = true;

                // Show open file dialog box
                System.Windows.Forms.DialogResult result = dlg.ShowDialog();

                // Process open file dialog box results
                if (result == System.Windows.Forms.DialogResult.OK)
                {
                    try
                    {
                        System.IO.File.WriteAllBytes(dlg.FileName, file.bytes);
                    }
                    catch (Exception ex)
                    {
                        System.Windows.MessageBox.Show(ex.Message);
                        return;
                    }
                }
            }
            else if (e.UserState is AudioReport)
            {
                AudioReport audio = e.UserState as AudioReport;

                string url = "";

                switch (audio.desc)
                {
                case "speak":
                    if (reader == null)
                    {
                        try
                        {
                            // tolerate reader acquisition failure more gracefully

                            reader = new SpeechSynthesizer();

                            // var l = new List<VoiceInfo>();
                            //
                            // foreach (InstalledVoice voice in reader.GetInstalledVoices())
                            // {
                            //     VoiceInfo info = voice.VoiceInfo;
                            //     string AudioFormats = "";
                            //     foreach (SpeechAudioFormatInfo fmt in info.SupportedAudioFormats)
                            //     {
                            //         AudioFormats += String.Format("{0}\n",
                            //         fmt.EncodingFormat.ToString());
                            //     }
                            //
                            //     l.Add(info);
                            //
                            // }

                            reader.SelectVoice("Microsoft Zira Desktop");
                        }
                        catch
                        {
                        }
                    }

                    if (reader != null)
                    {
                        reader.SpeakAsync(audio.text);
                    }
                    break;

                case "ownage":
                    switch (audio.killcount)
                    {
                    case 1:
                        url = "http://myserver.com/uploads/killshot/1.mp3";
                        break;

                    case 2:
                        url = "http://myserver.com/uploads/killshot/4.mp3";
                        break;

                    case 3:
                        url = "http://myserver.com/uploads/killshot/6.mp3";
                        break;

                    case 4:
                        url = "http://myserver.com/uploads/killshot/7.mp3";
                        break;

                    case 5:
                        url = "http://myserver.com/uploads/killshot/10.mp3";
                        break;

                    case 6:
                        url = "http://myserver.com/uploads/killshot/9.mp3";
                        break;

                    case 7:
                    default:
                        url = "http://myserver.com/uploads/killshot/14.mp3";
                        break;
                    }
                    break;

                case "fumble":
                    url = "http://myserver.com/uploads/killshot/0.mp3";
                    break;

                default:
                    url = "http://myserver.com/uploads/misc/" + audio.desc;
                    break;
                }

                if (url != "")
                {
                    var player = new System.Windows.Media.MediaPlayer();
                    player.Open(new Uri(url));
                    player.MediaOpened += new EventHandler((object s, EventArgs a) => { player.Play(); });
                    player.MediaEnded  += new EventHandler((object s, EventArgs a) => { player.Close(); });
                }
            }
            else if (e.UserState is HoursReport)
            {
                HoursReport h = e.UserState as HoursReport;
                vs1.SetRemainingHours(h.hours);
            }
        }
 private void PlayMediaPlayerSound(string path)
 {
     mediaPlayer = new MediaPlayer();
     mediaPlayer.MediaFailed += (o, args) =>
     {
         Logger.Log(201, new Exception(args.ErrorException.Message));
     };
     mediaPlayer.Open(new Uri(path, UriKind.Absolute));
     mediaPlayer.Play();
 }
Beispiel #40
0
 private void cek()
 {
     if (p1lock && p2lock)
     {
         generate();
     }
     if (!p1lock)
     {
         char p1a = '\0', p1b = '\0';
         if (p1m.Count != 0)
         {
             p1a = (char)p1m.Pop();
         }
         if (p1m.Count != 0)
         {
             p1b = (char)p1m.Pop();
         }
         if (p1b == '\0')
         {
             p1m.Push(p1a);
         }
         else
         {
             if (p1a == 'a' && p1b == 'd')
             {
                 p1geleng++;
                 p1angguk = 0;
                 p1m.Clear();
             }
             else if (p1a == 'w' && p1b == 's')
             {
                 p1geleng = 0;
                 p1angguk++;
                 p1m.Clear();
             }
             else
             {
                 p1geleng = 0;
                 p1angguk = 0;
                 p1m.Push(p1b);
                 p1m.Push(p1a);
             }
         }
         if (p1angguk == 3)
         {
             if (now.ans == question)
             {
                 new System.Threading.Thread(() =>
                 {
                     var c = new System.Windows.Media.MediaPlayer();
                     c.Open(new System.Uri(@Application.StartupPath + "\\s5\\G1Benar.wav"));
                     c.Play();
                 }).Start();
                 _soal           = DateTime.UtcNow.AddSeconds(4);
                 picP1BS.Image   = Image.FromFile(Application.StartupPath + "\\s5\\1.png");
                 picP1BS.Visible = true;
                 tmrBS1.Enabled  = true;
                 p1score        += 100;
                 pp1.Text        = p1score.ToString();
                 p1lock          = true;
                 p2lock          = true;
                 cek();
             }
             else
             {
                 new System.Threading.Thread(() =>
                 {
                     var c = new System.Windows.Media.MediaPlayer();
                     c.Open(new System.Uri(@Application.StartupPath + "\\s5\\G1Salah.wav"));
                     c.Play();
                 }).Start();
                 picP1BS.Image   = Image.FromFile(Application.StartupPath + "\\s5\\0.png");
                 picP1BS.Visible = true;
                 tmrBS1.Enabled  = true;
             }
         }
         if (p1geleng == 3)
         {
             if (now.ans != question && p1geleng == 3)
             {
                 new System.Threading.Thread(() =>
                 {
                     var c = new System.Windows.Media.MediaPlayer();
                     c.Open(new System.Uri(@Application.StartupPath + "\\s5\\G1Benar.wav"));
                     c.Play();
                 }).Start();
                 _soal           = DateTime.UtcNow.AddSeconds(4);
                 picP1BS.Image   = Image.FromFile(Application.StartupPath + "\\s5\\1.png");
                 picP1BS.Visible = true;
                 tmrBS1.Enabled  = true;
                 p1score        += 100;
                 pp1.Text        = p1score.ToString();
                 p1lock          = true;
                 p2lock          = true;
                 cek();
             }
             else
             {
                 new System.Threading.Thread(() =>
                 {
                     var c = new System.Windows.Media.MediaPlayer();
                     c.Open(new System.Uri(@Application.StartupPath + "\\s5\\G1Salah.wav"));
                     c.Play();
                 }).Start();
                 picP1BS.Image   = Image.FromFile(Application.StartupPath + "\\s5\\0.png");
                 picP1BS.Visible = true;
                 tmrBS1.Enabled  = true;
             }
         }
     }
     if (!p2lock)
     {
         char p2a = '\0', p2b = '\0';
         if (p2m.Count != 0)
         {
             p2a = (char)p2m.Pop();
         }
         if (p2m.Count != 0)
         {
             p2b = (char)p2m.Pop();
         }
         if (p2b == '\0')
         {
             p2m.Push(p2a);
         }
         else
         {
             if (p2a == 'j' && p2b == 'l')
             {
                 p2geleng++;
                 p2angguk = 0;
                 p2m.Clear();
             }
             else if (p2a == 'i' && p2b == 'k')
             {
                 p2geleng = 0;
                 p2angguk++;
                 p2m.Clear();
             }
             else
             {
                 p2geleng = 0;
                 p2angguk = 0;
                 p2m.Push(p2b);
                 p2m.Push(p2a);
             }
         }
         if (p2angguk == 3)
         {
             if (now.ans == question)
             {
                 new System.Threading.Thread(() =>
                 {
                     var c = new System.Windows.Media.MediaPlayer();
                     c.Open(new System.Uri(@Application.StartupPath + "\\s5\\G1Benar.wav"));
                     c.Play();
                 }).Start();
                 _soal           = DateTime.UtcNow.AddSeconds(4);
                 picP2BS.Image   = Image.FromFile(Application.StartupPath + "\\s5\\1.png");
                 picP2BS.Visible = true;
                 tmrBS2.Enabled  = true;
                 p2score        += 100;
                 pp2.Text        = p2score.ToString();
                 p2lock          = true;
                 p1lock          = true;
                 cek();
             }
             else
             {
                 new System.Threading.Thread(() =>
                 {
                     var c = new System.Windows.Media.MediaPlayer();
                     c.Open(new System.Uri(@Application.StartupPath + "\\s5\\G1Salah.wav"));
                     c.Play();
                 }).Start();
                 picP2BS.Image   = Image.FromFile(Application.StartupPath + "\\s5\\0.png");
                 picP2BS.Visible = true;
                 tmrBS2.Enabled  = true;
             }
         }
         if (p2geleng == 3)
         {
             if (now.ans != question && p2geleng == 3)
             {
                 new System.Threading.Thread(() =>
                 {
                     var c = new System.Windows.Media.MediaPlayer();
                     c.Open(new System.Uri(@Application.StartupPath + "\\s5\\G1Benar.wav"));
                     c.Play();
                 }).Start();
                 _soal           = DateTime.UtcNow.AddSeconds(4);
                 picP2BS.Image   = Image.FromFile(Application.StartupPath + "\\s5\\1.png");
                 picP2BS.Visible = true;
                 tmrBS2.Enabled  = true;
                 p2score        += 100;
                 pp2.Text        = p2score.ToString();
                 p2lock          = true;
                 p1lock          = true;
                 cek();
             }
             else
             {
                 new System.Threading.Thread(() =>
                 {
                     var c = new System.Windows.Media.MediaPlayer();
                     c.Open(new System.Uri(@Application.StartupPath + "\\s5\\G1Salah.wav"));
                     c.Play();
                 }).Start();
                 picP2BS.Image   = Image.FromFile(Application.StartupPath + "\\s5\\0.png");
                 picP2BS.Visible = true;
                 tmrBS2.Enabled  = true;
             }
         }
     }
 }
Beispiel #41
0
		void Player_MediaOpened (object sender, EventArgs e)
			{
			this.Top = VideoRectangle.Top;
			this.Left = VideoRectangle.Left;
			Player = sender as MediaPlayer;
			VideoDrawing DrawingFrame = new VideoDrawing ();
			DrawingFrame.Player = Player;
			double SourceAspectRatio = (double)Player.NaturalVideoWidth / (double)Player.NaturalVideoHeight;
			double TargetAspectRation = (double)VideoRectangle.Width / (double)VideoRectangle.Height;
			int NewWidth;
			int NewHeight;
			if (TargetAspectRation >= SourceAspectRatio)
				{
				NewHeight = (int) VideoRectangle.Height;
				NewWidth = (int)(VideoRectangle.Height * SourceAspectRatio);
				}
			else
				{
				NewWidth = (int) VideoRectangle.Width;
				NewHeight = (int)(VideoRectangle.Width / SourceAspectRatio);
				}
			//Rect CorrectedVideoRect = new Rect (VideoRectangle.Left, VideoRectangle.Top, NewWidth, NewHeight);
			Rect CorrectedVideoRect = new Rect (0, 0, NewWidth, NewHeight);
			this.MinWidth = NewWidth;
			this.MinHeight = NewHeight;
			DrawingFrame.Rect = CorrectedVideoRect;
						/*
						DrawingFrame.Rect = VideoRectangle;
						 */
			if (TimeToStop == DateTime.MinValue)
				TimeToStop = DateTime.Now + Player.NaturalDuration.TimeSpan;
			TimeSpan UnchangedDuration = (TimeToStop - DateTime.Now)
					- FadingDuration - FadingDuration - TimeSpan.FromMilliseconds (500);
			SetAnimationParameter (m_AnimationStoryBoard, FadingDuration, UnchangedDuration, FadingDuration,
				this, new PropertyPath (Window.OpacityProperty));
			this.Visibility = System.Windows.Visibility.Visible;
			m_AnimationStoryBoard.Begin (this);
			Player.Play ();
			DrawingBrush VideoBrush = new DrawingBrush (DrawingFrame);
			this.SizeToContent = SizeToContent.WidthAndHeight;
			this.Background = VideoBrush;
			if (Basics.IsTestRun)
				Basics.ReportInformationToEventViewer ("VideoWindow.Player_MediaOpened",
					"Player started mit File \"" + Player.Source.LocalPath
					+ "\"\r\nMinWidth = " + Convert.ToString (MinWidth)
					+ ", MinHeight = " + Convert.ToString (MinHeight)
					+ "\r\nTop = " + Convert.ToString (Top)
					+ ", Left = " + Convert.ToString (Left));
			this.Topmost = true;
			}
        /// <summary>
        /// Met à jour les messages
        /// </summary>
        private async void UpdateMessages(System.Windows.Controls.ListView lv)
        {
            using (LobbyService.LobbyServiceClient client = new LobbyService.LobbyServiceClient())
            {
                var lstMessages = await Task.Run(() => client.GetNewMessageFrom(UserSessionSingleton.Instance.UserToken.Value, _receiverName));

                bool newMsg = false;

                if (lstMessages.Count > 0)
                    newMsg = true;

                foreach (LobbyService.UserMessage um in lstMessages)
                    lv.Items.Add(um);

                if(lv.Items.Count > 0)
                    lv.ScrollIntoView(lv.Items[lv.Items.Count - 1]);

                if (newMsg)
                {
                    _mediaPlayer = new MediaPlayer();
                    _mediaPlayer.MediaFailed += (o, args) =>
                    {
                        MessageBox.Show("Media Failed!!");
                    };
                    _mediaPlayer.Open(new Uri("Sounds/MSN Sound.mp3", UriKind.RelativeOrAbsolute));
                    _mediaPlayer.Play();

                    var helper = new FlashWindowHelper(Application.Current);
                    // Flashes the window and taskbar 5 times and stays solid 
                    // colored until user focuses the main window
                    helper.FlashApplicationWindow(); 
                }
            }
        }
Beispiel #43
0
 /// <summary>
 /// 再生
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void PlayButton_Click(object sender, RoutedEventArgs e)
 {
     player.Play();
     isPaused = false;
 }