Results 1 to 8 of 8

Thread: Multimedia Class Modules

  1. #1

    Thread Starter
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Multimedia Class Modules

    Here is some work I have done lately:

    - clsActiveMovie
    - clsBrowseForFolderDialog
    - clsFileDialog
    - clsID3v1
    - clsVisualization
    - a sample program using these classes

    Basically, should ease the life if you're making an application that uses multimedia. clsActiveMovie allows to play video and music without an extra OCX: only a reference to ActiveMovie control type library is required. The dialog ones allow selecting files and folders easily (yes, FileDialog supports multiple files!). ID3v1 is selfexplanary, and Visualization provides output of a soundcard in an array.

    Now, here is a screenshot of the sample program in action:
    Attached Images Attached Images  

  2. #2

    Thread Starter
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654
    And here is the code. Please note this is a work in progress and there might be bugs. There are some files I haven't included, such as ID3v2 Class Module (which lacks writing support).

    Enjoy And comments welcome.
    Attached Files Attached Files

  3. #3

    Thread Starter
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654
    With the following modification you get a different visualization:

    VB Code:
    1. Private Sub Visualization_Timer()
    2.     Static Max(255) As Integer, Avg(255) As Integer, Curs(255) As New Collection, Maxs(255) As New Collection
    3.     Dim A As Integer, B As Byte, Cur(255) As Long, tMax(255) As Long, Bigger As Long, Smaller As Long
    4.     Static C As Integer, D As Boolean, Mover(255) As Long
    5.     Dim Red As Integer, Green As Integer, Blue As Integer, Soften As Single, NewTop As Integer
    6.     On Error Resume Next
    7.     If MyMedia.VideoWidth > 1 Then Exit Sub
    8.     Visualization.Enabled = False
    9.     Visual.Update
    10.     For A = 0 To 255
    11.         Cur(A) = CInt(Abs(CLng(Visual.GetData(A)) + CLng(Visual.GetData(A + 1))) / 2)
    12.         If Cur(A) > Max(A) Then Max(A) = Cur(A)
    13.         If Cur(A) Then Avg(A) = CInt((CLng(Avg(A)) + CLng(Cur(A))) / 2)
    14.         Cur(A) = Cur(A) + Avg(A) / 2
    15.         If Cur(A) < 0 Then Cur(A) = 0
    16.         tMax(A) = Max(A) + Avg(A) / 2
    17.         If tMax(A) = 0 Then tMax(A) = 1
    18.         Curs(A).Add Cur(A)
    19.         Maxs(A).Add tMax(A)
    20.         If Curs(A).Count > 10 Then Curs(A).Remove 1
    21.         If Maxs(A).Count > 10 Then Maxs(A).Remove 1
    22.         Smaller = 0
    23.         Bigger = 0
    24.         For B = 1 To Curs(A).Count
    25.             Soften = Abs(1 + (B - Curs(A).Count / 2) / 50)
    26.             Smaller = Smaller + Val(Curs(A).Item(B)) * Soften
    27.             Bigger = Bigger + Val(Maxs(A).Item(B)) * Soften
    28.         Next B
    29.         Red = 384 / Bigger * Smaller
    30.         Blue = (768 + (Rnd * 256)) / Bigger * Smaller
    31.         Green = (512 + (Rnd * 64)) / Bigger * Smaller
    32.         If Red < 0 Then Red = 0
    33.         If Green < 0 Then Green = 0
    34.         If Blue < 0 Then Blue = 0
    35.         If Red > 255 Then Red = 255
    36.         If Green > 255 Then Green = 255
    37.         If Blue > 255 Then Blue = 255
    38.         Mover(A) = Mover(A) * 0.5 + (Max(A) - Avg(A) + 1) / (Cur(A) + 1) * 10
    39.         If Mover(A) > VisBG.ScaleHeight Or Mover(A) = 0 Then Mover(A) = VisBG.ScaleHeight
    40.         BitBlt VisBG.hdc, NewTop, 0, VisBG.ScaleWidth / 256 + 1, VisBG.ScaleHeight / Mover(A) * (Mover(A) - 1), VisBG.hdc, NewTop, VisBG.ScaleHeight / Mover(A), vbSrcCopy
    41.         SetPixel VisBG.hdc, NewTop, VisBG.ScaleHeight - 1, RGB(CByte(Red), CByte(Green), CByte(Blue))
    42.         StretchBlt VisBG.hdc, NewTop, VisBG.ScaleHeight / Mover(A) * (Mover(A) - 1), VisBG.ScaleWidth / 256 + 1, VisBG.ScaleHeight / Mover(A), VisBG.hdc, NewTop, VisBG.ScaleHeight - 1, 1, 1, vbSrcCopy
    43.         NewTop = NewTop + VisBG.ScaleWidth / 256 + 1
    44.         If NewTop > Video.ScaleWidth Then Exit For
    45.     Next A
    46.     If D Then
    47.         C = C - 1
    48.         If C < 1 Then C = 0: D = False
    49.     Else
    50.         C = C + 1
    51.         If C > 254 Then C = 255: D = True
    52.     End If
    53.     VisBG.Refresh
    54.     BitBlt Video.hdc, 0, 0, Video.ScaleWidth, Video.ScaleHeight, VisBG.hdc, 0, 0, vbSrcCopy
    55.     Video.CurrentX = 5
    56.     Video.CurrentY = Video.ScaleHeight - Video.TextHeight(Playlist.Tag) - 2
    57.     Video.Print Playlist.Tag
    58.     Video.Refresh
    59.     Visualization.Enabled = True
    60. End Sub

    As seen below:
    Attached Images Attached Images  

  4. #4
    Fanatic Member
    Join Date
    Jul 2002
    Location
    Australia
    Posts
    635
    Merri,
    I'm getting a invalid procedure or argument when i try to add *.mnp3 files with your app, any fixes, and can I release a version for my Babya System users ?
    A.A. Fussy
    Babya Software Group

  5. #5

    Thread Starter
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654
    The code is as free as it can get, so yes, you can release your own version.

    As for the error, are you able to locate it? I can't help unless I know where it happens, since I seem to have no problems using it.

  6. #6
    Fanatic Member
    Join Date
    Jul 2002
    Location
    Australia
    Posts
    635
    I get a buffer overflow when a mp3 file is played-the invalid procedure when i add a file with the add files button.
    Last edited by crptcblade; Jan 7th, 2004 at 05:47 AM.
    A.A. Fussy
    Babya Software Group

  7. #7

    Thread Starter
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654
    Located the overflow (it should occur only with a maximum volume):

    VB Code:
    1. Cur(A) = CInt(Abs(CLng(Visual.GetData(A)) + CLng(Visual.GetData(A + 1))) / 2)

    should be:

    VB Code:
    1. Cur(A) = CInt(Abs(CLng(Visual.GetData(A)) + CLng(Visual.GetData(A + 1)) - 1) / 2)


    And I still don't know what might be wrong with Add files -button. Does the invalid procedure occur immediately when you push the button or after you've selected files?

  8. #8

    Thread Starter
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654
    Finally found the error. Apparently my VB has crashed when I fixed this before... replace this function in clsFileDialog with the new one:

    VB Code:
    1. Public Function FileOpen(ByRef Filename As String) As Boolean
    2.     Dim A As Integer, Temp As String, Temps() As String
    3.     'get filename
    4.     FileOpen = CBool(GetOpenFileName(FileDialog))
    5.     Temps = Split(Trim$(FileDialog.lpstrFile), vbNullChar)
    6.     If Temps(0) = vbNullString Then
    7.         FileOpen = False
    8.     ElseIf Temps(1) = vbNullString Then
    9.         Filename = Temps(0)
    10.     Else
    11.         If Right$(Temps(0), 1) <> "\" Then Temps(0) = Temps(0) & "\"
    12.         For A = 1 To UBound(Temps)
    13.             If Temps(A) <> vbNullString Then Filename = Filename & "|" & Temps(0) & Temps(A)
    14.         Next A
    15.         Filename = Mid$(Filename, 2)
    16.     End If
    17. End Function

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