0

Following is a portion of my project code.It contain a Timer,Windows Media Player,etc. This project does, here five user given times and when to reach this times to current time, then WMP will play. Can you please suggest a code to: while playing this in WMP,mute all other sounds,only WMP's sound should be heard.

 public void play(string tune)
    {          
        if (label1.Text == label6.Text || label2.Text == label6.Text || label3.Text == label6.Text || label4.Text == label6.Text || label5.Text == label6.Text)
        {
            axWindowsMediaPlayer1.URL = tune;
            if (label6.Text == label1.Text)
            {
                DialogResult yn = MessageBox.Show("Times to reach pray LUHAR", "Attention Pls:", MessageBoxButtons.OK);
                if (yn == DialogResult.OK) { axWindowsMediaPlayer1.Ctlcontrols.stop(); }

            }
            else if (label6.Text == label2.Text)
            {
              DialogResult yn = MessageBox.Show("Times to reach pray ASAR", "Attention Pls:", MessageBoxButtons.OK);
              if (yn == DialogResult.OK) { axWindowsMediaPlayer1.Ctlcontrols.stop(); }
            }
            else if (label6.Text == label3.Text)
            {
                DialogResult yn = MessageBox.Show("Times to reach pray MAGRIB", "Attention Pls:", MessageBoxButtons.OK);
                if (yn == DialogResult.OK) { axWindowsMediaPlayer1.Ctlcontrols.stop(); }
            }
            else if (label6.Text == label4.Text) 
            {
                DialogResult yn = MessageBox.Show("Times to reach pray ISHAH", "Attention Pls:", MessageBoxButtons.OK);
                if (yn == DialogResult.OK) { axWindowsMediaPlayer1.Ctlcontrols.stop(); }
            }
            else if (label6.Text == label5.Text)
            {
                DialogResult yn = MessageBox.Show("Times to reach pray SUBAH", "Attention Pls:", MessageBoxButtons.OK);
                if (yn == DialogResult.OK) { axWindowsMediaPlayer1.Ctlcontrols.stop(); }
            }
        }


    }
devavx
  • 1,035
  • 9
  • 22
suhail mc
  • 29
  • 1
  • 9
  • 1
    Actually its Zuhr, not luhar! – Afzaal Ahmad Zeeshan Sep 13 '13 at 11:53
  • 1
    Classic "What if two programs did this?" scenario - what happens if someone else's program also wants to play audio and exclude all other audio at the same time? – Damien_The_Unbeliever Sep 13 '13 at 12:08
  • @Damien_The_Unbeliever, which is fine. I really wish those on stack would try to answer questions rather than point out issues at times. For example, if this is for an industrial application where I have full control over the system and am making the decision that there is be no other applications trying to override mine, on a singular purpose computer, I would like this kind of functionality. There are always exceptions to rules. – Jarrod Christman Aug 27 '21 at 14:57
  • @JarrodChristman - if you have full control over the system, you don't need to try to mute other applications by overriding their own behaviour. You design the system such that they're not competing for the user's attention in the first place. – Damien_The_Unbeliever Aug 30 '21 at 16:25
  • @Damien_The_Unbeliever, incorrect. I may not have control over the software that also runs on it, even if I have full control of the computer. For example, in my case I have a system that does overhead PA messages for a warehouse, it has multiple applications. For 100% sure, mine would get audio priority over the others, yet I don't have control over the other software. Again, avoid assuming the why and just answer the how, so much more useful for people that pass by the stack topic even if the OP was going about the problem wrong for their scenario. – Jarrod Christman Aug 31 '21 at 17:37
  • @Damien_The_Unbeliever, "You design the system such that they're not competing for the user's attention in the first place." Which is another assumption made on your part, rather than it being a standalone system, with no user interaction (a headless system for the most part). Again, do not assume the why, it leads to bad advice. – Jarrod Christman Aug 31 '21 at 17:39

0 Answers0