BASS_SFX problems in VB.net?

Started by i00, 25 Nov '09 - 09:58

i00

Ok here's my problem... if i have the following code:

Public Class MediaBASS
    Public WithEvents tmrVidUpdate As New Timer

    Private Sub tmrVidUpdate_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrVidUpdate.Tick
        If hSFX <> -1 Then
            Try
                BASSAPI.BASS_SFX_PluginRender(hSFX, hStream, hVisDC)
            Catch ex As Exception
                Try
                    BASSAPI.BASS_SFX_PluginStop(hSFX)
                Catch ex2 As Exception

                End Try
                hSFX = -1
                tmrVidUpdate.Enabled = False
            End Try
        End If
    End Sub

    Private hSFX As Integer = 0
    Private hStream As Integer = 0
    Private BASS_UNICODE As Integer = -2147483648
    Private hVisDC As IntPtr = IntPtr.Zero

    Public Sub Play(ByVal File As String, Optional ByVal SoundCard As String = "")
        Dim frm As New Form
        frm.Visible = True
        hVisDC = frm.CreateGraphics().GetHdc()
        If BASSAPI.BASS_Init(-1, 44100, 0, frm.Handle, 0) Then
            BASSAPI.BASS_SFX_Init(IntPtr.Zero, frm.Handle)

            hStream = BASSAPI.BASS_StreamCreateFile(False, File, 0, 0, BASS_UNICODE)
            BASSAPI.BASS_ChannelPlay(hStream, False)

            hSFX = BASSAPI.BASS_SFX_PluginCreate("c:\rabbithole11.svp", frm.Handle, frm.Width, frm.Height, 0)
            BASSAPI.BASS_SFX_PluginStart(hSFX)
        End If
        tmrVidUpdate.Interval = 1000 / 30
        tmrVidUpdate.Enabled = True
    End Sub
End Class

And then call (on a button click):
       Dim asd As New MediaBASS
        asd.Play("c:\Matrix.mp3")

If i call it on a button on new form within my project - and make this form the startup it works

If i have my main form showing ... and put the button on that i get the window popup with nothing on it ???

no matter how i do it i can not get the video working when my real main form is open ... i have tried with other projects too - same thing with a few others...
it seems to not show if the project has a form open in it with alot of controls on it???!

Any ideas?

BTW i use windows 7 home premium

Thanks
Kris

radio42

Note, that when you leave the Play method any internal members will be disposed.
So I guess your "frm" will be disposed as well once you leave the Play method...

i00

#2
Quote from: radio42 on 25 Nov '09 - 11:12Note, that when you leave the Play method any internal members will be disposed.
So I guess your "frm" will be disposed as well once you leave the Play method...

Incorrect the frm will not be disposed... nor the timer ... unless you manually terminate them in the destructor
Try it if you don't believe me...
It only terminates objects by default (in VB.Net at least) that are not inherited from control at the end of scope.

Oh and I put the "Dim asd As New MediaBASS" outside the scope of the button click - same thing

Any other ideas? Thanks again
Kris

i00

OK even with the example code for vb.net - if you just put a rich text box on the example's form (no other code) and run it then start typing stuff in the RTB after a few words all of the visualizations will "freeze" it does this with other controls aswell - list view - not sure what else at this stage ... but if there are ANY of these controls in your project it will fall over eventually when playing with these controls (probably others too ... since my good project doesn't use either the rtb or the list view) :( - even if they are on another form... and doesn't seem to recover when you play the next song :(

Any ideas - otherwise this would be great ... Oh and like I said b4 - I use windows 7 home premium


i00