Page 1 of 1

Winamp Fast Forwarding and Rewind (also Next and Prev tracks

Posted: Fri Apr 11, 2008 12:17 pm
by James D
First I will like to thank Richard for all his help on navigating me through the muddy waters of scripting. LOL. I was going totally in the wrong direction. Here is the procedure I used, in the development of my masterpiece. LOL.
1. The script reads the field in HB
2. The Next and Prev Procedure were pretty simple
3. To fast forward and rewind was pretty hard
4. First I had to split the seconds and minutes on my winamp song position and winamp song length.
5. I had to learn CInt or Convert to Integer Function (so 01:20 is 120) pretty cool.
6. Then I had to combine the minutes and seconds back and use the Int Function

Some initial problem I had that are fixed:
1. Fast forward would continue past the end of the song
2. The CInt for the seconds would not put a “0” for the numbers under 10.
a. Example :
Song Length is 4:03
CInt Minutes is 4
CInt Sec is 3 and not 03 (which I needed)
So when you combine the minutes and the seconds together you got: 43 instead of 403.


So now for the installation of the script.

Go into the property manager, and create a property called action.
Add the property to your WinAmp Device (mine is called WINAMP_CONTROLS)
Create 4 property change buttons changing the values to Next, Prev, FF, and FR for your WinAmp device in your selected panel.
Take the script below and Save it as WinAmp Controls.vbs or so.
Create a script device, and associate it to the script that you just created.
And set the script state to running. And hopefully it works for you, as it does for me.
I have it set up when my Audio Video Panel comes up It turns the script state to running
And when the Panel is closes it turns the state to stopped.


Here is the Script: Be Gentle, I am not a script genius, Yet. LOL

Option Explicit
'On Error Resume Next
Dim Action
Dim Data

'===============================================================================================
'Continuous running script
Do
Sleep 1
Action = GetPropertyValue("WINAMP_CONTROLS.Action")
If Action <> "Waiting" Then
SetPropertyValue "WINAMP_CONTROLS.Action", "Waiting"
Call Handle_WINAMP_CONTROLS(Action)
Sleep 50
End If
Loop

' Reset
Set rs = Nothing
Set FileName = Nothing
Set dbConn = Nothing

'======================================================================================================
Sub Handle_WINAMP_CONTROLS(Action)

Data = (Action)
Select Case Data
Case "FF" : Call FForwardCOND
Case "FR" : Call FRewind
Case "NEXT" : Call NEXT_Track
Case "PREV" : Call PREV_Track
End Select
End Sub
'======================================================================================================
Sub NEXT_Track
Dim NXT_TR
NXT_TR = GetPropertyValue("WINAMP_CONTROLS.Play List Song Number")
SetPropertyValue "WINAMP_CONTROLS.Play List Song Number", (NXT_TR +1)
End Sub
'======================================================================================================
Sub PREV_Track
Dim PR_TR
PR_TR = GetPropertyValue("WINAMP_CONTROLS.Play List Song Number")
SetPropertyValue "WINAMP_CONTROLS.Play List Song Number", (PR_TR -1)
End Sub
'======================================================================================================
Sub FForwardCOND
Dim SongTotal
Dim SongPos
Dim SongPosSec
Dim SongPosMin
Dim SongPosInt
Dim SongTotalSec
Dim SongTotalMin
Dim SongTotalInt

SongPos = GetPropertyValue("WINAMP_CONTROLS.Song Position")
SongPosMin = CInt(Left(SongPos, 2))
'msgBox SongPosMin
SongPosSec = CInt(Right(SongPos, 2))
'msgBox SongPosSec
SongPosInt = Int(SongPosMin & SongPosSec)
'msgBox SongPosInt

SongTotal = GetPropertyValue("WINAMP_CONTROLS.Song Length")
'msgbox SongTotal
SongTotalMin = CInt(Left(SongTotal, 2))
'msgBox SongTotalMin
SongTotalSec = CInt(Right(SongTotal, 2))
'msgBox SongTotalSec
IF SongTotalSec <= 9 then
SongTotalSec = ("0" & SongTotalSec)
'msgBox SongTotalSec
End If
'msgBox SongTotalSec
SongTotalInt = Int(SongTotalMin & SongTotalSec) -15
'msgbox SongTotalInt

IF SongPosInt > SongTotalInt then
Call NEXT_Track
Else
Call FForward
End If
End Sub
'=========================================================
Sub FForward
Dim F_Forward
Dim OffsetTimeInMin
Dim OffsetTimeInSecs
F_Forward = GetPropertyValue("WINAMP_CONTROLS.Song Position")
'msgBox F_Forward
OffsetTimeInSecs = CInt(Right(F_Forward, 2)) + 5
'msgBox OffsetTimeInSecs
OffsetTimeInMin = CInt(Left(F_Forward, 2))
'msgBox OffsetTimeInMin
SetPropertyValue "WINAMP_CONTROLS.Song Position", "Days=0, Hours=00, Minutes=" & OffsetTimeInMin & ", Seconds=" & OffsetTimeInSecs
End Sub
'======================================================================================================
Sub FRewind
Dim F_Rewind
Dim OffsetTimeInMin
Dim OffsetTimeInSecs
F_Rewind = GetPropertyValue("WINAMP_CONTROLS.Song Position")
OffsetTimeInSecs = CInt(Right(F_Rewind, 2)) - 5
'msgBox OffsetTimeInSecs
OffsetTimeInMin = CInt(Left(F_Rewind, 2))
'msgBox OffsetTimeInMin
SetPropertyValue "WINAMP_CONTROLS.Song Position", "Days=0, Hours=00, Minutes=" & OffsetTimeInMin & ", Seconds=" & OffsetTimeInSecs
End Sub
'======================================================================================================