import media playlist

Corticus

New member
Local time
Today, 05:37
Joined
Aug 2, 2002
Messages
9
Hi all,

I'm trying to import my media playlist from Windows Media Player into tables.

I tried 'get external data'|Import|ODBC|Machine Data Source|ECDCMusic, but I get this error:
You cannot use ODBC to import from, export to, or link an external Microsoft Jet or ISAM database table to your database(ha ha hahaha!).

Ok, I added the maniacal laughter.

Please help, I've looked everywhere for this, the kb offered slight help, but I could not figure out how to implement it.

Ideally, I would like an artist table, a track table, an album table etc...

Thanks!
 
a little progress

Hmph...

Well I guess I'm on my own on this one. ;)

What I'm doing is having Access append a table with a list of filenames from a directory that is currently explicitly defined in the code, but I'll have to work on that. This is what I've got so far:

Option Compare Database

Private Sub Form_Open(Cancel As Integer)

Dim dbs As DataBase
Dim sql As String
Dim Filename As String
Dim myarray()
Dim fs As Object
Dim i As Integer

Set dbs = CurrentDb

' Declare filesearch object.
Set fs = Application.FileSearch

' Set folder to search.
fs.LookIn = "C:\My Music\Wu\"

' Set file name to search for.
fs.Filename = "*.mp3"

' Execute the file search, and check to see if the file(s) are
' present.
If fs.Execute > 0 Then
' Redimension the array to the number of files found.
ReDim myarray(fs.foundfiles.Count)
' Loop through all found file names and fill the array.
For i = 1 To fs.foundfiles.Count
Filename = fs.foundfiles(i)
sql = "Insert Into TblTrackInfo(TrackTitle) " & _
"Values ('" & Filename & "')"
dbs.Execute (sql)
Next i
Else
' Display message if no files were found.
MsgBox "No files were found"
End If

End Sub

I think I can start to append the artists to a table by looking to the directory under which the group of songs is located.

BTW, the idea of this is a media database of my music, I know it seems redundant since media player does this, but I have over 10,000 (80 GB+) of titles, and Media Player, and Music Match, and RealPlayer, and RealOne have an absolutely horrible time dealing with this many records, so I need to make something of my own. I don't need to play anything from it (though that might not be too hard), just organize my tracks and track info.

Is there a way to retrieve the artist and album info from an .mp3 file?

As I think about it, I'm not sure the path will give me this info,

para ejample:
C:\My Music\MP3s\Wu\01. Gravel Pit.mp3

is on Album 'The W'

But this data is neither in the file details, or in the path, so where is it coming from?

As long as I keep my music organized like

C:\artist\album\song.mp3

I'm okay, but somehow all these media players are getting additional track details from something other than the online CDDB, since it works when I'm not online, or even if I add a CD and never go online, just manually type in the artist/album.

Thanks!

-Cort
 
Okay,

This API provided by NateO about wraps up what I need:
Code:
Public Declare Function CreateFile Lib "kernel32" Alias "CreateFileA" _
        (ByVal lpFileName As String, _
        ByVal dwDesiredAccess As Long, _
        ByVal dwShareMode As Long, _
        ByVal lpSecurityAttributes As Long, _
        ByVal dwCreationDisposition As Long, _
        ByVal dwFlagsAndAttributes As Long, _
        ByVal hTemplateFile As Long) As Long

Public Declare Function CloseHandle Lib "kernel32" _
        (ByVal hObject As Long) As Long

Public Declare Function SetFilePointer Lib "kernel32" _
        (ByVal hFile As Long, _
        ByVal lDistanceToMove As Long, _
        ByVal lpDistanceToMoveHigh As Long, _
        ByVal dwMoveMethod As Long) As Long

Public Declare Function ReadFile Lib "kernel32" _
        (ByVal hFile As Long, _
        lpBuffer As Any, _
        ByVal nNumberOfBytesToRead As Long, _
        lpNumberOfBytesRead As Long, _
        ByVal lpOverlapped As Long) As Long

Public Const GENERIC_ALL = &H10000000
Public Const GENERIC_EXECUTE = &H20000000
Public Const GENERIC_READ = &H80000000
Public Const GENERIC_WRITE = &H40000000
Public Const OPEN_ALWAYS = 4
Public Const OPEN_EXISTING = 3
Public Const INVALID_HANDLE_VALUE = &HFFFFFFFF
Public Const FILE_SHARE_READ = &H1
Public Const FILE_SHARE_WRITE = &H2
Public Const FILE_ATTRIBUTE_NORMAL = &H80

Public Const FILE_BEGIN = 0
Public Const FILE_END = 2

Public Type TAG_INFO
    szTag As String
    szTrackName As String
    szArtistName As String
    szAlbumName As String
    szYear As String
    szComment As String
    genre As Long
End Type

Public Type TAG_DATA
    szTag(3) As Byte
    szTrackName(30) As Byte
    szArtistName(30) As Byte
    szAlbumName(30) As Byte
    szYear(4) As Byte
    szComment(30) As Byte
    genre As Long
End Type
 
Private Sub GetInfo(iFile As String)
    Dim lngFileHandle As Long
    Dim Result As Long
    Dim byteRead As Long
    Dim tagInfo As TAG_INFO
    Dim tagData As TAG_DATA
    Dim buf(128) As Byte
    Dim i As Long

    lngFileHandle = CreateFile(iFile, GENERIC_READ, FILE_SHARE_READ + FILE_SHARE_WRITE, _
                                    0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0)
    If lngFileHandle = INVALID_HANDLE_VALUE Then
        Exit Sub
    End If

    Result = SetFilePointer(lngFileHandle, -128&, 0, FILE_END)

    Result = ReadFile(lngFileHandle, buf(0), 128, byteRead, 0)

    If Result = 0 Or byteRead <> 128 Then
        Call CloseHandle(lngFileHandle)
        Exit Sub
    End If

    With tagData
        For i = 0 To 2
            .szTag(i) = buf(i)
        Next i
        For i = 3 To 32
            .szTrackName(i - 3) = buf(i)
        Next i
        For i = 33 To 62
            .szArtistName(i - 33) = buf(i)
        Next i
        For i = 63 To 92
            .szAlbumName(i - 63) = buf(i)
        Next i
        For i = 93 To 96
            .szYear(i - 93) = buf(i)
        Next i
        For i = 97 To 126
            .szComment(i - 97) = buf(i)
        Next i
        .genre = buf(127)
    End With

    tagInfo.szTag = Trim(StrConv(tagData.szTag, vbUnicode))
    tagInfo.szTrackName = Trim(StrConv(tagData.szTrackName, vbUnicode))
    tagInfo.szArtistName = Trim(StrConv(tagData.szArtistName, vbUnicode))
    tagInfo.szAlbumName = Trim(StrConv(tagData.szAlbumName, vbUnicode))
    tagInfo.szYear = Trim(StrConv(tagData.szYear, vbUnicode))
    tagInfo.szComment = Trim(StrConv(tagData.szComment, vbUnicode))
    tagInfo.genre = tagData.genre
    '**************************************
    MsgBox tagInfo.szArtistName
    MsgBox tagInfo.szTrackName
    '**************************************
    Call CloseHandle(lngFileHandle)

End Sub


Sub test()
Call GetInfo("C:\temp\Your.mp3")
End Sub

Also,
This software (free!):
http://www.mp3observer.com/download.asp

when installed, automatically creates a file:
mp3s.mdb
in the main directory under which you install the software.

Guess what the file is?

That's right... my mp3 database. Not perfect, but good enough for me.

Thanks!
 

Users who are viewing this thread

Back
Top Bottom