Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Put sound on own simple program

Put sound on own simple program

Scheduled Pinned Locked Moved C#
csharphelpquestion
8 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    MorganSim
    wrote on last edited by
    #1

    Have been trying up an easy program, but now want to try make it more user friendly by maybe playing a song in the background. How can I go about this one.Anyone help please.(C# base). :((

    D P 2 Replies Last reply
    0
    • M MorganSim

      Have been trying up an easy program, but now want to try make it more user friendly by maybe playing a song in the background. How can I go about this one.Anyone help please.(C# base). :((

      D Offline
      D Offline
      DaveyM69
      wrote on last edited by
      #2

      It depends on how you want to do it. The simplest way is:

      System.Media.SoundPlayer soundPlayer = new System.Media.SoundPlayer();
      soundPlayer.SoundLocation = @"c:\chord.wav"; // full path to file
      soundPlayer.Play();

      Don't forget to call soundPlayer.Dispose() when you're finished with it!

      Dave
      BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
      Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)

      M 1 Reply Last reply
      0
      • M MorganSim

        Have been trying up an easy program, but now want to try make it more user friendly by maybe playing a song in the background. How can I go about this one.Anyone help please.(C# base). :((

        P Offline
        P Offline
        PIEBALDconsult
        wrote on last edited by
        #3

        Sounds user hostile to me.

        M 1 Reply Last reply
        0
        • P PIEBALDconsult

          Sounds user hostile to me.

          M Offline
          M Offline
          MorganSim
          wrote on last edited by
          #4

          What's that supposed to mean?:confused:

          P 1 Reply Last reply
          0
          • D DaveyM69

            It depends on how you want to do it. The simplest way is:

            System.Media.SoundPlayer soundPlayer = new System.Media.SoundPlayer();
            soundPlayer.SoundLocation = @"c:\chord.wav"; // full path to file
            soundPlayer.Play();

            Don't forget to call soundPlayer.Dispose() when you're finished with it!

            Dave
            BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
            Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)

            M Offline
            M Offline
            MorganSim
            wrote on last edited by
            #5

            Thanks alot that helped and am able to get through.could have kissed you if you were next to me.(just a jok) Now check here, that method can only work with .wav file type only? or you can use other files(file size for a wav file is too large). waiting.... Thanks alot :doh:

            D D 2 Replies Last reply
            0
            • M MorganSim

              What's that supposed to mean?:confused:

              P Offline
              P Offline
              PIEBALDconsult
              wrote on last edited by
              #6

              The user may not want sound playing.

              1 Reply Last reply
              0
              • M MorganSim

                Thanks alot that helped and am able to get through.could have kissed you if you were next to me.(just a jok) Now check here, that method can only work with .wav file type only? or you can use other files(file size for a wav file is too large). waiting.... Thanks alot :doh:

                D Offline
                D Offline
                Dan Neely
                wrote on last edited by
                #7

                IT would have taken less time to change your code to point to an .mp3 file than it did to post the question here.

                Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots. -- Robert Royall

                1 Reply Last reply
                0
                • M MorganSim

                  Thanks alot that helped and am able to get through.could have kissed you if you were next to me.(just a jok) Now check here, that method can only work with .wav file type only? or you can use other files(file size for a wav file is too large). waiting.... Thanks alot :doh:

                  D Offline
                  D Offline
                  DaveyM69
                  wrote on last edited by
                  #8

                  You may be better off embedding media player. Right click on your toolbox and select Chose Items (you may have to wait a while for the next dialog!). Click on the COM Components tab and scroll down and select Windows Media Player. Drag and drop (& resize) a WMP onto your form. Set the URL property to point to your file and you're done.

                  Dave
                  BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
                  Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups