public void NextSong(Playlist playlist, Label txtKron, ProgressBar progress, bool isSpectrumOn)
 {
     i = 0;
     if (currentSongID != -1)
     {
         if (currentSongID < playlist.playlistSize - 1)
         {
             SongNameLabel(txtKron, playlist.listOfFiles[++currentSongID][1]);
             if (playlist.listOfFiles[currentSongID][2] == ".wav" && isSpectrumOn == true)
             {
                 AsynchronousClient.StartClient(playlist.listOfFiles[currentSongID][0]);
             }
             _player.Stop();
             Uri uri = new Uri(playlist.listOfFiles[currentSongID][0]);
             _player.Open(uri);
             _player.Play();
         }
         else if (currentSongID == playlist.playlistSize - 1)
         {
             SongNameLabel(txtKron, playlist.listOfFiles[0][1]);
             _player.Stop();
             if (playlist.listOfFiles[0][2] == ".wav" && isSpectrumOn == true)
             {
                 AsynchronousClient.StartClient(playlist.listOfFiles[0][0]);
             }
             Uri uri = new Uri(playlist.listOfFiles[0][0]);
             currentSongID = 0;
             _player.Open(uri);
             _player.Play();
         }
     }
 }
Exemple #2
0
 public void load(MediaPlayer mp,String file)
 {
     mp.Position = TimeSpan.Zero;
     string url = @"C:\Users\Asura\Documents\Visual Studio 2012\Projects\Project Labyrinth(C-Sharp)\Pro Labyrinth(C-Sharp)\Sound\"+file+".wav";
     mp.Open(new Uri(url, UriKind.Relative));
     mp.Volume = 100;
 }
Exemple #3
0
        public void PlayBackgroundMusic(int mfxID)
        {
            if (mfxID < 1 || mfxID >= m_music.Count)
            {
                throw new ArgumentOutOfRangeException("mfxID", "The MFX id is out of range. Use the 1-based index that matches the number in the file name.");
            }

            Action _func = () =>
            {
                m_songPlayer.Stop();
                m_songPlayer.Close();
                m_songPlayer.Open(m_music[mfxID - 1]);
                m_songPlayer.Play();
            };

            //when changing the map, the background music will be played from a different thread than the main
            //	one since it is all being done in a callback from the received network data. This requires a
            //	dispatcher to invoke the song change on the m_songPlayer, otherwise an exception is thrown because
            //	the thread does not 'own' the m_songPlayer object.
            if (m_dispatcher.Thread != Thread.CurrentThread)
            {
                m_dispatcher.BeginInvoke(_func);
            }
            else
            {
                _func();
            }
        }
 /// <summary>
 /// Funkcja wątku odtwarzania muzyki w tle
 /// </summary>
 public static void MusicThreadFunc()
 {
     try
     {
         mp = new MediaPlayer();
         mp.Open(new System.Uri(Path.GetFullPath(@"background_music.wav")));
         mp.Volume = (double)MusicVolumeTrackBar.Value / 10;
         mp.Play();
     }
     catch { }
     while (!music_stop)
     {
         if (music_changed)
         {
             if (MuteCheckbox.Checked)
             {
                 mp.Volume = 0;
                 music_changed = false;
             }
             else
             {
                 mp.Volume = (double)MusicVolumeTrackBar.Value / 10;
                 music_changed = false;
             }
         }
     }
     if(mp!=null)
     mp.Stop();
        music_stop = false;
 }
        /// <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();
        }
Exemple #6
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();
 }
Exemple #7
0
        public Form1()
        {
            InitializeComponent();
            this.KeyPreview = true;
            readPath();
            foreach (Control c in this.groupBox1.Controls)
            {
                if (c.GetType() == typeof(Button))
                {
                    Button b = (Button)c;
                    if (b.Text.Equals("ignore"))
                    {
                        continue;
                    }

                    b.MouseDown  += new MouseEventHandler(button_pressed);
                    b.MouseUp    += new MouseEventHandler(button_released);
                    b.MouseLeave += new EventHandler(button_leave);

                    deviceMap.Add(b.Tag.ToString(), null);
                    load(b.Tag.ToString());
                }
                if (c.GetType() == typeof(CheckBox))
                {
                    CheckBox cb = (CheckBox)c;
                    cb.CheckedChanged += new EventHandler(checked_chagned);
                }
            }

            button37_Click(null, null);
            this.listBox1.MouseDoubleClick += new MouseEventHandler(list_double_clicked);



            toolTip1.SetToolTip(this.button43, "Save current score to clipboard");
            toolTip2.SetToolTip(this.checkBox37, "Turn on/off piano key sound");

            toolTip3.SetToolTip(this.button37, "Preset C,D,E of 2,3,4 octave. The default");

            toolTip4.SetToolTip(this.listBox1, "Double click on selected item to replay note from history");

            toolTip5.SetToolTip(this.progressBar1, "Streak of 20 to win the game!");


            toolTip6.SetToolTip(this.button40, "Also shortcut 'space' to next!");

            toolTip7.SetToolTip(this.button41, "Also shortcut 'r' to repeat!");

            System.Threading.Thread.Sleep(500);

            var c1 = new System.Windows.Media.MediaPlayer();

            c1.Open(new System.Uri(Path.GetFullPath(@"res/loading.wav")));


            deviceMap.Add("loading.wav", c1);
            System.Threading.Thread.Sleep(500);
            c1.Play();
        }
Exemple #8
0
 static Music()
 {
     Sound.MusicVolumeChanged += Sound_MusicVolumeChanged;
     player = new MediaPlayer();
     player.Volume = Sound.MusicVolume;
     player.MediaEnded += Player_MediaEnded;
     player.Open(new Uri(Sound.BackgroundPath, UriKind.Relative));
 }
Exemple #9
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 AudioPlayer(string filename)
 {
     Patterns.ActIgnoringExceptions(() =>
     {
         me = new MediaPlayer();
         me.Open(new Uri(filename, UriKind.RelativeOrAbsolute));
         me.MediaEnded += me_MediaEnded;
     });
 }
Exemple #12
0
        private void load(String note_octave)
        {
            var c = new System.Windows.Media.MediaPlayer();

            c.Volume = 0.5;
            c.Open(new System.Uri(Path.GetFullPath(getAudioPath(note_octave))));
            deviceMap[note_octave] = c;
            System.Threading.Thread.Sleep(100);
        }
Exemple #13
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();
        }
Exemple #14
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();
		}
Exemple #15
0
        private void OkButton_Click(object sender, RoutedEventArgs e){
            MediaPlayer checker = new MediaPlayer();

            checker.Open(new Uri(PathTB.Text, UriKind.RelativeOrAbsolute));
            if (PathTB.Text == "" || AuthorTB.Text == "" || TitleTB.Text == ""){
                MessageBox.Show("Author or Title or Path is Empty");
                return; }
            else this.Close(); 
        }
 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();
 }
Exemple #17
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 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();
        }
        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();
     }
 }
Exemple #21
0
        public void CaptureBitMaps(string url)
        {
            MediaPlayer mediaPlayer = new MediaPlayer();
              mediaPlayer.MediaOpened += Mp_MediaOpened;
              mediaPlayer.ScrubbingEnabled = true;

              mediaPlayer.Open(new Uri(url));
              mediaPlayer.Changed += MediaPlayer_Changed;
              mediaPlayer.Position = TimeSpan.FromSeconds(0);
              mediaPlayer.SpeedRatio = 1;
            //      mediaPlayer.Play();
              mediaPlayer.MediaEnded += MediaPlayer_MediaEnded;
        }
Exemple #22
0
        public Enemy(Vector position, Player player, string text, int depth)
            : base(position, player, text)
        {
            _depth = depth;
            Damage = 33;
            TypingText.Layer = 0.5;

            _killSound = new MediaPlayer();
            _killSound.Open(new Uri(@"..\..\Resources\Audio\kill.mp3", UriKind.Relative));

            Matched += _killSound.Stop;
            Matched += _killSound.Play;
        }
Exemple #23
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 { }
        }
Exemple #24
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);
            }
        }
Exemple #25
0
 static Jet()
 {
     Sound.SoundVolumeChanged += SoundVolumeChanged;
     players = new List<MediaPlayer>();
     for (int i = 0; i <= 4; i++)
     {
         MediaPlayer player = new MediaPlayer();
         player.Volume = Sound.SoundVolume;
         player.MediaEnded += Player_MediaEnded;
         player.Open(new Uri(string.Format("Sounds/jet0{0}.wav", i), UriKind.Relative));
         players.Add(player);
     }
 }
Exemple #26
0
        private void OpenFileButton_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();

            dialog.Filter = "wav files (*.wav)|*.wav|All files (*.*)|*.*";
            if (dialog.ShowDialog() == true)
            {
                if (player.Source != null)
                {
                    player.Close();
                }
                player.Open(new Uri(dialog.FileName, UriKind.Absolute));
            }
        }
Exemple #27
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());
                    }
                }
            }));
        }
        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;
        }
Exemple #29
0
        public MainWindow()

        {
            InitializeComponent();
            player = new Player(myCanvas, this);
            mediaPlayer.Open(new Uri("TrueArt.mp3", UriKind.Relative));
            background = new Tapper.Background(myCanvas, this);

            gameTimer.Tick    += gameTimer_Tick;
            gameTimer.Interval = new TimeSpan(0, 0, 0, 0, 100 / 60);
            gameState          = Gamestate.SplashScreen;
            gameTimer.Start();
            mediaPlayer.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);
        }
        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);
        }
Exemple #32
0
        protected Item(Vector position, Player player, Level level, string text)
            : base(position, player, text)
        {
            CurrentLevel = level;

            //Inventory is a WIP!
            //Matched += PickUp;
            Matched += Activate;

            var pickupSound = new MediaPlayer();
            pickupSound.Open(new Uri(@"..\..\Resources\Audio\pickup.mp3", UriKind.Relative));

            Matched += pickupSound.Stop;
            Matched += pickupSound.Play;
        }
        public AudioPanel(string file)
        {
            InitializeComponent();
            player = new MediaPlayer();
            player.Open(new Uri(file));
            lblPosition.Content = String.Format("{0} / {1}", player.Position.ToString(@"mm\:ss"), player.NaturalDuration.ToString());
            slidePosition.Value = 0;

            DispatcherTimer timer = new DispatcherTimer();
            timer.Interval = TimeSpan.FromMilliseconds(100);
            timer.Tick += timer_Tick;
            timer.Start();
            if (player.NaturalDuration.HasTimeSpan)
                slidePosition.Maximum = player.NaturalDuration.TimeSpan.Ticks;
        }
Exemple #34
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




        }
Exemple #35
0
        private Player player1, player2; //player 1 and player 2 intialized

        #endregion Fields

        #region Constructors

        //the main window class
        public GameFlow(MainWindow mWindow)
        {
            db = new Database();                //database intialized to new database
            media = new MediaPlayer();
            mainWindow = mWindow;

            p1First = true;                     //condition who goes first set to 1
            player1 = null;
            player2 = null;
            changeState(STATES.Menu);           //when on the menu window

            media.MediaEnded += media_MediaEnded;
            media.MediaOpened += media_Opened;
            media.Open(new Uri(@"Resources\Media\Elevator.mp3", UriKind.Relative));
        }
Exemple #36
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));
                });
            }
        }
		public AboutBox()
		{
			InitializeComponent();

			Gif.StartAnimation();

			_mp = new MediaPlayer();
			_mp.MediaEnded += (o, e) =>
			{
				_playing = false;
				Gif.StopAnimation();
				Gif.GifSource = "/HtmlEditor;component/Images/click.gif";
				Gif.StartAnimation();
			};
			_mp.Open(new Uri("Images/pbj.mp3", UriKind.Relative));
		}
Exemple #38
0
        public void Init(MyModel mm)
        {
            this.mm = mm;
            Uri myValidMediaUri = new Uri(@"D:\Download\OdeToTheBrainCut.avi");

            MediaPlayer mp = new MediaPlayer();
            mp.Open(myValidMediaUri);
            vd = new VideoDrawing();
            vd.Player = mp;
            DrawingBrush db = new DrawingBrush();
            db.Drawing = vd;

            INameScope ins = NameScope.GetNameScope(mm.root);
            DiffuseMaterial dif = ins.FindName("dif") as DiffuseMaterial;
            dif.Brush = db;
            vd.Player.Play();
        }
Exemple #39
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
        }
        static double GetPodcastLength(string uri)
        {
            MediaPlayer player = new MediaPlayer();
            //Something is wrong. It dies here.
            player.Open(new Uri(uri, UriKind.Absolute));

            double returnLength = 0;

            if (player.NaturalDuration.HasTimeSpan)
            {
                returnLength = player.NaturalDuration.TimeSpan.TotalSeconds;
            }

            player.Close();

            return returnLength;
        }
Exemple #41
0
 private void Prepaer_DoWork()
 {
     SongName.Content = "正在加载歌曲ing";
     media.Open(new Uri(GetUri()));
     while (!media.NaturalDuration.HasTimeSpan)
     {
         Thread.Sleep(10);
     }
     GetTime();
     //Time 更新时间戳
     System.Windows.Threading.DispatcherTimer myTimer = new System.Windows.Threading.DispatcherTimer();
     myTimer.Tick    += new EventHandler(TimeChanged);
     myTimer.Interval = new TimeSpan(0, 0, 0, 1);
     SongName.Content = Data.SelcetMusic.SongName;
     myTimer.Start();
     media.Play();
 }
        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();
        }
Exemple #43
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();
        }
        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;
        }
        public MainWindow()
        {
            InitializeComponent();

            //play music
            mediaPlayer.Open(new Uri("ragTimeMusic.mp3", UriKind.Relative));
            //NIU mediaPlayer.Play();

            //ragtime music: http://freemusicarchive.org/music/Scott_Joplin/Frog_Legs_Ragtime_Era_Favorites/Scott_Joplin_-_08_-_Pine_Apple_Rag_1908_piano_roll

            //start timer

            gameTimer.Tick    += gameTimer_Tick;
            gameTimer.Interval = new TimeSpan(0, 0, 0, 0, 1000 / 60);
            gameTimer.Start();

            //add background
            background = new Tapper.Background(myCanvas, this);

            //set gamestate
            gameState = GameState.SplashScreen;
        }
Exemple #46
0
 public void PlayMusic(string link)
 {
     player.Open(new System.Uri(link));
     player.Volume = 100;
     player.Play();
 }
Exemple #47
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);
            }
        }
Exemple #48
0
 public PlayMusic()
 {
     _mp = new System.Windows.Media.MediaPlayer();
     _mp.Open(new Uri(@"E:\ProjecktC#\Tank\TankModel\music.mp3"));
     //mp.Open(new Uri("c:\pathtomedia\MySound.wav"));
 }
Exemple #49
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;
             }
         }
     }
 }
Exemple #50
0
 private void tmrRandom_Tick(object sender, EventArgs e)
 {
     if (counter < 2)
     {
         lblJudul.Text = "Acak Permainan ke - " + (counter + 1).ToString();
         new System.Threading.Thread(() =>
         {
             var c = new System.Windows.Media.MediaPlayer();
             c.Open(new System.Uri(@Application.StartupPath + "\\random\\c.wav"));
             c.Play();
         }).Start();
         if ((_start.AddSeconds(3) - DateTime.UtcNow).Ticks <= 0)
         {
             tmrRandom.Interval = tmrRandom.Interval + 50;
         }
         if ((_start.AddMilliseconds(6000) - DateTime.UtcNow).Ticks <= 0)
         {
             do
             {
                 if (!done[select])
                 {
                     tmrRandom.Enabled  = false;
                     tmrRandom.Interval = 55;
                     done[select]       = true;
                     go();
                     break;
                 }
                 else
                 {
                     select = rnd.Next(0, 7);
                 }
             } while ((done[select]));
         }
         select = rnd.Next(0, 7);
         for (int a = 0; a < 7; a++)
         {
             if (a != select)
             {
                 use[a] = bg[a];
             }
             else
             {
                 use[a] = bgs[a];
             }
         }
         label0.Image = use[0];
         label1.Image = use[1];
         label2.Image = use[2];
         label3.Image = use[3];
         label4.Image = use[4];
         label5.Image = use[5];
         label6.Image = use[6];
     }
     else
     {
         tmrRandom.Enabled = false;
         Akhir akhir = new Akhir(p1, p2);
         p.Stop();
         this.Hide();
         akhir.ShowDialog();
     }
 }
Exemple #51
0
 public void Open(Uri source)
 {
     _internalPlayer.Open(source);
 }
Exemple #52
0
 public MainWindow()
 {
     InitializeComponent();
     mediaPlayer.Open(new Uri("ragtime.mp3", UriKind.Relative));
 }