Author Topic: CadAMP Windowless MP3 player for AutoCAD  (Read 23872 times)

0 Members and 1 Guest are viewing this topic.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
CadAMP Windowless MP3 player for AutoCAD
« Reply #15 on: March 30, 2004, 04:53:43 PM »
I actually thought of the modemacro thing. It will be pretty easy to implement, I also have figured out for the most part, the ability to adjust the location of the file playing.. by either moving a slider forward or reverse. I am having a bit of difficulty setting the slider position, and I would like to set a timer to move it while it is still visible, but I don't want the slider control to be visible always, this would create overhead, and I don't want overhead.

So essentially I have retrieved the length of the file in milliseconds, retrieved the current position in the file, divided the current position by the length (to get a percentage done) then multiplied it by 100 (to get a whole number)...
Then attempted to set that value to the slider control... but no go...
I may have to set it in the slider initialization stages...
I also set the changed event of the slider to close the form. That way there is no buttons to press. I also need a timer so if the user does not change the slider, it disappears. This could be a variable the user can set to display it for say 5 or 10 seconds... I see alot of other possibilities, but I have to take it slowly...since I am essentially doing it in free time (which is a premium).

If you could create a macro function to parse a b4s file (xml on steriods) that would return an array of the file names (and paths) that would be great.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

TR

  • Guest
CadAMP Windowless MP3 player for AutoCAD
« Reply #16 on: March 30, 2004, 07:19:05 PM »
I'll work on that macro tomorrow at lunch if I have time.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
CadAMP Windowless MP3 player for AutoCAD
« Reply #17 on: March 31, 2004, 12:01:38 AM »
Ok, to keep everyone up to date on this... tonight I added the following.....
Popup slider control, to position the song at any location
Modemacro showing the current file playing...
Midi support
I am still working on a bug introduced by the length extraction of a MP3 file. It seems the length reported and the length assigned by the timer is not the same. I was presumtuous perhaps to think that the timer milliseconds would correspond to the MP3 milliseconds returned.
I also have to add the modemacro resetting if the user closes the current file, and to kill the timer in that case as well.

As soon as I get a b4s module I will make it loop through the list of files..
Preferrably it will be a function returning the list of songs (with paths) as an array to the calling function.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
CadAMP Windowless MP3 player for AutoCAD
« Reply #18 on: March 31, 2004, 12:13:08 AM »
Ok the latest version is up there....for the taking... Follow this link
Feedback please....

D2H ... you got your search bar ....
Tim ... you got the status bar....

Any more requests ... except multiple files, I am still working on that one

Make sure you delete your existing CadAMP.mnc and CadAMP.mnr otherwise you wil not get the correct bitmaps
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

42

  • Bull Frog
  • Posts: 483
CadAMP Windowless MP3 player for AutoCAD
« Reply #19 on: March 31, 2004, 04:46:28 AM »
Very smart piece of kit. All I would ask for is the abiliuty to play multipul songs. Again thanks. :P  8)
Alastair Mallett Autodesk Certified Professional
Technical Director
Hunters South Architects

rugaroo

  • Bull Frog
  • Posts: 378
  • The Other CAD Guy
CadAMP Windowless MP3 player for AutoCAD
« Reply #20 on: March 31, 2004, 11:15:25 AM »
Keith -

I was able to find this by accident today, maybe it might help somewhere.

Code: [Select]


Private Sub PlaySong(ByVal Index As Integer)
'Purpose:  Load a song, then play it
    If Index >= 1 Then
        LoadSong Index
    Else
        LoadSong 1
    End If
   
    If MediaPlayer1.Filename <> "" Then
        MediaPlayer1.Play
        bStopPressed = False
    End If
End Sub

Private Sub LoadSong(ByVal Index As Integer)
'Purpose:  Loads a song into the mediaplayer and sets properties

    If Index <= lstPlayList1.ListItems.Count Then
        lstPlayList1.ListItems(iCurrentIndex).Bold = False
        lstPlayList1.ListItems(iCurrentIndex).ListSubItems(1).Bold = False
        lstPlayList1.ListItems(iCurrentIndex).ListSubItems(2).Bold = False
        iCurrentIndex = Index
        MediaPlayer1.Filename = lstFilenames.List(Index - 1)
       
        Label1.Caption = "Current Song: " & lstPlayList1.ListItems(Index).ListSubItems(1).Text & " by " & lstPlayList1.ListItems(Index).ListSubItems(2).Text
        'Label1.Caption = "Current Song: " & Right(lstPlayList.List(Index), Len(lstPlayList.List(Index)) - Len(Str(Index)) - 1)
        sFormTitle = frmMain.sPlayerName & " - [" & lstPlayList1.ListItems(Index).ListSubItems(1).Text & "-" & lstPlayList1.ListItems(Index).ListSubItems(2).Text & "]  "
        frmMain.Caption = sFormTitle
        'HCSSlider1.Max = MediaPlayer1.Duration
        'HCSSlider1.Min = 0
        lstPlayList1.ListItems(Index).Selected = True
        lstPlayList1.ListItems(Index).EnsureVisible
        lstPlayList1.ListItems(Index).Bold = True
        lstPlayList1.ListItems(Index).ListSubItems(1).Bold = True
        lstPlayList1.ListItems(Index).ListSubItems(2).Bold = True
        lstPlayList1.Refresh
    End If
End Sub
LDD06-09 | C3D 04-19 | Infraworks 360 | VS2012-VS2017

ELOQUINTET

  • Guest
CadAMP Windowless MP3 player for AutoCAD
« Reply #21 on: March 31, 2004, 03:23:43 PM »
keith it worked for me before but i downloaded the latest and now i get this message  :cry:

Macro name: MP3.PlayFile Execution error

rugaroo

  • Bull Frog
  • Posts: 378
  • The Other CAD Guy
CadAMP Windowless MP3 player for AutoCAD
« Reply #22 on: March 31, 2004, 03:25:41 PM »
Go to menuload, completely remove cadamp, and then completely reload the mnc file. I had the exact same problem.

R
LDD06-09 | C3D 04-19 | Infraworks 360 | VS2012-VS2017

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
CadAMP Windowless MP3 player for AutoCAD
« Reply #23 on: March 31, 2004, 03:32:57 PM »
Another issue is whether you are using VB6 or VB5. If you have VB5 then you will need to make a few modifications to the code.

Namely, you will need to replace all occurences of

AddressOf

with

MyAddressOf

and enclose the argument in quotes.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

TR

  • Guest
CadAMP Windowless MP3 player for AutoCAD
« Reply #24 on: April 01, 2004, 12:16:39 AM »
Keith:

Here's the deal: I honestly don't know how to create a function that returns an array (unless you can assign an array to a function that's supposed to return a string(I've never tried)), so the best thing I can do is return a string that you'd need to run the split() function on. If this is acceptable let me know.

Also, I don't know where you're getting .b4s files from. I have winamp 5 and the only playlist formats it supports are .m3u and .pls (which seem fairly easy to parse). Is a .b4s file a windows media player playlist? If so, could you upload one to the lilypad so I can take a look at it?

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
CadAMP Windowless MP3 player for AutoCAD
« Reply #25 on: April 01, 2004, 08:04:25 AM »
It is a winamp 4 playlist
The file is xml so the parsing should probably be about the same.

I would expect that you can create a string array then return that string, but you would need to test it to be sure.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

TR

  • Guest
CadAMP Windowless MP3 player for AutoCAD
« Reply #26 on: April 06, 2004, 06:04:24 PM »
Keith:

I still don't have a .b4s file to work with but here are two functions I created to read a .m3u and a .pls and return the songs in an array. The .bas file can be downloaded here.

the m3u function:
Code: [Select]

'This function reads the contents of a WinAMP m3u file and returns the
'file paths in an array
Public Function ParseM3U(M3UFile As String) As String()
Dim M3ULine As String
Dim M3USongs() As String
ReDim M3USongs(0) As String
Open M3UFile For Input As #1
Do While Not EOF(1)
Input #1, M3ULine
If Left(M3ULine, 1) = Chr(92) Then
    If M3USongs(0) = Null Then
        M3USongs(0) = M3ULine
    Else:
        ReDim Preserve M3USongs(LBound(M3USongs) To UBound(M3USongs) + 1) As String
        M3USongs(UBound(M3USongs)) = M3ULine
    End If
End If
Loop
Close #1
ParseM3U = M3USongs
End Function


the pls function:
Code: [Select]

'This function reads the contents of a WinAMP pls file and returns the
'file paths in an array
Public Function parsePLS(PLSFile As String) As String()
Dim PLSLine As String
Dim PLSLineStripped As String
Dim PLSSongs() As String
Dim I As Integer
ReDim PLSSongs(0) As String
Open PLSFile For Input As #1
Do While Not EOF(1)
Input #1, PLSLine
If LCase(Left(PLSLine, 4)) = "file" Then
    Do While Right(Left(PLSLine, I), 1) <> Chr(61)
        I = I + 1
    Loop
    PLSLineStripped = Right(PLSLine, Len(PLSLine) - I)
    If PLSSongs(0) = Null Then
        PLSSongs(0) = PLSLineStripped
    Else:
        ReDim Preserve PLSSongs(LBound(PLSSongs) To UBound(PLSSongs) + 1) As String
        PLSSongs(UBound(PLSSongs)) = PLSLineStripped
    End If
End If
Loop
Close #1
parsePLS = PLSSongs
End Function


Post a .b4s file to the lilly pond and I'll work on it.


Also, you need to revise the code so the seekbar doesn't show unless a mp3 is playing. Showing it without a song playing crashes my AutoCAD instantly. Something like this should work.

Code: [Select]

Sub StopMP3()
 Dim dwreturn As Long
 Dim Ret As String * 128
  dwreturn = mciSendString("close all", 0&, 0&, 0&)

 If dwreturn <> 0 Then
  mciGetErrorString dwreturn, Ret, 128
  MsgBox Ret, vbCritical
 End If
 ClearModeMacro
 PlayStatus = "stop"
End Sub


Code: [Select]

Sub SeekMP3Form()
If Not PlayStatus = vbNullString and Not PlayStatus = "stop" Then
   RetVal = TimerModule.TimerSetup(6000)
   SeekMP3.Show
End If
End Sub

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
CadAMP Windowless MP3 player for AutoCAD
« Reply #27 on: April 06, 2004, 06:18:42 PM »
Good enough... did you test the code above for the seekbar?
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

TR

  • Guest
CadAMP Windowless MP3 player for AutoCAD
« Reply #28 on: April 06, 2004, 07:38:22 PM »
I typed that out from here without testing. It should work though.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
CadAMP Windowless MP3 player for AutoCAD
« Reply #29 on: April 06, 2004, 09:03:14 PM »
I thought about that and I figured I should make it a bit more foolproof... I added a bit of code to check the status of the player, if it was still playing, it would display, but if it had stopped, then it would not display. This would prevent a user from selecting the button after the song had finished.

I have managed to add multiple file support via selection of multiple files, but it does not work without VB6. I am working on a solution for VB5, but it might not come as readily.

I also have added a skip to next or previous file if there is more than 1 file in the playlist.

I am preparing to add the PlayList mod as I type... give me a few minutes and I will upload the latest version.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie