|
-
Aug 4th, 2000, 02:18 PM
#1
Thread Starter
Lively Member
Hi,
What I want to do is play an mp3 without an activeX control (like MediaPlayer or smthing). I would like it if somebody could send me a example project or the code thet makes clear how to do it (maybe with DirectX 7 --> I already downloaded the sdk).
Thanx
-
Aug 4th, 2000, 03:00 PM
#2
New Member
Truc
Hi,
You can play a MP3 file with win API ot with the MMControl1.
Use the winapi function "Playsnd" if you want to use it.
Rename a MP3 file to a .wav file!
And use this source code.
(You don't need the
Private Sub Form_Load()
'Set the Wait and Notify properties of the MCI control
MMControl1.Wait = True
MMControl1.Notify = False
'Specify the Device type for the MCI control (WaveAudio)
MMControl1.DeviceType = "WaveAudio"
'Specify the MP3 audio file name (with the .WAV extension)
MMControl1.FileName = App.Path & "\mp3samp.wav"
'Open the MCI control
MMControl1.Command = "open"
'Now the MCI control buttons are enabled, click the 'Play button
'to play the sound file.
'You can click the 'Prev', 'Back', 'Stop', 'Pause', etc. to move
'forward and backward or to pause or stop the play.
End Sub
Private Sub Form_Unload(Cancel As Integer)
'You must close the MCI control before closing your application
'to properly manage multimedia resources
MMControl1.Command = "close"
End Sub
For more info mail to:
[email protected]
Or goto http://www.Gabita.com
Regards
GabitaSoft
-
Aug 4th, 2000, 03:15 PM
#3
To my knowledge, you cannot play MP3's with the Multimedia control. You can, however, use DirectX or 3rd Party controls. See this link for more information
-
Aug 4th, 2000, 03:32 PM
#4
Thread Starter
Lively Member
Thanx GabitaSoftVB but your truc in't realy what I'm looking for, what I want to do is to play an mp3 file for my own mp3 player and renaming the files is a bit laborious.
-
Aug 4th, 2000, 05:47 PM
#5
New Member
Much succes
Hi
If you want to make at your own a MP3 player then i can only say that it is very difficult.
It is created by prof programmers and musicus, and if you want to make it at your own, then much succes.
Regards
GabitaSoft Belguim (Sigurd)
-
Aug 17th, 2000, 08:18 PM
#6
Lively Member
Playing an MP3 file within your own MP3 program is possible, I am currently working on an MP3 player.....
However you will need to include an ActiveX control... Once I have finished mine I'll let you have the source code if you like...
The only other option is top include the MS MediaControl, but this will depend on the current version that you are using... (Current one I'm using is 6.4.07.112) My project at the moment is in working state by using this control.. (I currently get this to open multiple mp3's and play them, with automatic move to next once one has finished... Its turning out quite similar to that of winamp)
but as i said I'm creating my own ActiveX, this is because I can't seem to control the volume on mediaplayer, not matter what I try... Any tips on how to set the mediaplayer's volume by the value from a slider control anybody????
DJ Danny K
-
Aug 17th, 2000, 11:13 PM
#7
Hyperactive Member
sort of related question......
Hi,
Since moperke was asking whether mp3 files could be played without a control, it got me wondering.....
can I play mpeg/avi files without a control? If yes, how do I manage it???
Thanks.
-
Aug 17th, 2000, 11:49 PM
#8
MP3 file
Code:
Public Declare Function mciGetErrorString Lib "winmm.dll" Alias "mciGetErrorStringA" (ByVal dwError As Long, ByVal lpstrBuffer As String, ByVal uLength As Long) As Long
Public Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal cchBuffer As Long) As Long
Public 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
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public Declare Function ReleaseCapture Lib "user32" () As Long
Public Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Public Const SWP_NOMOVE = &H2
Public Const SWP_NOSIZE = &H1
Public Const HWND_TOPMOST = -1
Public Const HWND_NOTOPMOST = -2
Public TheFileName As String
Public Function IsItPlaying() As Boolean
Static yn As String * 30
mciSendString "status MP3Play mode", yn, Len(yn), 0
IsPlaying = (Mid$(yn, 1, 7) = "playing")
End Function
Public Function mp3Play(FileName As String)
Dim cmdToDo As String * 255
Dim dwReturn As Long
Dim ret As String * 128
Dim tmp As String * 255
Dim lenShort As Long
Dim ShortPathAndFie As String
If Dir(FileName) = "" Then
mmOpen = "Error with input file"
Exit Function
End If
lenShort = GetShortPathName(FileName, tmp, 255)
ShortPathAndFie = Left$(tmp, lenShort)
glo_hWnd = hwnd
cmdToDo = "open " & ShortPathAndFie & " type MPEGVideo Alias MP3Play"
dwReturn = mciSendString(cmdToDo, 0&, 0&, 0&)
If dwReturn <> 0 Then 'not success
mciGetErrorString dwReturn, ret, 128
mmOpen = ret
MsgBox ret, vbCritical
Exit Function
End If
mmOpen = "Success"
mciSendString "play MP3Play", 0, 0, 0
End Function
Public Function mp3Pause()
mciSendString "pause MP3Play", 0, 0, 0
End Function
Public Function mp3Stop() As String
mciSendString "stop MP3Play", 0, 0, 0
mciSendString "close MP3Play", 0, 0, 0
End Function
Public Function PositionInSec()
Static PIS As String * 30
mciSendString "set MP3Play time format milliseconds", 0, 0, 0
mciSendString "status MP3Play position", PIS, Len(PIS), 0
PositionInSec = Round(Mid$(PIS, 1, Len(PIS)) / 1000)
End Function
Public Function Position()
Static P As String * 30
mciSendString "set MP3Play time format milliseconds", 0, 0, 0
mciSendString "status MP3Play position", P, Len(P), 0
sec = Round(Mid$(P, 1, Len(P)) / 1000)
If sec < 60 Then Position = "0:" & Format(sec, "00")
If sec > 59 Then
mins = Int(sec / 60)
sec = sec - (mins * 60)
Position = Format(mins, "00") & ":" & Format(sec, "00")
End If
End Function
Public Function LengthInSec()
Static L As String * 30
mciSendString "set MP3Play time format milliseconds", 0, 0, 0
mciSendString "status MP3Play length", L, Len(s), 0
LengthInSec = Round(Val(Mid$(L, 1, Len(L))) / 1000) 'Round(CInt(Mid$(s, 1, Len(s))) / 1000)
End Function
Public Function Length()
Static L As String * 30
mciSendString "set MP3Play time format milliseconds", 0, 0, 0
mciSendString "status MP3Play length", L, Len(L), 0
sec = Round(Val(Mid$(L, 1, Len(L))) / 1000) 'Round(CInt(Mid$(l, 1, Len(l))) / 1000)
If sec < 60 Then Length = "0:" & Format(sec, "00")
If sec > 59 Then
mins = Int(sec / 60)
sec = sec - (mins * 60)
Length = Format(mins, "00") & ":" & Format(sec, "00")
End If
End Function
Public Function SeekTo(Second)
mciSendString "set MP3Play time format milliseconds", 0, 0, 0
If IsItPlaying = True Then mciSendString "play MP3Play from " & Second, 0, 0, 0
If IsItPlaying = False Then mciSendString "seek MP3Play to " & Second, 0, 0, 0
End Function
Public Sub FormDrag(frm As Form)
ReleaseCapture
Call SendMessage(frm.hwnd, 161, 2, 0&)
End Sub
Public Sub FormOnTop(frm As Form, OTTF As Boolean)
Select Case OTTF
Case True
Call SetWindowPos(frm.hwnd, HWND_TOPMOST, 0, 0 _
, 0, 0, SWP_NOMOVE Or SWP_NOSIZE)
Case False
Call SetWindowPos(frm.hwnd, HWND_NOTOPMOST, 0, 0 _
, 0, 0, SWP_NOMOVE Or SWP_NOSIZE)
End Select
End Sub
Public Function RevInStr(ByVal sIn As String, sFind As String, Optional nStart As Long = 1, Optional bCompare As VbCompareMethod = vbBinaryCompare) As Long
Dim nPos As Long
nPos = InStr(nStart, sIn, sFind, bCompare)
If nPos = 0 Then
RevInStr = 0
Else
RevInStr = Len(sIn) - nPos - Len(sFind) + 2
End If
End Function
I used to have the code to play mpg's but I lost it.
-
Aug 18th, 2000, 12:15 AM
#9
Junior Member
How about encoding or decoding mp3 files? I always wondered how I could do this, but I only got as far as to know I needed the MPEG comittee's agreement to make an encoder/decoder since only they had the algorythm used to make MPEG layer 3. Anyone know where I could get this, or is simply illegal to have it without buying it? (i.e. proprietary encoding/decoding)
I know I'm a bit off-topic, but I couldn't resist asking. Please bear with me 
Raggart
-
Aug 18th, 2000, 12:39 AM
#10
Allright~!
I found my MP3 encoding algorithm for C++ and the project that showed how to play MPG's they were not written by me, but if you want them email me
[email protected]
-
Aug 18th, 2000, 05:53 AM
#11
moperke, if all you want to do is play an mp3 file then why don't you just shell out winamp hidden ?
Using the API you can make winamp do nearly everything and I am pretty sure you can get winamp to return details about the file that is playing.
-
Aug 18th, 2000, 11:06 AM
#12
its easier to just play the MP3 yourself,
unless you are making this program to run on yours and only your computer, it would be hard to tell if the user had winamp or not.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|