Jump to content

Winamp Automation Library


big_daddy
 Share

Recommended Posts

  • Moderators

So far its nothing more than the basics, but I plan on adding more funtionality as I have time.

Winamp doesn't have a native com interface so you must install ActiveWinamp for these function to work. I have provided a script that makes this process very easy.

ActiveWinamp Installer

ActiveWinamp_Installer.au3

T0.1-0, 9/13/2006

Winamp.au3

Examples

#include <Date.au3>
#include <Winamp.au3>

HotKeySet("{Esc}", "_Exit")

$oWinAmp = _WinampCreate("")
If @error Then Exit
$bAttached = @extended

$oEvent = ObjEvent($oWinAmp, "_Event_")

$oPlayList = $oWinAmp.playlist

If $oWinAmp.PlayState <> 1 Then
    If $oWinAmp.Playlist.Count > 0 Then
        $oWinAmp.Play
    EndIf
EndIf

While 1
    Sleep(100)
WEnd

Func _Event_ChangedTrack()
    Local $iHours, $iMins, $iSecs, $sLength = "", $sInfo = ""
    
    $oItem = $oPlayList ($oPlayList.position)
    
    $iLength = $oItem.Length
    _TicksToTime ( $iLength*1000, $iHours, $iMins, $iSecs )
    If $iHours Then $sLength &= $iHours & "hrs "
    If $iHours Or $iMins Then $sLength &= $iMins & "mins "
    $sLength &= $iSecs & "secs "
    
    $iRating = $oItem.Rating
    If $iRating = "255" Then $iRating = "Not Rated"
    
    $iPlayCount = $oItem.Playcount
    If $iPlayCount = -1 Then $iPlayCount = "Never Played"
    
    $sInfo &= "Artist: " & $oItem.Artist & @CRLF
    $sInfo &= "Title: " & $oItem.Title & @CRLF
    $sInfo &= "Album: " & $oItem.Album & @CRLF
    $sInfo &= "Genre: " & $oItem.Genre & @CRLF
    $sInfo &= "Track#: " & $oItem.Track & @CRLF
    $sInfo &= "Length: " & $sLength & @CRLF
    $sInfo &= "Playcount: " & $iPlayCount & @CRLF
    $sInfo &= "Rating: " & $iRating & @CRLF
    $sInfo &= "Filename: " & $oItem.Filename & @CRLF
    ConsoleWrite($sInfo & @CRLF)
EndFunc   ;==>_Event_ChangedTrack

Func _Exit()
    If Not $bAttached Then
        _WinampQuit($oWinAmp)
    EndIf   
    Exit
EndFunc   ;==>_Exit
Edited by big_daddy
Link to comment
Share on other sites

  • 4 weeks later...

& another script thet does not work...I get error when i try to compile the main thing, it says:

Error #include depth exceeded. make shure there are no recursive includes.

Im using

SciTE4AutoIt3

Version 1.70

Link to comment
Share on other sites

  • Moderators

& another script thet does not work...I get error when i try to compile the main thing, it says:

Error #include depth exceeded. make shure there are no recursive includes.

Im using

SciTE4AutoIt3

Version 1.70

I hope you are referring to another one of your scripts that does not work. :lmao:

I have not come across this error before, but I don't believe my library is the cause of it. If you are having troubles with your script please make a new post in the support forum.

Thanks,

Bob

Link to comment
Share on other sites

I hope you are referring to another one of your scripts that does not work. :lmao:

I have not come across this error before, but I don't believe my library is the cause of it. If you are having troubles with your script please make a new post in the support forum.

Installed: SciTE Version 1.71 & error was gone...must been bugged SciTE version or something.

PS: I ment that i tried to run, I dont even remember the count, of the alarm clock scrips posted hire & none of them worked.

Link to comment
Share on other sites

  • 2 weeks later...
  • 1 month later...

I updated the ActiveWinamp installer script by adding my own download progress GUI that I made. Feel free to use it.

#include <GUIConstants.au3>
#include <date.au3>
$sInstallPath = RegRead("HKCU\Software\Winamp", "")
If $sInstallPath = "" Then
    MsgBox(48, "Error", "You must have Winamp installed before running this script!" & _
            @CRLF & @CRLF & "The Winamp download page will now be opened for you.")
    Run(@ComSpec & " /c Start http://www.winamp.com/player/free.php", @WorkingDir, @SW_HIDE)
    Exit
EndIf

If Not FileExists($sInstallPath & "\Plugins\gen_activewa.dll") Then
    $iMsgBox = MsgBox(4, "ActiveWinamp", "Would you like to download and install ActiveWinamp now?")
    Switch $iMsgBox
        Case 6
            $sDownloadPath = "http://www.winamp.com/plugins/details.php?id=143299&download=yes" & _
                    "&url=http%3A%2F%2Fdownload.nullsoft.com%2Fcustomize%2Fcomponent%2F2004%2F11%2F2%2FP%2FActiveWinamp.exe"
            If DownloadFile($sDownloadPath,@TempDir & "\ActiveWinamp.exe") = 0 Then
                MsgBox(48,"Canceled","The download was canceled and the script will now exit.")
                Exit
            Endif
#cs
            $iDownloadSize = InetGetSize($sDownloadPath)
            InetGet($sDownloadPath, @TempDir & "\ActiveWinamp.exe", 0, 1)
            While @InetGetActive
                TrayTip("Download Progress", "Downloading " & Round(@InetGetBytesRead / 1024) & "KB of " & Round($iDownloadSize / 1024) & "KB", 0, 16)
                Sleep(100)
            WEnd
            TrayTip("", "", 0)
#ce
            If FileExists(@TempDir & "\ActiveWinamp.exe") Then
                RunWait(@TempDir & "\ActiveWinamp.exe", @WorkingDir)
                If FileExists($sInstallPath & "\Plugins\gen_activewa.dll") Then
                    MsgBox(0, "Installation Successful", "You are now ready to use WinAmp.au3!")
                    Exit
                Else
                    MsgBox(48, "Installation Failed", "Something went wrong with the install, please try running this script again.")
                    Exit
                EndIf
            Else
                MsgBox(48, "Error Downloading File", "Please download and install the file manually." & _
                        @CRLF & @CRLF & "The download site will be opened for you at this time.")
                Run(@ComSpec & " /c Start http://www.winamp.com/plugins/details.php?id=143299", @WorkingDir, @SW_HIDE)
                Exit
            EndIf
        Case 7
            Exit
        Case Else
            Exit
    EndSwitch
Else
    MsgBox(0, "ActiveWinamp", "You already have ActiveWinamp installed!")
EndIf

Func DownloadFile($s_URL, $s_Filename)
    $ProgressForm = GUICreate("Downloading ActiveWinamp...", 350, 88, (@DesktopWidth - 350) / 2, (@DesktopHeight - 88) / 2) ;283, 278)
    $downloadprogress = GUICtrlCreateProgress(8, 68, 337, 17, $PBS_SMOOTH)
    GUICtrlSetColor(-1, 0x0A246A)
    $lbldownloadspeed = GUICtrlCreateLabel("", 8, 48, 76, 17)
    $lblprogresstext = GUICtrlCreateLabel("Download in progress.  Please wait...",20,10, 210, 20)
    $sizeinbytes = InetGetSize($s_URL)
    $intsuccess = InetGet($s_URL, $s_Filename, 0, 1)
    $lbldownloadedpercent = GUICtrlCreateLabel("0%", 312, 48, 32, 17, $SS_RIGHT)
    $lbldownloadedovertotal = GUICtrlCreateLabel("0 KB/" & Int($sizeinbytes / 1024) & " KB", 112, 48, 118, 17, $SS_CENTER)
    $lblTimeElapsed = GUICtrlCreateLabel("Time Elapsed: 0:00:00",20,30,160,17)
    $lblEstimateTimeToCompletion = GUICtrlCreateLabel("Estimated Time Left:",165,30,250,17)
    GUISetState(@SW_SHOW)
    $intsuccess = ""
    $lastbytes = 0
    $timestamp = TimerInit()
    $timestamp2 = TimerInit()
    $timestamp3 = TimerInit()
    Local $iHours, $iMins, $iSecs
    While @InetGetActive = 1
        $msg = GUIGetMsg()
        If $msg = $GUI_EVENT_CLOSE Then
            $iMsgBoxAnswer = MsgBox(308, "Abort?", "Are you sure you want to abort this update?  All current download progress will be lost." & @CRLF & @CRLF & "Are you still sure you want to cancel this download and all its current progress?" & @CRLF & '(Clicking the "No" button will continue the download.)')
            Select
                Case $iMsgBoxAnswer = 6 ;Yes
                    InetGet("abort")
                    Close($s_Filename)
                    Return 0
                Case $iMsgBoxAnswer = 7 ;No
                    ;Do nothing and continue downloading
            EndSelect
        EndIf
        If TimerDiff($timestamp) >= 1000 Then
            GUICtrlSetData($lbldownloadspeed, Int((@InetGetBytesRead - $lastbytes) / 1024) & " KB/s")
#region - Calculate Tiem Elapsed
            $TicksFromDownloadStart = TimerDiff($timestamp3)
            _TicksToTime ($TicksFromDownloadStart , $iHours, $iMins, $iSecs )
            If $iMins < 10 Then $iMins = "0" & $iMins
            If $iSecs< 10 Then $iSecs = "0" & $iSecs
            GUICtrlSetData($lblTimeElapsed,"Time Elapsed: " & $iHours & ':' & $iMins & ':' & $iSecs)
#endregion -  Calculate Time Elapsed
#region  - Calculate Time Remaining
            $totalAverageKBPerSecond = (@InetGetBytesRead / 1024) / ($TicksFromDownloadStart/1000)
            _TicksToTime (Int((($sizeinbytes - @InetGetBytesRead)/1024)/$totalAverageKBPerSecond*1000), $iHours, $iMins, $iSecs ) 
            If $iMins < 10 Then $iMins = "0" & $iMins
            If $iSecs< 10 Then $iSecs = "0" & $iSecs
            GUICtrlSetData($lblEstimateTimeToCompletion,"Estimated Time Left: " & $iHours & ':' &  $iMins & ':' & $iSecs)
#endregion - Calculate Time Remaining
            $lastbytes = @InetGetBytesRead
            $timestamp = TimerInit()
        EndIf
        If TimerDiff($timestamp2) >= 50 Then
            GUICtrlSetData($lbldownloadedovertotal, Int(@InetGetBytesRead / 1024) & " KB/" & Int($sizeinbytes / 1024) & " KB")
            GUICtrlSetData($downloadprogress, (@InetGetBytesRead / $sizeinbytes) * 100)
            GUICtrlSetData($lbldownloadedpercent, Int(@InetGetBytesRead / $sizeinbytes * 100) & "%")
            $timestamp2 = TimerInit()
        EndIf
    WEnd
    GUIDelete($ProgressForm)
    Return 1
EndFunc 

Func Close($s_Filename)
    Sleep(100);wait to make sure that the file is no longer being written to
    Return FileDelete($s_Filename)
EndFunc   ;==>Close

"So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire

Link to comment
Share on other sites

Incredible!

Great!

And some others adjectives...

Great job! :P

Só o que posso lhe dizer, bom é quando faz mal!My work:Au3Irrlicht - Irrlicht for AutoItMsAgentLib - An UDF for MSAgentAu3GlPlugin T2 - A 3D plugin for AutoIt...OpenGl Plugin - The old version of Au3GlPlugin.MAC Address Changer - Changes the MAC AddressItCopter - A dragonfly R/C helicopter simulator

VW Bug user

Pinheiral (Pinewood) city:

http://pt.wikipedia.org/wiki/Pinheiral

Link to comment
Share on other sites

My little song anouncer. When the song changes is says: "The next song is $SONG by $ARTIST"

Very cool

#include <Date.au3>
#include <Winamp.au3>

HotKeySet("{Esc}", "_Exit")

$oWinAmp = _WinampCreate("")
If @error Then Exit
$bAttached = @extended
$oEvent = ObjEvent($oWinAmp, "_Event_")
$oPlayList = $oWinAmp.playlist
While 1
    Sleep(100)
WEnd

Func _Event_ChangedTrack()
    $oItem = $oPlayList ($oPlayList.position)
    $oWinAmp.Pause
    _TalkOBJ( "The next song is " & $oItem.Title & " by " & $oItem.Artist, 1 )
    $oWinAmp.Play
EndFunc   ;==>_Event_ChangedTrack

Func _Exit()
    If Not $bAttached Then
        _WinampQuit($oWinAmp)
    EndIf   
    Exit
EndFunc   ;==>_Exit

Func _TalkOBJ($s_text, $s_voice = 3)
    Local $quite = 0
    Local $o_speech = ObjCreate("SAPI.SpVoice")
    Select
        Case $s_voice == 0
            Return
        Case $s_voice == 1
            $o_speech.Voice = $o_speech.GetVoices ("Name=Microsoft Mary", "Language=409").Item (0);female
        Case $s_voice == 2
            $o_speech.Voice = $o_speech.GetVoices ("Name=Microsoft Mike", "Language=409").Item (0);male
        Case $s_voice == 3
            $o_speech.Voice = $o_speech.GetVoices ("Name=Microsoft Sam", "Language=409").Item (0);sam
    EndSelect
    $o_speech.Speak ($s_text)
    $o_speech = ""
    Sleep(1000)
    TrayTip("", "", 1)
EndFunc   ;==>_TalkOBJ
Check out ConsultingJoe.com
Link to comment
Share on other sites

  • Moderators

Nice!

I optimized the code a bit.

#include <Winamp.au3>

HotKeySet("{Esc}", "_Exit")

$o_speech = ObjCreate("SAPI.SpVoice")
$oWinAmp = _WinampCreate ("")
If @error Then Exit
$bAttached = @extended
$oEvent = ObjEvent($oWinAmp, "_Event_")
$oPlayList = $oWinAmp.playlist

While 1
    Sleep(100)
WEnd

Func _Event_ChangedTrack()
    $oItem = $oPlayList ($oPlayList.position)
    $oWinAmp.Pause
    _TalkOBJ("The next song is " & $oItem.Title & " by " & $oItem.Artist)
    $oWinAmp.Play
EndFunc   ;==>_Event_ChangedTrack

Func _TalkOBJ($s_text, $i_voice = 3)
    Switch $i_voice
        Case 1
            $o_speech.Voice = $o_speech.GetVoices ("Name=Microsoft Mary", "Language=409").Item (0);female
        Case 2
            $o_speech.Voice = $o_speech.GetVoices ("Name=Microsoft Mike", "Language=409").Item (0);male
        Case 3
            $o_speech.Voice = $o_speech.GetVoices ("Name=Microsoft Sam", "Language=409").Item (0);sam
        Case Else
            Return
    EndSwitch
    $o_speech.Speak ($s_text)
EndFunc   ;==>_TalkOBJ

Func _Exit()
    If Not $bAttached Then
        _WinampQuit ($oWinAmp)
    EndIf
    $o_speech = 0
    Exit
EndFunc   ;==>_Exit
Edited by big_daddy
Link to comment
Share on other sites

When I try the speech example, I get an error whn it trys to talk.

$o_speech.Voice = $o_speech.GetVoices ("Name=Microsoft Mary", "Language=409").Item (0)^ERROR

Error: The requested action with this object has failed.

Is there something else I need to make sure I have on the computer? ie voices enabled or something?

EDIT: the voice works when 3 (SAM) is selected, but not the others.

However. when it trigers it says "The next song is by" and nothing else. The song artist and title are showing in the playlist.

Also, if I try the first example script it displays $oItem.Filename but none of the others. It maybe the .mp3s not properly tagged?

WinXP

Winamp 2.95

AutoIt 3.1.1.98

These winamp scripts are cool BTW, very handy. thx guys

Edited by cyanidemonkey

My AutoIt Scripts.- AutoHost and Password Enabler for Delta Force 2 Demo.| Caffine for Winamp 2.9x and WRS 2.0 | mp3 directory cleaner | CRAP DJ | A:B:J Radio Automation Software | FFMPEG batch conversion automator

Link to comment
Share on other sites

When I try the speech example, I get an error whn it trys to talk.

$o_speech.Voice = $o_speech.GetVoices ("Name=Microsoft Mary", "Language=409").Item (0)^ERROR

Error: The requested action with this object has failed.

Is there something else I need to make sure I have on the computer? ie voices enabled or something?

EDIT: the voice works when 3 (SAM) is selected, but not the others.

However. when it trigers it says "The next song is by" and nothing else. The song artist and title are showing in the playlist.

Also, if I try the first example script it displays $oItem.Filename but none of the others. It maybe the .mp3s not properly tagged?

WinXP

Winamp 2.95

AutoIt 3.1.1.98

These winamp scripts are cool BTW, very handy. thx guys

It is probably because you don't have Microsoft marry installed

Check out ConsultingJoe.com
Link to comment
Share on other sites

Is there a way I could detect if a computer has the voice installed via au3 script?

ie: the script runs but before it says something between songs checks if the voice is loaded, if not move to next voice, or default voice.

My AutoIt Scripts.- AutoHost and Password Enabler for Delta Force 2 Demo.| Caffine for Winamp 2.9x and WRS 2.0 | mp3 directory cleaner | CRAP DJ | A:B:J Radio Automation Software | FFMPEG batch conversion automator

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...