Results 1 to 14 of 14

Thread: Loading music files

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2014
    Posts
    12

    Loading music files

    Please could someone help a VB novice. I’m attempting to create some sort of jukebox software but can’t get beyond the stage of loading the albums(mp3 format) into a database for future editing, indexing etc and selecting individual tracks. Any help would be greatly appreciated

  2. #2
    The Idiot
    Join Date
    Dec 2014
    Posts
    2,721

    Re: Loading music files

    not sure what u really need here.
    but I would start with a way to load all files into a collection or UDT/array.
    so, look for the API FindFirstFile, theres tons of example googling or here in this forum.

    playback we have ActiveMovie control type library that I think is quite good and have enough functions to make a great player.
    also, u can find examples here or by googling.

  3. #3

    Thread Starter
    New Member
    Join Date
    Dec 2014
    Posts
    12

    Re: Loading music files

    Thanks for the reply but I’m probably more of a novice than that. I’m struggling to find the right code to read the files from “C:\ Albums”. Will the mp3 file be recognised as a string? Most common errors I’m receiving are ‘path not found’ and ‘path/file access error’

  4. #4
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,872

    Re: Loading music files

    Very basic sample using the Dir() method of VB6.
    It does not do sub folders, just a scan of the given directory
    Code:
    Dim sFile As String
    
    ' This will ask for the first file name matching the given parameters
    sFile = Dir("C:\Albums\*.MP3")
    Do While Len(sFile) > 0
      ' This will print the found file title
      Debug.Print sFile 
      ' Ask for the next file
      sFile = Dir
    Loop

  5. #5
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,145

    Re: Loading music files

    Attached is a rather in-depth JukeBox I created...this one I am attaching only has ONE album (with ONE song). If you look at the code you will see how I open/play mp3 files.

    NOTE: Due to CopyRight laws, I have not included any songs in mp3 format. Instead, for the ONE song you will see (I titled it 'House of the Rising Sun'), I have substituted a very small sound bit mp3 file. If you add any songs/albums make sure you use the same folder structure as I do (Music/Artist(s)/Album/mp3(s)). You do not need to add Artists Pictures nor Album Covers (I have a default jpg for those albums/songs for which I do not have those jpgs).

    Play around with it...good luck with YOUR program.

    Sam


    JUKEBOX.zip
    Sam I am (as well as Confused at times).

  6. #6
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    5,651

    Re: Loading music files

    Just FYI, if you ever wanted to include sample songs, there's https://freemusicarchive.org which offers music under the Creative Commons license, where it's free to share with attribution.

  7. #7
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,145

    Re: Loading music files

    Aye, faf, but the music I prefer listening to (which is Country and Rock and Roll by popular artists) won't be found at that site! :-) MOST of mine (I have over 5000 individual songs in my program) come from my CDs, 45's and albums.

    (Also, my mp3s are of a size too large to be xferring to this forum anyway).
    Sam I am (as well as Confused at times).

  8. #8
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    6,582

    Re: Loading music files

    But for an example you don't need to include songs you would prefer to listen to, you just need placeholders, like you did anyway, and they don't have to be large.
    You could just search for a number of short songs from such a site, place them in a directory and create an album list and play list, and then have a canned example that you can provide without worrying about copyright issues. As it is, why even use a known song title, or a very similar title in your example. The example should have been just as valid with a title name "Example One Ditty",
    "Anyone can do any amount of work, provided it isn't the work he is supposed to be doing at that moment" Robert Benchley, 1930

  9. #9
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,145

    Re: Loading music files

    Ok ok ok....point made. However, doing a QUICK search at that site, the file sizes are similar to what I have, hence to suitable for uploading to this forum. I guess I could search and search and search to find a small one, but I think I'll just leave it alone...the file isn't important...my little soundbite suits just fine for POC.

    Sammi
    Sam I am (as well as Confused at times).

  10. #10

    Thread Starter
    New Member
    Join Date
    Dec 2014
    Posts
    12

    Re: Loading music files

    That’s brilliant Sam. Just what I needed although I haven’t unzipped it yet. Only just seen the replies so I hope you wasn’t thinking I was ungrateful. Same to you Arnoutdv. Many thanks

  11. #11

    Thread Starter
    New Member
    Join Date
    Dec 2014
    Posts
    12

    Re: Loading music files

    Quote Originally Posted by Arnoutdv View Post
    Very basic sample using the Dir() method of VB6.
    It does not do sub folders, just a scan of the given directory
    Code:
    Dim sFile As String
    
    ' This will ask for the first file name matching the given parameters
    sFile = Dir("C:\Albums\*.MP3")
    Do While Len(sFile) > 0
      ' This will print the found file title
      Debug.Print sFile 
      ' Ask for the next file
      sFile = Dir
    Loop
    Thanks for that Arnoutdv. Moving on from that example, how would it be possible to read the title of any sub folders i.e individual albums, the mp3 tracks within, and then move on to the next album?

  12. #12
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,145

    Re: Loading music files

    Did you run that program I sent? Does that.
    Sam I am (as well as Confused at times).

  13. #13

    Thread Starter
    New Member
    Join Date
    Dec 2014
    Posts
    12

    Re: Loading music files

    Hi Sam. I have run and looked at your program and there is a log of code I’m not familiar with but am still learning. What I can’t find in your program is the option to search for new files and tracks that will have been added to the Albums folder

  14. #14
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,145

    Re: Loading music files

    As long as you have added the songs (artist, album and title) manually to the appropriate subDirectory (format (under the directory in which the program is being run): \Music\Artist Name\Album\SongTitle.mp3), the program 'finds' the songs and the 'search' is sorted and displayed alphabetically by artist(s) last names.
    Sam I am (as well as Confused at times).

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