Continuous media player in VB

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ruckfules99
    New Member
    • Feb 2009
    • 12

    Continuous media player in VB

    I'm always so close to being done my "game" and then i think of adding something new to it....

    I know that in vb 6.0 that there is a "windows media player" tool, but it only allows you to play one song, not a different song after one is finished. So i searched on youtube and found a video



    and in this video he shows that his code actually works, so i thought i'd use it...but im getting a problem..

    This is the code im having problems with....Everyti me i click "Add file" (Please watch the video is a important point to understanding what im saying) i get and error message and it highlights the code ".Dialog Title = " Open Media..." if someone can tell me whats wrong and how to fix it...or if you know another way to make files that play after one another Thank you.

    *Below is the whole code*

    Code:
    Private Sub Command1_Click()
    Dim sFile As String
    
        With CommonDialog1
        .Dialog Title = " Open Media..."
              .CancelError = False
        .Filter = "All Suported Files"
                     .ShowOpen
            If Len(.FileName) = 0 Then
                Exit Sub
            End If
            sFile = .FileName
            
        With List1
                .AddItem sFile
                End With
                End With
                End Sub
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    just change your code to the following.

    Code:
    Private Sub Command1_Click()
    Dim sFile As String
        With CommonDialog1
        .DialogTitle = " Open Media..."
              .CancelError = False
        .Filter = "All Suported Files"
                     .ShowOpen
            If Len(.FileName) = 0 Then
                Exit Sub
            End If
            sFile = .FileName
        With List1
                .AddItem sFile
                End With
                End With
    End Sub
    
    Private Sub List1_Click()
    WindowsMediaPlayer1.URL = List1
    End Sub
    you have a typo(an extra space) in the code

    Comment

    • ruckfules99
      New Member
      • Feb 2009
      • 12

      #3
      Originally posted by debasisdas
      just change your code to the following.

      Code:
      Private Sub Command1_Click()
      Dim sFile As String
          With CommonDialog1
          .DialogTitle = " Open Media..."
                .CancelError = False
          .Filter = "All Suported Files"
                       .ShowOpen
              If Len(.FileName) = 0 Then
                  Exit Sub
              End If
              sFile = .FileName
          With List1
                  .AddItem sFile
                  End With
                  End With
      End Sub
      
      Private Sub List1_Click()
      WindowsMediaPlayer1.URL = List1
      End Sub
      you have a typo(an extra space) in the code

      Thanks for your help! the code is working except when i click "add file" it doesnt open up a window where i can search for a music file to play in my media player...What do i do please reply back

      Comment

      • vdraceil
        New Member
        • Jul 2007
        • 236

        #4
        You have added CommonDialog control to your toolbox,right?!
        Type in the firstline of command button's click event..

        CommonDialog1.S howOpen

        Comment

        • debasisdas
          Recognized Expert Expert
          • Dec 2006
          • 8119

          #5
          that line is already there in the code .

          Comment

          • vdraceil
            New Member
            • Jul 2007
            • 236

            #6
            Oh,sorry i missed that line..
            CommonDialog box shows up,file opens,song plays...everyth ing is fine when i created a sample project with all those components.
            No problem with the code too..

            Comment

            • ruckfules99
              New Member
              • Feb 2009
              • 12

              #7
              Thank you so much! I found my problem i didnt add a commondialog the whole time! no wonder i was having issues! Thank you guys for putting up with my stupidness!
              Last edited by ruckfules99; Feb 12 '09, 08:24 PM. Reason: Spelling mistake

              Comment

              Working...