Page 1 of 2 12 LastLast
Results 1 to 40 of 54

Thread: Can vb play mp3's as easy as winamp can?

  1. #1

    Thread Starter
    Addicted Member SandmanSamR's Avatar
    Join Date
    Dec 2003
    Location
    Florida
    Posts
    131

    Can vb play mp3's as easy as winamp can?

    Like, can I make a program that works like that of winamp or can vb only play certain files?
    ';..;'
    Monsterous

    SANDMANSAMR
    SANDMANSAMR
    SANDMANSAMR
    SANDMANSAMR
    SANDMANSAMR

  2. #2
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    Its not VB that plays the files, but the Windows API. Search for mciSendString.
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  3. #3
    Hyperactive Member
    Join Date
    Feb 2003
    Location
    Grenada
    Posts
    346
    But for something a little closer to your level of programming you should just drag and drop the MediaPlayer component (Ctrl+T) into VB and start from there....

    Afetr you get more experienced then you can move on to declarations....
    If my post has been helpful, then please rate it accordingly...
    If it has solved your question(s), then don't forget to mark the thread as "[Resolved]"... thank you.

  4. #4
    PowerPoster Pc_Madness's Avatar
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    2,765
    The best solution. :thumb: Paste this code into a class file and declare it as

    Private MyPlayer as New ClassNAme

    then you can access it with,
    MyPlayer.Stop


    The post that I got it from had smilies enabled, so it did something similar to about 3 lines in the code, so if you get an error, it should be either ":)" or ";)" (without quotes).

    Enjoy. :)


    VB Code:
    1. Private Declare Function mciGetErrorString Lib "winmm.dll" Alias "mciGetErrorStringA" (ByVal dwError As Long, ByVal lpstrBuffer As String, ByVal uLength As Long) As Long
    2. Private Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal cchBuffer As Long) As Long
    3. Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long
    4. Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    5. Private Declare Function ReleaseCapture Lib "user32" () As Long
    6. Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
    7. Private Const SWP_NOMOVE = &H2
    8. Private Const SWP_NOSIZE = &H1
    9. Private Const HWND_TOPMOST = -1
    10. Private Const HWND_NOTOPMOST = -2
    11. Private TheFileName As String
    12.  
    13.  
    14.  
    15. Private Function IsItPlaying() As Boolean
    16. Static yn As String * 30
    17.     mciSendString "status MP3Play mode", yn, Len(yn), 0
    18.     IsItPlaying = (Mid$(yn, 1, 7) = "playing")
    19. End Function
    20.  
    21. Private Function mp3Play(FileName As String)
    22. Dim cmdToDo As String * 255
    23. Dim dwReturn As Long
    24. Dim ret As String * 128
    25.  
    26. Dim tmp As String * 255
    27. Dim lenShort As Long
    28. Dim ShortPathAndFie As String
    29.    
    30.     If Dir(FileName) = "" Then
    31.         mmOpen = "Error with input file"
    32.         Exit Function
    33.     End If
    34.     lenShort = GetShortPathName(FileName, tmp, 255)
    35.     ShortPathAndFie = Left$(tmp, lenShort)
    36.     glo_hWnd = hwnd
    37.     cmdToDo = "open " & ShortPathAndFie & " type MPEGVideo Alias MP3Play"
    38.     dwReturn = mciSendString(cmdToDo, 0&, 0&, 0&;)
    39.  
    40.     If dwReturn <> 0 Then  'not success
    41.         mciGetErrorString dwReturn, ret, 128
    42.         mmOpen = ret
    43.         MsgBox ret, vbCritical
    44.         Exit Function
    45.     End If
    46.    
    47.     mmOpen = "Success"
    48.     mciSendString "play MP3Play", 0, 0, 0
    49. End Function
    50.  
    51. Private Function mp3Pause()
    52.     mciSendString "pause MP3Play", 0, 0, 0
    53. End Function
    54.  
    55. Private Function mp3Unpause()
    56.     mciSendString "resume MP3Play", 0, 0, 0
    57. End Function
    58.  
    59. Private Function mp3Stop() As String
    60.     mciSendString "stop MP3Play", 0, 0, 0
    61.     mciSendString "close MP3Play", 0, 0, 0
    62. End Function
    63.  
    64. Private Function PositionInSec()
    65. Static PIS As String * 30
    66.     mciSendString "set MP3Play time format milliseconds", 0, 0, 0
    67.     mciSendString "status MP3Play position", PIS, Len(PIS), 0
    68.     PositionInSec = Round(Mid$(PIS, 1, Len(PIS)) / 1000)
    69. End Function
    70.  
    71. Private Function Position()
    72. Static P As String * 30
    73.     mciSendString "set MP3Play time format milliseconds", 0, 0, 0
    74.     mciSendString "status MP3Play position", P, Len(P), 0
    75.     sec = Round(Mid$(P, 1, Len(P)) / 1000)
    76.     If sec < 60 Then Position = "0:" & Format(sec, "00")
    77.     If sec > 59 Then
    78.         mins = Int(sec / 60)
    79.         sec = sec - (mins * 60)
    80.         Position = Format(mins, "00") & ":" & Format(sec, "00")
    81.     End If
    82. End Function
    83.  
    84. Private Function LengthInSec()
    85. Static L As String * 30
    86.     mciSendString "set MP3Play time format milliseconds", 0, 0, 0
    87.     mciSendString "status MP3Play length", L, Len(s), 0
    88.     LengthInSec = Round(Val(Mid$(L, 1, Len(L))) / 1000) 'Round(CInt(Mid$(s, 1, Len(s))) / 1000)
    89. End Function
    90.  
    91. Private Function Length()
    92. Static L As String * 30
    93.     mciSendString "set MP3Play time format milliseconds", 0, 0, 0
    94.     mciSendString "status MP3Play length", L, Len(L), 0
    95.     sec = Round(Val(Mid$(L, 1, Len(L))) / 1000) 'Round(CInt(Mid$(l, 1, Len(l))) / 1000)
    96.     If sec < 60 Then Length = "0:" & Format(sec, "00")
    97.     If sec > 59 Then
    98.         mins = Int(sec / 60)
    99.         sec = sec - (mins * 60)
    100.         Length = Format(mins, "00") & ":" & Format(sec, "00")
    101.     End If
    102. End Function
    103.  
    104. Private Function TimeRemaining() As String
    105.     RSecs = (LengthInSeconds) - (PositionInSec)
    106.     RMins = Int(RSecs / 60)
    107.     RSecs = Format((((RSecs / 60) - RMins) / 1.67), "0.00") * 100
    108.     If RSecs > 59 Then
    109.         RMins = RMins + 1
    110.         RSecs = 0#
    111.     Else: RMins = RMins
    112.         RSecs = RSecs
    113.     End If
    114.     If RSecs < 10 Then
    115.         TimeRemaining = RMins & ":0" & RSecs
    116.     Else: TimeRemaining = RMins & ":" & RSecs
    117.     End If
    118. End Function
    119.  
    120. Private Function SeekTo(Second)
    121.     mciSendString "set MP3Play time format milliseconds", 0, 0, 0
    122.     If IsItPlaying = True Then mciSendString "play MP3Play from " & Second, 0, 0, 0
    123.     If IsItPlaying = False Then mciSendString "seek MP3Play to " & Second, 0, 0, 0
    124. End Function
    125.  
    126. Private Function FastFoward(Second)
    127.     Second = (PositionInSec + Second) * 1000
    128.     mciSendString "set mpeg time format milliseconds", 0&, 0&, 0&
    129.     If IsItPlaying = True Then
    130.         mciSendString "play mpeg from " & Second, 0&, 0&, 0&
    131.     Else: mciSendString "seek mpeg from " & Second, 0&, 0&, 0&
    132.     End If
    133. End Function
    134.  
    135. Private Function Rewind(Second)
    136.     Second = (PositionInSec - Second) * 1000
    137.     mciSendString "set mpeg time format milliseconds", 0&, 0&, 0&
    138.     If IsItPlaying = True Then
    139.         mciSendString "play mpeg from " & Second, 0&, 0&, 0&
    140.     Else: mciSendString "seek mpeg from " & Second, 0&, 0&, 0&
    141.     End If
    142. End Function
    143.  
    144. Private Function SetVolume(Channel As String, VolumeValue As Long) As String
    145. Dim cmdToDo As String * 128
    146. Dim dwReturn As Long
    147. Dim ret As String * 128
    148. Dim VolumeV As Long
    149. VolumeV = VolumeValue
    150.  
    151. If VolumeV < 0 Or VolumeV > 100 Then
    152.     SetVolume = "out of volume"
    153.     Exit Function
    154. End If
    155.  
    156. VolumeV = VolumeV * 10
    157.  
    158. If LCase(Channel) = "left" Or LCase(Channel) = "right" Then
    159.     cmdToDo = "setaudio mpeg " & Channel & " Volume to " & VolumeV
    160. Else
    161.     cmdToDo = "setaudio mpeg Volume to " & VolumeV
    162. End If
    163.  
    164. dwReturn = mciSendString(cmdToDo, 0&, 0&, 0&)
    165.  
    166. If Not dwReturn = 0 Then  'not success
    167.     mciGetErrorString dwReturn, ret, 128 'Get the error
    168.     SetVolume = ret
    169.     Exit Function
    170. End If
    171.  
    172. 'Success
    173. SetVolume = "Success"
    174. End Function
    175.  
    176. Private Function Pitch(Value As Integer) As String
    177.     Dim dwReturn As Long
    178.     Dim ret As String * 128
    179.     Dim Pval As Long
    180.     Value = Value - 100
    181.     Pval = 1000 + Value
    182.     dwReturn = mciSendString("set mpeg speed " & Pval, 0&, 0&, 0&)
    183.     If Not dwReturn = 0 Then  'not success
    184.         mciGetErrorString dwReturn, ret, 128 'Get the error
    185.         Pitch = ret
    186.         Exit Function
    187.     End If
    188.    
    189. Pitch = "Success"
    190. End Function
    Don't Rate my posts.

  5. #5
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654
    That code needs serious fixing. First of all, where is Option Explicit? There are tons of undeclared variables... and when I started to go through fixing it, I ended up getting confused what the *censored* it is doing. TimeRemaining for example, it does something weird in there. And why all the return values are string? And why there are functions even if those don't return anything? Should be a sub then.

    Just some annoyances in that code

  6. #6
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654
    VB Code:
    1. RSecs = Format((((RSecs / 60) - RMins) / 1.67), "0.00") * 100

    What this line is doing again? Anyways, I'm converting it like this:

    RMins = RSecs \ 60
    RSecs = RSecs Mod 60

    If the original RSecs were the time in seconds, this should work.

  7. #7
    Hyperactive Member
    Join Date
    Feb 2003
    Location
    Grenada
    Posts
    346
    lol@Merri....

    Thank you....you just proved my prior statement...


    And @ PC_Madness.... what are you trying to do the kid with all those codes?

    The kid just found out what boolean is and you're gonna lay this sort of coding on him?

    (Not to mention the codes are incorrect...)

    If my post has been helpful, then please rate it accordingly...
    If it has solved your question(s), then don't forget to mark the thread as "[Resolved]"... thank you.

  8. #8
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654
    Well, the code does work (I guess, I didn't check it before I started to fix it). The problem is how it works and what it returns. It is far from optimal. And boy do people like optimal...


    Edit Here we go again!

    VB Code:
    1. If sec < 60 Then Position = "0:" & Format(sec, "00")
    2.     If sec > 59 Then
    3.         mins = Int(sec / 60)
    4.         sec = sec - (mins * 60)
    5.         Position = Format(mins, "00") & ":" & Format(sec, "00")
    6.     End If

    Dear lord...



    More edit I don't mean to be insultive, it just bugs me so much to see such a code. Or maybe I'm just evil?
    Last edited by Merri; Dec 27th, 2003 at 10:55 PM.

  9. #9

    Thread Starter
    Addicted Member SandmanSamR's Avatar
    Join Date
    Dec 2003
    Location
    Florida
    Posts
    131
    see, this is the type of overwhelming things I'm talking about. Why the hell is there so many things just to play a simple mp3?!

    Oh and thanks protocol. I know someone gots mah back
    ';..;'
    Monsterous

    SANDMANSAMR
    SANDMANSAMR
    SANDMANSAMR
    SANDMANSAMR
    SANDMANSAMR

  10. #10
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654
    I'm now working with a "better" class, which is fully commented and should be easy to use as well. I guess I make a sample program too. Atleast I can say I made it, since it is all different from the one posted above

    And yeah, it is made hard, but this is because there are so many things one might want to know (such as playback position, playback length and so on).

    Wonder if I go as far as getting tags... or, even, saving tags. That'd be cool to implement

  11. #11
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985
    Originally posted by SandmanSamR
    see, this is the type of overwhelming things I'm talking about. Why the hell is there so many things just to play a simple mp3?!

    Oh and thanks protocol. I know someone gots mah back
    To play an MP3 is a bit complicated. You only see the Play and Stop buttons in Winamp, the code for Winamp is actually quite LARGE.

    I was working on an MP3 class in C++. I haven't worked on it for a while, but the declarations of everything alone is a good 100-200 lines of code. Not to mention the ID3 v1, v1.1, and v2 Tag reading code. I haven't finished the whole playing part, lol.

    Anyway, there isn't going to be a very easy solution like
    Code:
    PlayMP3("Slayer.mp3")
    You first need to decide how you want to play it. Win API? Direct Sound? ect.... there are many ways. When you determine that, you will then need to learn how an MP3 file is made and works so you can write the code to play it.

    Seeing that you are new, I would suggest a different project. Perhaps a text editor or something? That way you'll learn the language much better before tackling such a project.

  12. #12

    Thread Starter
    Addicted Member SandmanSamR's Avatar
    Join Date
    Dec 2003
    Location
    Florida
    Posts
    131
    Just to get it stright, your gonna add stuff like
    VB Code:
    1. 'this does this because of this
    right?
    ';..;'
    Monsterous

    SANDMANSAMR
    SANDMANSAMR
    SANDMANSAMR
    SANDMANSAMR
    SANDMANSAMR

  13. #13
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985
    Originally posted by SandmanSamR
    Just to get it stright, your gonna add stuff like
    VB Code:
    1. 'this does this because of this
    right?
    Yes that is commenting.

  14. #14

    Thread Starter
    Addicted Member SandmanSamR's Avatar
    Join Date
    Dec 2003
    Location
    Florida
    Posts
    131
    Originally posted by kasracer

    I was working on an MP3 class

    I just started seeing class used in explinations, I am unfamiliar with the term. how, what, and why is it used? Normally I would first go look it up but its kind of hard looking up the word class without thousands of irrelevent results


    Seeing that you are new, I would suggest a different project. Perhaps a text editor or something? That way you'll learn the language much better before tackling such a project.

    Common now, Text editing? well yeah I guess so, seeing as how thats what we recently learned. Recently being couple weeks ago but still. I dont like the pace the class because 1/2 the class is learning slower then others, by a lot!
    ';..;'
    Monsterous

    SANDMANSAMR
    SANDMANSAMR
    SANDMANSAMR
    SANDMANSAMR
    SANDMANSAMR

  15. #15

    Thread Starter
    Addicted Member SandmanSamR's Avatar
    Join Date
    Dec 2003
    Location
    Florida
    Posts
    131
    I was just making sure, no harm no foul right?
    ';..;'
    Monsterous

    SANDMANSAMR
    SANDMANSAMR
    SANDMANSAMR
    SANDMANSAMR
    SANDMANSAMR

  16. #16
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985
    VB6 does not have classes. Classes are in OOP languages (Object Oriented Languages).

    VB.NET, C++, Objective C, C#, Java, ect.... are OOP languages.

  17. #17
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654
    Ok, "Class Module". There you go smarty

  18. #18
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985
    Originally posted by Merri
    Ok, "Class Module". There you go smarty
    "Class Module"? How can it be a class if there is no OOP in VB6?

  19. #19

    Thread Starter
    Addicted Member SandmanSamR's Avatar
    Join Date
    Dec 2003
    Location
    Florida
    Posts
    131
    so class module is not the same as class? I would fuiger them to be the same
    ';..;'
    Monsterous

    SANDMANSAMR
    SANDMANSAMR
    SANDMANSAMR
    SANDMANSAMR
    SANDMANSAMR

  20. #20
    Frenzied Member Shawn N's Avatar
    Join Date
    Dec 2001
    Location
    Houston
    Posts
    1,631
    VB does have classes. The language is just not class oriented.
    Please rate my post.

  21. #21
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654
    And here we have the MP3 class I've been working on. The class module and a simple project demonstrating how to use it.

    I included a proper error handler. It records all errors for programmer's convenience.

    And as a btw, I found atleast one mp3 which it didn't play. It seemed to work ok, but I didn't hear anything. I don't know if this is a bug in MCI or in my sound drivers. All other mp3s I tested played just fine.

    You're welcome to report any errors you find


    Edit Fixed GetStatus problem, it now returns the correct status.

    More edit This versiom has no ID3v1 support, scroll below for newer code.
    Attached Files Attached Files
    Last edited by Merri; Dec 28th, 2003 at 02:57 PM.

  22. #22
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629
    I downloaded it, and I'm going to check it right after I reinstall VB6.. I've been meaning to make some autoplay's for MP3 CDs that I've made in the past, but I didn't like the Media Player Control and it's options that much.. so, I'll get back to you.
    Like Archer? Check out some Sterling Archer quotes.

  23. #23
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654
    This new version has a reading support for ID3v1 tags. Enjoy
    Attached Files Attached Files

  24. #24
    Hyperactive Member
    Join Date
    Feb 2003
    Location
    Grenada
    Posts
    346
    lol

    @Merri....Just goes to show you that postcount does not make the Guru...

    I have yet to find an MP3 tag class that supports MusicMatch feature for album imaging....when that is done, to the codebank it goes.....


    @ kasracer: 100-200 lines of declarations?!!

    What are you creating an OS?
    If my post has been helpful, then please rate it accordingly...
    If it has solved your question(s), then don't forget to mark the thread as "[Resolved]"... thank you.

  25. #25
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654
    And a new version out. Now you can edit and save ID3v1 tags. Ain't that fun? Also, fixed an error in the genres list (values were one too big) and did some other minor enhancements somewhere. I can't find a bug, so its ready enough for another upload

    And, well, guru... I'm good only with some things. Maybe a guru of generic coding or something like that. And well, I haven't been all that much in here, so that's why my post count is so small. I'm no MadBoy who posts about anything and everything he gets his mind into before even thinking about trying doing it himself Ok, that was a bit over, but it is a half-truth, since he HAVE posted somewhat twice as much in two months as I have in the entire time I've been here (registered the first time in early 2001, add about 200 to my post count).

    Uhhuh, this is going too much off-topic, so please don't answer to this. Otherwise we gotta go to Chit Chat.

    Maybe I'm able to work on ID3v2 tags too. That requires a lot more work though, since I have no proper code ready for it atm and v2 tags are far more complicated to read (and especially write) than v1 tags.

    Also, I happened to find www.fmod.org - maybe I can make a similar class module for that DLL to ease the life of a VB programmer, since the DLL is free. I tested it and it worked like a charm. Ideal for playing audio. It supports OGGs and modules too
    Attached Files Attached Files

  26. #26
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    Originally posted by Protocol



    @ kasracer: 100-200 lines of declarations?!!

    What are you creating an OS?
    declarations do not only mean the API's. they are also public variables, types, UDT's.

    so combined, it probably WOULD be 100-200 lines.
    Remember, if someone's post was not helpful, you can always rate their post negatively .

  27. #27
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654
    I've been reading the ID3v2 specification and I'm pretty sure I understand it completely by now. Complex format compared to ID3v1, but I managed to get it after some ten hours of reading and pondering. Of course I did some other things in the while. I'm pretty sure I'm now able to write the code (I wrote some types while going through the document and fixed them as I understood more... atm I need only to write the code that does the dirty work and reads the tag into memory).

    I expect to have a new version of the class module to be out by tomorrow, with full ID3v2 support. Full means you can get any information from the tag, be it pictures or whatever it can have. I think the next bigger problem I have is CRC-32 since there can be CRC-32 data... as for encryptions and compressions, I'm leaving those for the programs to handle. There are just so many different ways to do it.

  28. #28

    Thread Starter
    Addicted Member SandmanSamR's Avatar
    Join Date
    Dec 2003
    Location
    Florida
    Posts
    131
    Originally posted by Protocol
    lol
    @ kasracer: 100-200 lines of declarations?!!

    What are you creating an OS?

    First of all, That is a phat ass program! Thank you!!!!

    a couple questions though, when I first opened it, it said something was wrong with this line:
    VB Code:
    1. Dim MyMP3 As New MP3_CLASS
    I just unloaded everything, opened project as new and just added the form and the class into the already opened project and it seems to have fixed that error message.

    Also, everytime I open a new song it says error "263|The specified device..." why does that keep opening?

    Do you think with my "know-how" I can add a playlist to that? and if so, what about a randomize order and/or play?
    I would rather try it before you go off and do it unless you think its to much of a task for me to handle
    Last edited by SandmanSamR; Dec 29th, 2003 at 01:12 PM.
    ';..;'
    Monsterous

    SANDMANSAMR
    SANDMANSAMR
    SANDMANSAMR
    SANDMANSAMR
    SANDMANSAMR

  29. #29
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    Originally posted by Protocol
    @ kasracer: 100-200 lines of declarations?!!

    What are you creating an OS? [/B]
    No offence intended, but it's called PROGRAMMING and not playing with toys
    \m/\m/

  30. #30
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654
    SandmanSamR:

    Yeah, I just noticed I forgot .FRX files from the zip file. And nobody told me I had done so. I don't update the zip before I get ID3v2 support done. Which is going on nicely, I just managed to read some of my files properly with it Still, it needs some expanding to be fully functional...

    First of all, does the song play? If it does, you can ignore the error. The error detection is maybe reacts too easily to things... but atleast it is quite good


    Then some small coding tutorials


    To go on with a simple playlist:

    - add a listbox
    - instead of placing a filename into txtFile textbox, add it to the listbox
    - modify code in butOpen to use List1.List(List1.ListIndex) instead of txtFile.Text to open files


    To have a random song playing when a song ends:

    - find the following line in StatusUpdate_Timer:
    VB Code:
    1. If Val(Status) = 4 And Length = Position Then MyMP3.SeekTo 0: MyMP3.PlayMP3
    Now, remove everything after Then and add butClose_Click, List1.ListIndex = Int(Rnd * List1.ListCount) and butOpen_Click


    You might get same song twice, as you don't keep any track on what have been played. You might encounter some errors too, since there is no error checking (such as if there are listitems at all in the listbox).

    Happy learning

  31. #31
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654
    Voilá! I have now coded a simple ID3v2 tag support. It isn't perfect... yet. Wonder if this will be ready this year? Two days to go...

    What I added:
    - flexible read and storage routines for ID3v2 tags
    - UTF-16 decoder (and the other character codings should work too)
    - tons of comments

    Maybe not that much done, but it was a hard job to get this far. ID3v2 isn't of the easiest formats... I guess its only popular because WinAmp uses it. Oh well, the hardest part is done. Now it needs only some fixing so that it is 100% standard compliant... it reads most tags just fine.

    If you find a problematic song, please let me know.
    Attached Files Attached Files

  32. #32
    PowerPoster Pc_Madness's Avatar
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    2,765
    Originally posted by Protocol
    And @ PC_Madness.... what are you trying to do the kid with all those codes?

    The kid just found out what boolean is and you're gonna lay this sort of coding on him?

    (Not to mention the codes are incorrect...)

    All he has to do is stick it into a class file and then he doesn't have to see it again.
    Don't Rate my posts.

  33. #33
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    Originally posted by Pc_Madness
    All he has to do is stick it into a class file and then he doesn't have to see it again.
    and to do that, he just needs to know what a class module is, how to use one, how to access one, how to initialize one
    Remember, if someone's post was not helpful, you can always rate their post negatively .

  34. #34
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654
    He also needs to edit the code so that it would work (the code has set all functions to Private! not accessible outside the class!), remove the parts that don't work (Pitch and SetVolume for the least), remove the unused API commands (GetShortPathName, SendMessage, ReleaseCapture, SetWindowPos), remove the unused constants, edit the file opening so that instead of using shortpathname API (because it doesn't work) it uses Chr(34) & Filename & Chr(34)...

    Umm... Am I going too far with listing what is wrong with the code...? I just hate code that doesn't work. There is too much of it in this world. Back to fixing mine.

  35. #35
    Hyperactive Member
    Join Date
    Apr 2001
    Location
    N42 29.340 W71 53.215
    Posts
    422

    Some suggestions

    Merri, you are my hero. I've been trying to figure out V2 tags for 2 months now.

    Few comments:
    The button with the ellipsis on it should probably say something like "Browse for MP3".

    Once a file is selected there, why not open it immediately on return from the common dialog? By "Open" I mean, read & display the tag info.

    Why an "Open" button? This seems to start playing (I don't have speakers on this PC). Shouldn't the "Play" button do that?

    Why a "Close" button?

    Wouldn't hurt to use the ToolTipText to add some help.

    Will you be adding V2 tag editing?

    Thanks and Happy New Year to all. Looking forward to the next release. DaveBo
    "The wise man doesn't know all the answers, but he knows where to find them."
    VBForums is one place, but for the really important stuff ... here's a clue 1Tim3:15

  36. #36
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654
    Sorry, I'm not concentrating to the actual program. I wanted to make it more clear how many different commands there are to play files. Like, play-button could be also the pause/resume button... but since these are three different commands, I wanted to point it out visually. It is a sample program and I'm concentrating on the Class Module itself.

    V2 editing is coming once I've fixed some things. I've already fixed an error in ID3v1 loading plus I've fixed some other things... atm I'm working CRC-32 support, since it is possible there is a file with CRC-32 checking. Now if I happened to have a CRC-32 enabled file, I'd be super-happy. I just have to make the support in theory... in the other hand, I gotta do a lot of things to be working in theory.

    Expect an update in a few hours

  37. #37
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654
    Here I come again with an another update. I made the ID3v2 reading support more complete, now it reads almost any ID3v2 enabled file (the only thing missing is reading of synchronized frame data, which I probably leave unimplemented - it would be a pain to reformat the code now).

    - added CRC-32 support
    - made error detection more complete: you now know where the error comes from
    - possible to get header information
    - fixed two-three stupid bugs (not sure if all of them were in the last version)
    - even more comments!
    - did I have UTF-16 support in the last version? Anyways, it is there now

    Once again, enjoy! I think I'm now ready to go on with ID3v2 writing


    Should I start a new topic for this?
    Attached Files Attached Files

  38. #38

    Thread Starter
    Addicted Member SandmanSamR's Avatar
    Join Date
    Dec 2003
    Location
    Florida
    Posts
    131
    I am learning a thing or two if it means anything to you. I got a question though, whats the purpose of adding the common dialog box?

    This topic is fine. If it wasn' t for more people posting I would say yeah, make a new one. As it is, people are aware of the updates so you dont really have to. Ultimatly it is up to you though, if you wish to show everyone on this board what you have done I have no problem with that
    ';..;'
    Monsterous

    SANDMANSAMR
    SANDMANSAMR
    SANDMANSAMR
    SANDMANSAMR
    SANDMANSAMR

  39. #39
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654
    I use Common Dialog Box to show the file opening dialog. It was the easiest way to do it. It can open only one file at a time though. I have a module that lets open multiple files at a time, showing the exactly same Dialog, but I didn't want to use it in this example. Wanted to keep it as simple as possible.

    Yet, I'm planning on making a more complex sample program, since ID3v2 is complex... and there is no way going around it. Maybe I make multiple sample programs on different possibilities of the Class Module (one as a simple MP3 player with ID3v1 view and a ID3v2 file browser or something like that).

  40. #40

    Thread Starter
    Addicted Member SandmanSamR's Avatar
    Join Date
    Dec 2003
    Location
    Florida
    Posts
    131
    what about scrolling text inside a textbox? would I just do
    VB Code:
    1. Private Sub Timer1_Timer()
    2. Filename.Left = Filename.Left - 50
    3.  
    4. If Filename.Left <= -2160 Then Filename.Left = Filename.Left + 50
    5. If Filename.Left >= 1920 Then Filename.Left = Filename.Left - 50
    6.  
    7.  
    8.  
    9. End Sub

    I just made it so that instead of the text moving inside the box, the whole textbox moves. I just made a frame to put it in so it doesn't overlap the other things and it looks cool
    Last edited by SandmanSamR; Dec 30th, 2003 at 08:03 PM.
    ';..;'
    Monsterous

    SANDMANSAMR
    SANDMANSAMR
    SANDMANSAMR
    SANDMANSAMR
    SANDMANSAMR

Page 1 of 2 12 LastLast

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