Results 1 to 8 of 8

Thread: Playing music

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2009
    Posts
    138

    Playing music

    Hello everybody!

    I want when I click on some button, computer run some music file from specified path (for example C:\path) and to start playing music from this file but without running any programs, just like background of the program.

    Thanks!

  2. #2
    Addicted Member DramaQueen's Avatar
    Join Date
    Mar 2010
    Posts
    187

    Re: Playing music

    Try the mediaplayer control, it's very simple.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jan 2009
    Posts
    138

    Re: Playing music

    Sorry, where do you see 'mediaplayer' control in Visual Studio 2008?!
    Last edited by hepeci; Apr 22nd, 2010 at 04:21 PM.

  4. #4
    Addicted Member
    Join Date
    Sep 2008
    Posts
    149

    Re: Playing music

    Go to Solution Explorer -> Add reference -> In the COM tab find Windows Media Player and add to the project. Next add this code:
    Code:
    Public Class Form1
        Dim player As WindowsMediaPlayer
    
        Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            Dim player As New WindowsMediaPlayer
            player.URL = path_to_the_file
        End Sub
    End Class

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jan 2009
    Posts
    138

    Re: Playing music

    OK, this works. But, how to stop music in some moment?

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Jan 2009
    Posts
    138

    Re: Playing music

    Actually, when I click button I want that program stop reproducing song.

  7. #7
    Lively Member
    Join Date
    Jan 2010
    Location
    United Kingdom
    Posts
    115

    Re: Playing music

    In the click event of your stop button add the following:

    Code:
    player.Ctlcontrols.stop()
    Regards
    Colin

    If my comments helped please remember to add to my reputation using Rate This Post.

    If your problem has been resolved please mark the thread resolved using the "Mark Thread Resolved" link in thread tools.

    CodeBank Submissions: 1) WebBrowser - Delete cookies etc 2) Import My.Settings from previous build version

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Jan 2009
    Posts
    138

    Re: Playing music

    @wearcm, when I type your code program tell me following error:

    Object variable or With block variable not set.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width