Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Playing mp3's as background music 2

Status
Not open for further replies.

Jooky68

Programmer
Jul 10, 2002
231
US
I am attempting to play mp3's as background music whenever my program opens up, and i have two questions.

1. I am currently doing it through windows media play...
'********************************************************
Private WithEvents p As MediaPlayer.MediaPlayer

Private Sub Play_Click()
p.Open "C:\Documents and Settings\Paul Juckiewicz\My Documents\My Music\80's U2 - Sunday Bloody Sunday.mp3"
End Sub

Private Sub Stop_Click()
p.stop
End Sub

Private Sub Form_Load()
Set p = New MediaPlayer.MediaPlayer
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
p.stop
Set p = Nothing
End Sub
'******************************************************
If I put my program on someones computer that doesnt have windows media play...will it still play????



2. I am looking for another way to play the file, is there a api call that can recognize mp3 files.

Basically im looking for what people think is the best method for playing music for background purposes in my program. Thanks in advance
 
u dont have to worry about components not exisiting because when u use P&D wizard it will give u all the components. therefore it will work in any system (where the setup is run)... about the api thing try Win32API forum for VB....

Known is handfull, Unknown is worldfull
 
Use the MCISendString API, something like:
Also you can't use long file names so you'll have to use GetShortPathName API.


Option Explicit

Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long

Private Sub Command1_Click()
Dim ret As Long
ret = mciSendString("OPEN C:\MyFolder\MyMP3.mp3 Alias MyMP3", 0, 0, 0)
ret = mciSendString("Play MyMP3", 0, 0, 0)
End Sub

 
Why not use the Microsoft MultiMedia Control 6.0 SP3? Look in Project|Components etc. It's the MCI32.OCX

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
I am not to familiar with the Microsoft MM control...does anyone have sample coding of playing an mp3, or any file for that matter.

Also I tried the MCISendstring command and I couldnt get it to play. I am wondering if the path was too long and thats why.
 
Add the control to your project:

Project|Components|Microsoft MultiMedia Control

Then just stick a Media Control called 'mp1' on your form and use:

mp1.FileName = "C:\new.wma"
mp1.Play

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
johnwm,
I tried using the multimedia control, but that did not work as suggested. However the Microsoft Media Player Control worked like a charm.
 
Johnwm,
I could not get the multimedia control to play mp3's.
 
that will happen only if the multimedia component can play mp3. i think it can...

Known is handfull, Unknown is worldfull
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top