I am writing my own DLL for playing mp3 wiht DirectX.
I'm wondering is this correct, because I have problem with this :
Code:
Public Property Let LoadFile(ByVal File As String, Level As Integer)
DirectShow_Load_Media File
DirectShow_Volume Level
DirectShow_Balance 0
DirectShow_Speed 100
DirectShow_Set_Position 0, 0, 0, 0
End Property
Public Property Let UcitajFile(ByVal File As String, Glasnoca As Integer)
DirectShow_Load_Media File
DirectShow_Volume Glasnoca
DirectShow_Balance 0
DirectShow_Speed 100
DirectShow_Set_Position 0, 0, 0, 0
End Property
Public Property Let SetLevel(ByVal Level As Integer)
DirectShow_Volume Level
End Property
Public Property Let RunFile(ByVal State As Boolean)
On Error Resume Next
If State Then
DirectShow_Play
Else
DirectShow_Stop
End If
End Property
Second, is this a function "DirectShow_Volume" or a variable, because if it's a variable you're missing '=' symbol. Also, why do you have two identical Let-s (LoadFile, UcitajFile)? I realize you translated the name of the property and arguments, but what's the point?
Second, is this a function "DirectShow_Volume" or a variable, because if it's a variable you're missing '=' symbol. Also, why do you have two identical Let-s (LoadFile, UcitajFile)? I realize you translated the name of the property and arguments, but what's the point?
Yes, I translated, that's duplicated.
Also, DirectShow_Volume is function.
Problem, when I make this DLL and try to use in application, I can't hear anything.
In application, I put this :
Code:
LoadFile Path, Volume
RunFile True
and, also, when typing LoadFile, VB show just Path parameter, there is no Volume parameter in ToolTip
i just easily compiled this code as an activeX dll
Code:
Public Sub LoadFile(ByVal File As String, Level As Integer)
' DirectShow_Load_Media File
' DirectShow_Volume Level
' DirectShow_Balance 0
' DirectShow_Speed 100
' DirectShow_Set_Position 0, 0, 0, 0
MsgBox "LoadFile"
End Sub
Public Sub UcitajFile(ByVal File As String, Glasnoca As Integer)
' DirectShow_Load_Media File
' DirectShow_Volume Glasnoca
' DirectShow_Balance 0
' DirectShow_Speed 100
' DirectShow_Set_Position 0, 0, 0, 0
MsgBox "UcitajFile"
End Sub
Public Sub SetLevel(ByVal Level As Integer)
' DirectShow_Volume Level
MsgBox "SetLevel"
End Sub
Public Sub RunFile(ByVal State As Boolean)
On Error Resume Next
If State Then
' DirectShow_Play
Else
' DirectShow_Stop
End If
' DirectShow_Volume Level
MsgBox "RunFile"
End Sub
you know you should open a new ActiveX DLL Project (not the default , which is standard EXE)
When you create a DLL, in order to use it, you first have to reference it. Once you have referenced it, You can then use it... first by declaring an object of the class type, then you create an instance of the class. Then and only then can you call its methods and functions.
The reason LoadFile is only giving you the one parameter, is because it's the wrong loadFile.
Also, the code you posted CANNOT be the full extent of all the code ... since all those calls to the directx functions will fail w/o being defined or referenced somehow.
When you create a DLL, in order to use it, you first have to reference it. Once you have referenced it, You can then use it... first by declaring an object of the class type, then you create an instance of the class. Then and only then can you call its methods and functions.
The reason LoadFile is only giving you the one parameter, is because it's the wrong loadFile.
Also, the code you posted CANNOT be the full extent of all the code ... since all those calls to the directx functions will fail w/o being defined or referenced somehow.
-tg
I know that, and I have done all.
In this DLL, I have module where I have directX functions, and in DLL I used reference quartz.dll.
Description of problem.
I want to use two sounds at the same time. First, I set module inside application. But if I want to load secund file, first will be replaced. And I can't play it. So, I decided to move that module in one DLL, so i can declare two object, Music1 as MyDll.clsPlay, Music as MyDll.clsPlay.
In this DLL, I have module where I have directX functions, and in DLL I used reference quartz.dll.
Description of problem.
I want to use two sounds at the same time. First, I set module inside application. But if I want to load secund file, first will be replaced. And I can't play it. So, I decided to move that module in one DLL, so i can declare two object, Music1 as MyDll.clsPlay, Music as MyDll.clsPlay.
Using this DLL, I can't accomplish this task
for your first problem :
play more than one file at a time:
Code:
Type DirectShowbuf
Event As IMediaEvent
Control As IMediaControl
Position As IMediaPosition
Audio As IBasicAudio
Video As IBasicVideo
Video_Window As IVideoWindow
End Type
Function DSInit(DS As DirectShowbuf) As Boolean
On Error GoTo Error_Handler
Set DS.Control = New FilgraphManager
Set DS.Event = DS.Control
Set DS.Position = DS.Control
DS.Position.Rate = 1
DSInit = False
Exit Function
Error_Handler:
' Call ShowErrorMsg()
DSInit = True
End Function
you can use this last function to open as many devices as you want,
and thus play as many files as you want.
you should be aware what you're doing, because you need also to close those
devices.
you can for examples use an array to store each device, like this:
Code:
Dim DSArray[10] As DirectSHowBuf
Dim DSDeviceNum As Integer
Private Sub Form_Load()
For DSDeviceNum = 0 To 3
Call DSInit(DSArray(DSDeviceNum))
DSDeviceNum = DSDeviceNum + 1
Next
For DSDeviceNum = 0 To 3
DSArray(DSDeviceNum).Control.RenderFile (fName)
Next
End Sub
Last edited by whatsup; May 20th, 2010 at 10:04 AM.
for your first problem :
play more than one file at a time:
Code:
Type DirectShowbuf
Event As IMediaEvent
Control As IMediaControl
Position As IMediaPosition
Audio As IBasicAudio
Video As IBasicVideo
Video_Window As IVideoWindow
End Type
Function DSInit(DS As DirectShowbuf) As Boolean
On Error GoTo Error_Handler
Set DS.Control = New FilgraphManager
Set DS.Event = DS.Control
Set DS.Position = DS.Control
DS.Position.Rate = 1
DSInitM = False
Exit Function
Error_Handler:
' Call ShowErrorMsg()
DSInit = True
End Function
you can use this last function to open as many devices as you want,
and thus play as many files as you want.
you should be aware what you're doing, because you need also to close those
devices.
you can for examples use an array to store each device, like this:
Code:
Dim DSArray[10] As DirectSHowBuf
Dim DSDeviceNum As Integer
Private Sub Form_Load()
For DSDeviceNum = 0 To 3
Call DSInit(DSArray[DSDeviceNum])
DSDeviceNum = DSDeviceNum + 1
Next
For DSDeviceNum = 0 To 3
DSArray[DSDeviceNum].Control.RenderFile (fName)
Next
End Sub
OK, I'll try
----
I fixed in DLL instancing property and set back to multiuse ( I don't know how it was changed to private) and make DLL, but, again I can't hear anything.
Using your code, which references I need to include ? (I included "quartz.dll")
I have problem in this line :
Code:
Function DSInit(DS As DirectShowbuf) As Boolean
On Error GoTo Error_Handler
Set DS.Control = New FilgraphManager
Set DS.Event = DS.Control
Set DS.Position = DS.Control
DS.Position.Rate = 1
DSInitM = False
Exit Function
Error_Handler:
' Call ShowErrorMsg()
DSInit = True
End Function
Option Explicit
Dim Music As DirectShowbuf
Private Type DirectShowbuf
Event As IMediaEvent
Control As IMediaControl
Position As IMediaPosition
Audio As IBasicAudio
Video As IBasicVideo
Video_Window As IVideoWindow
End Type
Private Function DSInit(DS As DirectShowbuf) As Boolean
On Error GoTo Error_Handler
Set DS.Control = New FilgraphManager
Set DS.Event = DS.Control
Set DS.Position = DS.Control
DS.Position.Rate = 1
DSInit = False
Exit Function
Error_Handler:
' Call ShowErrorMsg()
DSInit = True
End Function
Private Sub Form_Load()
DSInit Music
Music.Control.RenderFile "C:\file.mp3"
Set Music.Audio = Music.Control
Music.Control.Run
End Sub
i just took the code from your post, didn't make any change,
and it worked no problem.
maybe try to replace the mp3, because DS can't play every file.
that's the main reason i'm using in my media player FMOD library,
because i have files that DS and MCI couldn't play.
i just took the code from your post, didn't make any change,
and it worked no problem.
maybe try to replace the mp3, because DS can't play every file.
that's the main reason i'm using in my media player FMOD library,
because i have files that DS and MCI couldn't play.
really don't know
I tried another mp3 and nothing., and another one, nothing