Results 1 to 3 of 3

Thread: Cant open mp3 as binary?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2000
    Location
    Texas
    Posts
    313
    I can not open an mp3 as binary. I did this

    Code:
    Dim LocData() As Byte
    Dim LenData As Long
    Dim sendloop As Long
    Dim path As String
    path = "d:\program files\napster\music\Hows it gonna be.mp3"
        Open path For Binary As #1
        
        ReDim LocData(1 To 2048) As Byte ' Work in 2kb chunks
    
    LenData = LOF(1) ' Get length of file
    
    For sendloop = 1 To LenData \ 2048 ' Go through file
    
      Get #1, , LocData 'Get data from the file nCnt is from where to start the get
    
      Form1.Winsock1(index).SendData LocData 'Send the chunk
    
    Next
    but it wont do it, it is saying when i get the the lenData, it is saying it is 0. Any sudgestions?

  2. #2
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    Well you have spaces in the file name, and that's not healthy

    Try putting the string in quotes, Windows likes it better that way:

    Code:
    Dim LocData() As Byte
    Dim LenData As Long
    Dim sendloop As Long
    Dim path As String
    path = """d:\program files\napster\music\Hows it gonna be.mp3"""
        Open path For Binary As #1
        
        ReDim LocData(1 To 2048) As Byte ' Work in 2kb chunks
    
    LenData = LOF(1) ' Get length of file
    
    For sendloop = 1 To LenData \ 2048 ' Go through file
    
      Get #1, , LocData 'Get data from the file nCnt is from where to start the get
    
      Form1.Winsock1(index).SendData LocData 'Send the chunk
    
    Next
    Harry.

    "From one thing, know ten thousand things."

  3. #3
    Hyperactive Member Wak's Avatar
    Join Date
    Nov 2000
    Location
    Brisbane, Queensland
    Posts
    298

    Get MP3 Tag info

    A function to receive MP3 tag info is below.

    Code:
    option explicit
    
    Private Type TagInfo
        Tag As String * 3
        Songname As String * 30
        artist As String * 30
        album As String * 30
        year As String * 4
        comment As String * 30
        genre As String * 1
    End Type
    
    Private CurrentTag As TagInfo
    
    Public Function GetTagInfo(Filename As String) As String
        
        Open Filename For Binary As #1
        With CurrentTag
            Get #1, FileLen(Filename) - 127, .Tag
            If Not .Tag = "TAG" Then
                GetTagInfo = "Other" 
                Close #1
                Exit Function
            End If
    
            Get #1, , .Songname
            Get #1, , .artist
            Get #1, , .album
            Get #1, , .year
            Get #1, , .comment
            Get #1, , .genre
            Close #1
        
             GetTagInfo =  RTrim(.artist) & " - " & RTrim(.Songname) 
        
            End With
    End Function

    This just gets the basic tag info, if that's what you want.
    Just put it in a separate module.
    Visual Basic 6.0 Enterprise
    Visual C++ 6.0 Professional

    Wak

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