windows media player in vb6-VBForums
Results 1 to 16 of 16

Thread: windows media player in vb6

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2008
    Posts
    992

    windows media player in vb6

    i have a list of items in a listbox and i when i double click the listbox it plays that song... but what i need to do is that when the song is finished playing(ended), it will start the next song listed on the listbox.

  2. #2
    PowerPoster
    Join Date
    Jan 2008
    Posts
    8,529

    Re: windows media player in vb6

    Maybe you can pull out what you need from this project
    Attached Files Attached Files

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2008
    Posts
    992

    Re: windows media player in vb6

    i cannot open that?

  4. #4
    Super Moderator Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    11,920

    Re: windows media player in vb6

    You need winzip to open that. get it from winzip.com

    The sub you are looking for in that code is

    vb Code:
    1. Private Sub MediaPlayer1_EndOfStream(ByVal Result As Long)
    2. End Sub
    The poster formerly known as koolsid
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved

    Microsoft MVP: 2011 - Till Date IMP Links : Acceptable Use Policy, FAQ

    MyGear:
    Sony VGN-FZ27G with a triple boot between (XP+Office 2003+VB6), (VISTA+Office 2007+VS2008) and (Win7+Office 2010+VS2010) || Sony VPCCB-45FN with a Win7+Office 2010+VS2010. VM: (XP+Office 2003+VB6), (VISTA+Office 2007+VS2008), (Win8+Office 2010+VS2012) || Mac Book Pro (10.6.8) with Office 2011

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2008
    Posts
    992

    Re: windows media player in vb6

    i know, i got winrar... but i cannot open the project my self.

    koolsid i'll try to mess up with that code.

    edit:

    i've tried to use listindex and stuff i cannot find a way to do it.
    Last edited by Justa Lol; Feb 12th, 2009 at 04:05 AM.

  6. #6
    Super Moderator Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    11,920

    Re: windows media player in vb6

    I was able to open the project with no difficulty okay load your project and we will work with that Trust me, once you get the hang of it, it is fun
    The poster formerly known as koolsid
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved

    Microsoft MVP: 2011 - Till Date IMP Links : Acceptable Use Policy, FAQ

    MyGear:
    Sony VGN-FZ27G with a triple boot between (XP+Office 2003+VB6), (VISTA+Office 2007+VS2008) and (Win7+Office 2010+VS2010) || Sony VPCCB-45FN with a Win7+Office 2010+VS2010. VM: (XP+Office 2003+VB6), (VISTA+Office 2007+VS2008), (Win8+Office 2010+VS2012) || Mac Book Pro (10.6.8) with Office 2011

  7. #7
    PowerPoster
    Join Date
    Jan 2008
    Posts
    8,529

    Re: windows media player in vb6

    OK, here is the full source code from that zip file. You will need to add the controls however.
    Code:
    Dim lstindex As Long
    Dim PreviousIndex As Integer
    Dim DefaultPlaylistDirectory As String
    Const TitlebarCaption = "Media Player"
    
    Private Sub Form_Load()
     On Error Resume Next
     
     '
     ' Change below to your default folder where you have your music files
     '
     DefaultPlaylistDirectory = "M:\All of My Music\Every_MP3_I_Have"
    
    
     MediaPlayer1.ShowCaptioning = True
     MediaPlayer1.ShowStatusBar = True
     
     lblBigTitle.Caption = ""
    
     List1.Clear
     List2.Clear
     
     '
     ' Default Playlist
     '
     File1.Path = DefaultPlaylistDirectory
     
     For i = 0 To File1.ListCount - 1
       List1.List(List1.ListCount) = Left(File1.List(i), Len(File1.List(i)) - 4)
       List2.List(List2.ListCount) = File1.Path & "\" & File1.List(i)
     Next i
     
     Caption = TitlebarCaption & " - [" & File1.Path & "]"
     
     lblTotalSelections = "Total Selections: " & List1.ListCount
     
     MediaPlayer1.ClickToPlay = True '.AutoStart = True
    End Sub
    
    Private Sub Form_Resize()
     Dim MeWidth As Long
     Dim MeHeight As Long
     
     On Error Resume Next
     
     If Me.Height < 6060 Then Me.Height = 6060
     If Me.Width < 8625 Then Me.Width = 8625
    
     MeWidth = Me.Width
     MeHeight = Me.Height
    
        Select Case Me.WindowState
            Case vbNormal
    
              List1.Height = Me.Height - 1125
              Me.Height = List1.Height + 1125
    
              MeWidth = Me.Width
              MeHeight = Me.Height
                
            Case vbMinimized
              '
            Case vbMaximized
              List1.Height = Me.Height - 1125
    
              MeWidth = Me.Width
              MeHeight = Me.Height
                
              Me.WindowState = vbNormal
              Me.Move 0, 0, MeWidth, MeHeight
        End Select
    
     Picture3.Height = Me.Height - 750
     Picture4.Height = Me.Height - 750
    
     MediaPlayer1.Height = Picture4.Height - 720
    
     Picture4.Width = Me.Width - 4455
     
     MediaPlayer1.Width = Picture4.Width - 60
     Picture1.Width = Picture4.Width - 60
     lblBigTitle.Width = Picture1.Width - 15
    End Sub
    
    Private Sub List1_DblClick()
     On Error Resume Next
     List1.Selected(lstindex) = False
    
     MediaPlayer1.Stop
     MediaPlayer1.FileName = List2.List(List1.ListIndex)
     
     List1.Selected(lstindex) = False
     
     lblBigTitle.Caption = List1.List(List1.ListIndex)
     
     lstindex = List1.ListIndex
     
     List1.Selected(lstindex) = True
     
     lblNofN.Caption = "Playing " & List1.ListIndex + 1 & " of " & List1.ListCount
    End Sub
    
    Private Sub MediaPlayer1_Click(Button As Integer, ShiftState As Integer, x As Single, y As Single)
     ' Stop
    End Sub
    
    Private Sub MediaPlayer1_EndOfStream(ByVal Result As Long)
     On Error Resume Next
     
     If miPlaySelectedContinue.Checked = True Then
       MediaPlayer1.FileName = List2.List(List1.ListIndex)
     Else
       If Not lstindex = List1.ListCount - 1 Then
         lstindex = lstindex + 1
    
         MediaPlayer1.FileName = List2.List(lstindex)
       
         lblBigTitle.Caption = List1.List(lstindex)
       
         List1.ListIndex = lstindex
       
         List1.Selected(lstindex - 1) = False
         List1.Selected(lstindex) = True
       
         lblNofN.Caption = "Playing " & List1.ListIndex + 1 & " of " & List1.ListCount
       Else
         If miPlayAllContinue.Checked = True Then
           List1.ListIndex = 0
         
           List1.Selected(lstindex) = False
    
           MediaPlayer1.FileName = List2.List(List1.ListIndex)
     
           List1.Selected(lstindex) = False
         
           lblBigTitle.Caption = List1.List(List1.ListIndex)
         
           lstindex = List1.ListIndex
         
           List1.Selected(lstindex) = True
       
           lblNofN.Caption = "Playing " & List1.ListIndex + 1 & " of " & List1.ListCount
         End If
       End If
     End If
    End Sub
    
    Private Sub FileOpen()
     On Error GoTo ErrHandler
    
     Dim vFiles As Variant
     Dim lFile As Long
    
     '
     ' Use Ctrl-A to Select All entries from the dialogbox
     '
     With CommonDialog1
       .FileName = "" 'Clear the filename
       .CancelError = True
       .DialogTitle = "Select File(s)..."
       .Flags = cdlOFNAllowMultiselect Or cdlOFNExplorer Or cdlOFNHideReadOnly 'Flags, allows Multi select, Explorer style and hide the Read only tag
       .Filter = "All files (*.*)|*.*"
       .MaxFileSize = 32767 ' Allows a buffer large enough to hold the total number of file names selected
       .InitDir = DefaultPlaylistDirectory
       .ShowOpen
       vFiles = Split(.FileName, Chr(0)) 'Splits the filename up in segments
        
       '
       ' If there is only 1 file then do this
       '
       If UBound(vFiles) = 0 Then
         List1.Clear
         List2.Clear
         
         List2.AddItem .FileName
         List1.AddItem .FileTitle
         
         k = InStrRev(.FileName, "\")
         
         Caption = TitlebarCaption & " - [" & Left(.FileName, k - 1) & "]"
         
         DefaultPlaylistDirectory = Left(.FileName, k - 1)
         
         lblTotalSelections = "Total Selections: " & List1.ListCount
       Else
         List1.Clear
         List2.Clear
         
         '
         ' More than 1 file then do this until there are no more files
         '
         For lFile = 1 To UBound(vFiles)
           List2.AddItem vFiles(0) + "\" & vFiles(lFile)
           List1.AddItem vFiles(lFile)
         Next
         k = InStrRev(.FileName, "\")
         
         Caption = TitlebarCaption & " - [" & Left(.FileName, k - 1) & "]"
         
         DefaultPlaylistDirectory = Left(.FileName, k - 1)
          
         lblTotalSelections = "Total Selections: " & List1.ListCount
       End If
     End With
    
     Exit Sub
    ErrHandler:
     If Err <> cdlCancel Then
       MsgBox Err.Description
     End If
    End Sub
    
    Private Sub miOpen_Click()
     FileOpen
    End Sub
    Private Sub miPlayAllContinue_Click()
     If miPlayContinue.Checked = True Then
       miPlayContinue.Checked = False
     Else
       miPlayContinue.Checked = True
     End If
    End Sub
    
    Private Sub miPlaySelectedContinue_Click()
     If miPlaySelectedContinue.Checked = True Then
       miPlaySelectedContinue.Checked = False
     Else
       miPlaySelectedContinue.Checked = True
     End If
    End Sub

  8. #8

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2008
    Posts
    992

    Re: windows media player in vb6

    no, i have the code... i cannot open the form.

  9. #9
    PowerPoster
    Join Date
    Jan 2008
    Posts
    8,529

    Re: windows media player in vb6

    What does that mean? Are you saying that when you try to open the .vbp project nothing happens, nothing at all? Something has to take place; I mean I dont believe that it is total silence.

  10. #10

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2008
    Posts
    992

    Re: windows media player in vb6

    when i open the project i get 2 errors then it shows me the code of it not the form...
    and when i try to show the form it gives me an error.

  11. #11
    PowerPoster
    Join Date
    Jan 2008
    Posts
    8,529

    Re: windows media player in vb6

    Well for pete sakes can you not give us a little more info? What do you expect us to do when all you say is i get 2 errors and it gives me an error. We need details. I don't have any problem with it and koolsid didn't have any problems with it so why should you have problems.

  12. #12

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2008
    Posts
    992

    Re: windows media player in vb6

    it wont load MSDXM.ocx and i have it registered...

  13. #13
    PowerPoster
    Join Date
    Jan 2008
    Posts
    8,529

    Re: windows media player in vb6

    Well, that is a totally different problem. So the problem is not with the project but rather with your system not being able to load the OCX. OK, I will send another ZIP file and let's see what that one does.
    Attached Files Attached Files

  14. #14

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2008
    Posts
    992

    Re: windows media player in vb6

    funny, it says file not found, form1.frm.

  15. #15

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2008
    Posts
    992

    Re: windows media player in vb6

    i will just work on my next project and leave this one for later... i'm trying to be first in school to finish it... but that doesnt matter our teacher will help us when we come to the time we need replay and play a list.

  16. #16
    PowerPoster
    Join Date
    Jan 2008
    Posts
    8,529

    Re: windows media player in vb6

    Quote Originally Posted by Justa Lol
    funny, it says file not found, form1.frm.
    Don't worry about that; just go ahead and allow the project to load up and then resave it and that message won't come up again. I think it was just left in the .vbp file after I renamed Form1 to MediaPlayerForm.frm

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.