Results 1 to 27 of 27

Thread: using own dll

  1. #1

    Thread Starter
    Addicted Member BSA01's Avatar
    Join Date
    Apr 2009
    Location
    Bosnia and Herzegovina
    Posts
    146

    using own dll

    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

  2. #2
    Next Of Kin baja_yu's Avatar
    Join Date
    Aug 2002
    Location
    /dev/root
    Posts
    5,989

    Re: using own dll

    First, what's the problem?

    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?

  3. #3

    Thread Starter
    Addicted Member BSA01's Avatar
    Join Date
    Apr 2009
    Location
    Bosnia and Herzegovina
    Posts
    146

    Re: using own dll

    Quote Originally Posted by baja_yu View Post
    First, what's the problem?

    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

  4. #4
    Hyperactive Member
    Join Date
    Jul 2009
    Posts
    489

    Re: using own dll

    maybe you post the dll project, and will try to fix it.

  5. #5
    Hyperactive Member
    Join Date
    Jul 2009
    Posts
    489

    Re: using own dll

    second:
    if you want to use playsound as a sub = method (not property)
    you shoud replace the keyword property let with sub

  6. #6

    Thread Starter
    Addicted Member BSA01's Avatar
    Join Date
    Apr 2009
    Location
    Bosnia and Herzegovina
    Posts
    146

    Re: using own dll

    Quote Originally Posted by whatsup View Post
    second:
    if you want to use playsound as a sub = method (not property)
    you shoud replace the keyword property let with sub
    I really hope this will work, because I want to use this dll like some extern source of functions.

  7. #7
    Hyperactive Member
    Join Date
    Jul 2009
    Posts
    489

    Re: using own dll

    it should easly work.
    if you problems, just post them.

  8. #8

    Thread Starter
    Addicted Member BSA01's Avatar
    Join Date
    Apr 2009
    Location
    Bosnia and Herzegovina
    Posts
    146

    Re: using own dll

    Quote Originally Posted by whatsup View Post
    it should easly work.
    if you problems, just post them.
    problem is, when I rename all Property Let to Sub, and try to make DLL, msgbox show :

    "No creatable public component detected.
    F1 for help"

  9. #9
    Hyperactive Member
    Join Date
    Jul 2009
    Posts
    489

    Re: using own dll

    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)

  10. #10
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: using own dll

    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 don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  11. #11

    Thread Starter
    Addicted Member BSA01's Avatar
    Join Date
    Apr 2009
    Location
    Bosnia and Herzegovina
    Posts
    146

    Re: using own dll

    Quote Originally Posted by techgnome View Post
    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.



    Using this DLL, I can't accomplish this task

  12. #12
    Hyperactive Member
    Join Date
    Jul 2009
    Posts
    489

    Re: using own dll

    Quote Originally Posted by BSA01 View Post
    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.



    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

  13. #13

    Thread Starter
    Addicted Member BSA01's Avatar
    Join Date
    Apr 2009
    Location
    Bosnia and Herzegovina
    Posts
    146

    Re: using own dll

    Quote Originally Posted by whatsup View Post
    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.

  14. #14

    Thread Starter
    Addicted Member BSA01's Avatar
    Join Date
    Apr 2009
    Location
    Bosnia and Herzegovina
    Posts
    146

    Re: using own dll

    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

  15. #15
    Hyperactive Member
    Join Date
    Jul 2009
    Posts
    489

    Re: using own dll

    i'm sorry
    it should be
    Code:
        DSInit = False

  16. #16
    Hyperactive Member
    Join Date
    Jul 2009
    Posts
    489

    Re: using own dll

    also where ever i wrote these brackets -> [ ]
    it should be these -> ( )

  17. #17

    Thread Starter
    Addicted Member BSA01's Avatar
    Join Date
    Apr 2009
    Location
    Bosnia and Herzegovina
    Posts
    146

    Re: using own dll

    I used one variable "music" that is "DirectShowbuf"

    In form load, I set :

    Code:
    DSInit Music
    Music.control.render "C:\file.mp3"
    Music.control.run
    Also, printed DSInit, and I saw it was false. But I don't hear anything.

  18. #18
    Hyperactive Member
    Join Date
    Jul 2009
    Posts
    489

    Re: using own dll

    i'm sorry maybe i forgot this line

    Code:
        DS.Control.RenderFile myFileName
        Set DS.Audio = DS.Control  ' <----

  19. #19
    Hyperactive Member
    Join Date
    Jul 2009
    Posts
    489

    Re: using own dll

    this code is from media player, that works very well for a long time, so there should be no problem,
    (except of some small mistakes of mine )

  20. #20

    Thread Starter
    Addicted Member BSA01's Avatar
    Join Date
    Apr 2009
    Location
    Bosnia and Herzegovina
    Posts
    146

    Re: using own dll

    Entire code, also not working :

    Code:
    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

  21. #21
    Hyperactive Member
    Join Date
    Jul 2009
    Posts
    489

    Re: using own dll

    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.

  22. #22

    Thread Starter
    Addicted Member BSA01's Avatar
    Join Date
    Apr 2009
    Location
    Bosnia and Herzegovina
    Posts
    146

    Cool Re: using own dll

    Quote Originally Posted by whatsup View Post
    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

  23. #23
    Hyperactive Member
    Join Date
    Jul 2009
    Posts
    489

    Re: using own dll

    i made a little project for you,
    which i tested and it works.
    it can play up to 3 files at a time.
    i hope it'll work for you.
    Attached Files Attached Files

  24. #24

    Thread Starter
    Addicted Member BSA01's Avatar
    Join Date
    Apr 2009
    Location
    Bosnia and Herzegovina
    Posts
    146

    Re: using own dll

    Quote Originally Posted by whatsup View Post
    i made a little project for you,
    which i tested and it works.
    it can play up to 3 files at a time.
    i hope it'll work for you.
    I apritiate, but it is obius that error is just for me. Really don't know.

  25. #25
    Hyperactive Member
    Join Date
    Jun 2007
    Posts
    280

    Re: using own dll

    Have you tried it on a different PC?
    Slower than a crippled Vista
    More buggy than a fresh XP install
    Look! Down the road, some 50 miles behind the drunken snail.
    It's Ubuntu!

  26. #26

    Thread Starter
    Addicted Member BSA01's Avatar
    Join Date
    Apr 2009
    Location
    Bosnia and Herzegovina
    Posts
    146

    Re: using own dll

    Quote Originally Posted by AsmIscool View Post
    Have you tried it on a different PC?
    No. And, what's the point if I can't do that on my PC

  27. #27
    Hyperactive Member
    Join Date
    Jul 2009
    Posts
    489

    Re: using own dll

    the point is to confirm that this is a problam in your system,
    and not in your code.
    and then you can try replace / register new dll (or something)

Posting Permissions

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



Click Here to Expand Forum to Full Width