Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Playing MP3 with VB6

Posted on 2009-02-10
7
Medium Priority
?
1,050 Views
Last Modified: 2013-12-20
Hi Experts,

Can you advise me what i need to play MP3 files from VB6
please not to complex, I'm still a newbie in VB :)


Regards,
Murph
0
Comment
Question by:theo kouwenhoven
  • 4
  • 3
7 Comments
 
LVL 15

Expert Comment

by:JackOfPH
ID: 23608976
Assalam-o-Alaikum Chudzidiot
      Here is the answer regarding to your question in which you said for code to play .MP3 song by VB5/6 coding. This code is working very well. Let’s try and give me feed back. You may run any file which have any format like .MP3, .WAV etc. You can use text2.text value for progress bar change. If you can’t do it, then reply, I will do it for you…. Thanks

Steps:-
      1:  Start new project (form1 will be automatically add)
      2: Add two command buttons automatically named to “command1” & “command2”
      3: Add two text boxes automatically named to “text1” & “text 2”
      4: Add a timer control automatically named to “timer1”, set its “interval” to 500, and “enabled” property to false.
      5: Paste all this code in form’s code window
      6: Change the file path name in  {Form1.FilePath = "D:\MP3SONGS\BAS.MP3"} line as required.
      6: Save the project and run.
     

‘Code Starts From Here
‘---------------------------
Option Explicit
Private Declare Function mciSendStringA Lib "winmm.dll" _
(ByVal lpstrCommand As String, ByVal _
lpstrReturnString As String, ByVal uReturnLength As Long, _
ByVal hwndCallback As Long) As Long

Public Temp As Integer, ReturnString As String, FilePath As String, Abc As Variant

Public Function SendMCIcommand(TheCommand As String) As String
    ReturnString = String$(128, " ")
    Temp = mciSendStringA(TheCommand, ReturnString, 127, 0)
    SendMCIcommand = ReturnString
End Function

Private Sub Command1_Click()
    Form1.FilePath = "D:\MP3SONGS\BAS.MP3"
    Form1.Abc = SendMCIcommand("open " & Form1.FilePath)
    Form1.Abc = SendMCIcommand("play " & Form1.FilePath)
    Form1.Timer1.Enabled = True
End Sub

Private Sub Command2_Click()
    Form1.Abc = SendMCIcommand("close " & Form1.FilePath)
    Form1.Timer1.Enabled = False
End Sub

Private Sub Form_Unload(Cancel As Integer)
    Unload form1
End Sub

Private Sub Timer1_Timer()
    Form1.Text1.Text = SendMCIcommand("status " & Form1.FilePath & " length")
    Form1.Text2.Text = SendMCIcommand("status " & Form1.FilePath & " position")
End Sub

‘---------------------------
 ‘Code Ends To Here
0
 
LVL 16

Author Comment

by:theo kouwenhoven
ID: 23609713
Hey JackOfPH,

looks good, but is there a way to skip to a specific point in a mp3?
is there volume controll that is secific for this object,
so if I create SendMCIcommand1 and SendMCIcommand2 thet they will not interfere?

Thanks already !!!

Regards,
Murph
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 15

Expert Comment

by:JackOfPH
ID: 23618396
I think you have to create your own class for this...

0
 
LVL 15

Accepted Solution

by:
JackOfPH earned 600 total points
ID: 23618412
0
 
LVL 16

Author Comment

by:theo kouwenhoven
ID: 23664144
creating classes is not something a newbie  can do :(

I'm now trying to use "ActiveMovie control Library"
but strugeling with an incorrect duration time :(
0
 
LVL 16

Author Closing Comment

by:theo kouwenhoven
ID: 31545220
Not the right answer, but if brought me to find a solution with 'active Movie Control'
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question