#NoTrayIcon #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseX64=n #AutoIt3Wrapper_Icon=C:\Windows\shoutcast.ico #AutoIt3Wrapper_Outfile=TinyShoutCastTuner.exe #AutoIt3Wrapper_Compression=4 #AutoIt3Wrapper_UseUpx=n #AutoIt3Wrapper_Res_Description=Listen ShoutCast Radios Stations. #AutoIt3Wrapper_Res_Fileversion=1.0.3.5 #AutoIt3Wrapper_Res_Fileversion_AutoIncrement=P #AutoIt3Wrapper_Res_LegalCopyright=Copyright © wakillon 2012 #AutoIt3Wrapper_Res_Field=AutoIt Version|%AutoItVer% #AutoIt3Wrapper_Res_Field=Compile date|%longdate% %time% #AutoIt3Wrapper_Res_Icon_Add=C:\Windows\shoutcast.ico #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #Region ;************ Includes ************ #Include #Include #Include #Include #Include ; AutoItObject 1.2.2.0 #Include #Include #Include #Include #EndRegion ;************ Includes ************ Opt ( 'GuiOnEventMode', 1 ) Opt ( 'GUICloseOnESC', 0 ) Opt ( 'TrayOnEventMode', 1 ) Opt ( 'TrayMenuMode', 1 ) If Not _Singleton ( @ScriptName, 1 ) Then Exit OnAutoItExitRegister ( '_OnAutoItExit' ) #Region ------ Global Variables ------------------------------ Global Const $TBS_NOTICKS = 0x0010 Global Const $PBS_SMOOTH = 1 Global Const $TRAY_EVENT_PRIMARYUP = -8 Global Const $TRAY_CHECKED = 1 Global Const $TRAY_UNCHECKED = 4 Global $sMediaFile Global $oCOMError = ObjEvent ( 'AutoIt.Error', '_ErrFunc' ) _AutoItObject_StartUp () Global $oUSER32DLL = _AutoItObject_DllOpen ( 'user32.dll' ) Global $hVolSlider, $oGraphBuilder, $oMediaControl, $oBasicAudio, $oAudioMeterInformation Global $_Url, $_Version, $_SoftTitle _AudioVolObject ( $oAudioMeterInformation ) If _FileMissing () Then _FileInstall () Global $_RegKey1 = 'HKLM\SOFTWARE\TinyShoutCastTuner' Global $_RegKey2 = 'HKCU\Software\Microsoft\Windows\CurrentVersion\Run' If StringInStr ( @OsArch, '64' ) Then $_RegKey1 = 'HKLM64\SOFTWARE\TinyShoutCastTuner' $_RegKey2 = 'HKCU64\Software\Microsoft\Windows\CurrentVersion\Run' EndIf Global $_RegKeySettings = $_RegKey1 & '\Settings' Global $_GuiWidth = 635, $_GuiHeight = 370, $_ButtonWidth = 80, $_ButtonHeight=22 Global $_Gui, $_ListView, $_ListViewItem[1], $_ListViewItemMax, $_SimpleClick, $_DoubleClick, $_DevIdkey = BinaryToString ( InetRead ( $_Url & '/DevIdkey.txt' ) ) Global $_K=0, $_Progress, $sMediaFile2Old, $_DisplayName, $_DisplayName2, $_DisplayNameOld, $_LastStationUrl, $_TitleKey = 'TinyShoutCastTuner' Global $_ArrayId[1], $_ArrayName[1], $_ArrayGenre[1], $_ArrayUrl[1], $_ArrayListenerPeak[1], $_ArrayContentType[1], $_ArrayCurrentSong[1], $_ArrayBitrate[1] Global $_ArrayParts[3] = [170, 450, 635], $_StatusBar, $_HandleProgress, $_Input, $_Label, $_ComboBox1, $_ComboBox2, $_ComboBox3 Global $_ShowFavButton, $_ReMovFavButton, $_AddFavButton, $_FavoritesArrayName[1], $_FavoritesArrayUrl[1], $_ShowFavorites Global $_TypeSearch, $_MaxResults='&limit=30', $_Genre, $_KeyWords, $_SearchButton, $_PlayButton, $sMediaFile2, $iVol, $iPlaying=0 Global $_ShoutcastItem, $_StartItem, $_AboutItem, $_AddRadioToFavoritesItem, $_UpdateItem, $_SkinDllPath, $_Dll, $_SearchInfos, $sMediaFile3, $_EnableCheckForUpdates, $_UpdateLink #EndRegion --- Global Variables ------------------------------ #Region ------ Init ------------------------------ If Not _IsConnected () Then Exit MsgBox ( 262144+16, 'Error', 'You are Not Connected !' & @CRLF & 'Retry Later' & @CRLF & 'Exiting...', 5 ) $_Version = _GetScriptVersion () $_SoftTitle = 'TinyShoutCastTuner v' & $_Version & ' © wakillon 2012' _TrayMenu () ConsoleWrite ( '$_EnableCheckForUpdates : ' & $_EnableCheckForUpdates & @Crlf ) If $_EnableCheckForUpdates Then _LookForUpdate () _GuiCreate () _GUICtrlCreateListViewItems ( '' ) _InitBuilder ( $oGraphBuilder, $oMediaControl, $oBasicAudio ) _PlayLastListenedStation () _ShowFavorites () #EndRegion --- Init ------------------------------ #Region ------ Main Loop ------------------------------ While 1 If $iVol <> GUICtrlRead ( $hVolSlider ) Then $iVol = 100 -GUICtrlRead ( $hVolSlider ) If IsObj ( $oBasicAudio ) Then $oBasicAudio.put_Volume ( -Exp ( ( $iVol ) / 10.86 ) ) GUICtrlSetTip ( $hVolSlider, 100 -$iVol & ' %VOL' ) EndIf If $sMediaFile Then _RenderFile ( $sMediaFile ) If $_SearchInfos Then $_StringSplit = StringSplit ( StringReplace ( $_FavoritesArrayUrl[$_DoubleClick], 'http://', '' ), ':' ) $_Result = _GetShoutcastRadioInfos ( $_StringSplit[1], $_StringSplit[2], 3000 ) If IsArray ( $_Result ) Then $_Msg = 'Stream Title : ' & $_Result[1] & @CRLF & _ 'Content Type : ' & $_Result[4] & @CRLF & _ 'Bitrate : ' & $_Result[5] & @CRLF & _ 'Stream Genre : ' & $_Result[2] & @CRLF & _ 'Stream URL : ' & $_Result[3] & @CRLF & _ 'Current Song : ' & $_Result[6] & @CRLF GUICtrlSetData ( $_Label, $_Msg ) ClipPut ( $_Result[3] ) Else GUICtrlSetData ( $_Label, 'No Infos Found !' ) EndIf $sMediaFile2= $_FavoritesArrayUrl[$_DoubleClick] $_SearchInfos = 0 EndIf WEnd #EndRegion --- Main Loop ------------------------------ Func _About () TrayItemSetState ( $_AboutItem, $TRAY_UNCHECKED ) MsgBox ( 262144 + 64, $_Version, 'Informations' & @CRLF & @CRLF _ & 'Hello !' & @CRLF & 'I hope this software will be useful for listening Shoutcast Stations !' & @CRLF _ & 'A search can be done by filters, Top, Genre, KeyWords and Max number of Results.' & @CRLF _ & 'A double click on a station will display Infos about it.' & @CRLF _ & 'Url is copied to the Clipboard.' & @CRLF _ & 'You can add stations to your Favorites' & @CRLF _ & 'and remove them too, they are saved in Registry.' & @CRLF _ & 'You can Add Manually Stations to Favorites by Tray Menu Item.' & @CRLF _ & 'At start the Last Listened Station is automatically played.' & @CRLF _ & 'This program is free and is not protected by a Copyright.' & @CRLF _ & 'It can be distributed and copied, and may be modified and distributed under a different name.' & @CRLF _ & 'This program has been tested successfully on XP Sp3 32bit and Seven 64bit.' & @CRLF & @CRLF _ & 'Thanks to the AutoIt Community' & @CRLF & @CRLF _ & 'wakillon.', 0, $_GUI ) EndFunc ;==> _About () Func _AddManuallyRadioToFavorites () TrayItemSetState ( $_AddRadioToFavoritesItem, $TRAY_UNCHECKED ) Local $_UrlToAdd = InputBox ( 'Add Radio To Favorites', 'Enter Url and Port of a Station', 'http://84.54.140.229:8000', '', 240, 200 ) Local $_NameToAdd = InputBox ( 'Add Radio To Favorites', 'Enter Station Name', 'Station1', '', 240, 200 ) _GetFavorites () If Not _AlreadyInArray ( $_FavoritesArrayUrl, $_UrlToAdd, 0, 1 ) Then If $_UrlToAdd <> '' And $_NameToAdd <> '' Then RegWrite ( $_RegKey1 & '\Favorites', StringFormat ( '%03i', UBound ( $_FavoritesArrayUrl ) ), 'REG_SZ', $_UrlToAdd & '|' & $_NameToAdd ) $_StringLen=StringLen ( $_NameToAdd ) If $_ShowFavorites=1 Then _GetFavorites () _GUICtrlCreateListViewItems ( $_FavoritesArrayName ) EndIf MsgBox ( 262144, 'Success', $_NameToAdd & @Crlf & @Crlf & _StringRepeat ( ' ', Round ( ( $_StringLen-27 )/1.4 ) ) & 'has been added to Favorites', 2, $_GUI ) Else MsgBox ( 262144, 'Error', 'Station has not been added To Favorites', 3, $_GUI ) EndIf Else MsgBox ( 262144, 'Error', 'This Radio is already in your Favorites', 3, $_GUI ) EndIf EndFunc ;==> _AddManuallyRadioToFavorites () Func _AddToFavorites () If $_DoubleClick = '' Then $_DoubleClick = $_SimpleClick If $_DoubleClick > UBound ( $_ArrayUrl ) -1 Then Return Local $_UrlToAdd = $_ArrayUrl[$_DoubleClick] Local $_NameToAdd = $_ArrayName[$_DoubleClick] _GetFavorites () If Not _AlreadyInArray ( $_FavoritesArrayUrl, $_UrlToAdd, 0, 1 ) Then If $_UrlToAdd <> '' Then _ RegWrite ( $_RegKey1 & '\Favorites', StringFormat ( '%03i', UBound ( $_FavoritesArrayUrl ) ), 'REG_SZ', $_UrlToAdd & '|' & $_NameToAdd ) If $_NameToAdd <> '' Then $_StringLen=StringLen ( $_NameToAdd ) MsgBox ( 262144, 'Success', $_NameToAdd & @Crlf & @Crlf & _StringRepeat ( ' ', Round ( ( $_StringLen-27 )/1.4 ) ) & 'has been added to Favorites', 2, $_GUI ) EndIf Else MsgBox ( 262144, 'Error', 'This Radio is already in your Favorites', 3, $_GUI ) EndIf EndFunc ;==> _AddToFavorites () Func _AlreadyInArray ( $_SearchArray, $_Item, $_Start=0, $_Partial=0 ) _ArraySearch ( $_SearchArray, $_Item, $_Start, 0, 0, $_Partial ) If Not @error Then Return 1 EndFunc ;==> _AlreadyInArray () Func _AudioVolObject ( ByRef $oAudioMeterInformation ) Local Const $sCLSID_MMDeviceEnumerator = '{BCDE0395-E52F-467C-8E3D-C4579291692E}' Local Const $sIID_IMMDeviceEnumerator = '{A95664D2-9614-4F35-A746-DE8DB63617E6}' Global $dtagIMMDeviceEnumerator = $dtagIUnknown & _ "EnumAudioEndpoints hresult(dword;dword;ptr*);" & _ "GetDefaultAudioEndpoint hresult(dword;dword;ptr*);" & _ "GetDevice hresult(wstr;ptr*);" & _ "RegisterEndpointNotificationCallback hresult(ptr);" & _ "UnregisterEndpointNotificationCallback hresult(ptr);" Local $dtagIMMDevice = $dtagIUnknown & _ "Activate hresult(ptr;dword;variant*;ptr*);" & _ "OpenPropertyStore hresult(dword;ptr*);" & _ "GetId hresult(wstr*);" & _ "GetState hresult(dword*);" Local Const $sIID_IAudioMeterInformation = '{C02216F6-8C67-4B5B-9D00-D008E73E0064}' Local $dtagIAudioMeterInformation = $dtagIUnknown & _ "GetPeakValue hresult(float*);" & _ "GetMeteringChannelCount hresult(dword*);" & _ "GetChannelsPeakValues hresult(dword;float*);" & _ "QueryHardwareSupport hresult(dword*);" Local $oMMDeviceEnumerator = _AutoItObject_ObjCreate ( $sCLSID_MMDeviceEnumerator, $sIID_IMMDeviceEnumerator, $dtagIMMDeviceEnumerator ) If @error Then Return SetError ( 1, 0, 0 ) Local $aCall = $oMMDeviceEnumerator.GetDefaultAudioEndpoint ( 0, 0, 0 ) If Not IsArray ( $aCall ) Then Return SetError ( 2, 0, 0 ) Local $oDefaultDevice = _AutoItObject_WrapperCreate ( $aCall[3], $dtagIMMDevice ) Local $pIID_IAudioMeterInformation = _AutoItObject_CLSIDFromString ( $sIID_IAudioMeterInformation ) $aCall = $oDefaultDevice.Activate ( Number ( DllStructGetPtr ( $pIID_IAudioMeterInformation ) ), 1, 0, 0 ) If Not IsArray ( $aCall ) Then Return SetError ( 3, 0, 0 ) $oAudioMeterInformation = _AutoItObject_WrapperCreate ( $aCall[4], $dtagIAudioMeterInformation ) Return True EndFunc ;==> _AudioVolObject () Func _DisplayCurrentSong () If $sMediaFile3 = '' Then Return Local $_Ip, $_Port, $_Var $_Ip = _StringBetween ( $sMediaFile3, 'http://', ':' ) $_Port = _StringBetween ( StringReplace ( $sMediaFile3, 'http://', '' ), ':', '' ) $_Var = _GetCurrentSong ( $_Ip[0], $_Port[0] ) If $iPlaying And $_Var <> 'N/A' Then _GUICtrlStatusBar_SetText ( $_StatusBar, $_Var, 1 ) EndFunc ;==> _DisplayCurrentSong () Func _EnableCheckForUpdates () $_EnableCheckForUpdates = _IsTrayItemChecked ( $_UpdateItem ) RegWrite ( $_RegKeySettings, 'EnableCheckForUpdates', 'REG_SZ', $_EnableCheckForUpdates ) EndFunc ;==> _EnableCheckForUpdates () Func _ErrFunc ( $oCOMError ) ConsoleWrite ( '!->--- COM Error ! err.number is: ' & @TAB & $oCOMError.number & @CRLF & _ 'err.windescription:' & @TAB & $oCOMError.windescription & @CRLF & _ 'err.description is: ' & @TAB & $oCOMError.description & @CRLF & _ 'err.source is: ' & @TAB & $oCOMError.source & @CRLF & _ 'err.helpfile is: ' & @TAB & $oCOMError.helpfile & @CRLF & _ 'err.helpcontext is: ' & @TAB & $oCOMError.helpcontext & @CRLF & _ 'err.lastdllerror is: ' & @TAB & $oCOMError.lastdllerror & @CRLF & _ 'err.scriptline is: ' & @TAB & $oCOMError.scriptline & @CRLF & _ 'err.retcode is: ' & @TAB & $oCOMError.retcode & @CRLF & @CRLF ) EndFunc ;==> _ErrFunc () Func _FileInstall () If Not _IsConnected () Then Exit MsgBox ( 262144+16, 'Error', 'You are Not Connected !' & @CRLF & 'Retry Later' & @CRLF & 'Exiting...', 5 ) ToolTip ( _StringRepeat ( ' ', 12 ) & 'Please Wait while downloading externals files' & @Crlf, @DesktopWidth/2-152, 0, $_Version, 1, 4 ) If Not FileExists ( @TempDir & '\TST\skin' ) Then DirCreate ( @TempDir & '\TST\skin' ) If Not FileExists ( @TempDir & '\TST\skin\SkinCrafterDll.dll' ) Then InetGet ( $_Url & '/SkinCrafterDll.dll', @TempDir & '\TST\skin\SkinCrafterDll.dll', 9, 0 ) If Not FileExists ( @TempDir & '\TST\skin\Amazonite.skf' ) Then InetGet ( $_Url & '/Amazonite.skf', @TempDir & '\TST\skin\Amazonite.skf', 9, 0 ) If Not FileExists ( @WindowsDir & '\shoutcast.ico' ) Then InetGet ( $_Url & '/shoutcast.ico', @WindowsDir & '\shoutcast.ico', 9, 0 ) ToolTip ( '' ) EndFunc ;==> _FileInstall () Func _FileMissing () $_Url = 'http://tinyurl.com/cpey6v8' If Not FileExists ( @TempDir & '\TST\skin' ) Then Return True If Not FileExists ( @TempDir & '\TST\skin\SkinCrafterDll.dll' ) Then Return True If Not FileExists ( @TempDir & '\TST\skin\Amazonite.skf' ) Then Return True If Not FileExists ( @WindowsDir & '\shoutcast.ico' ) Then Return True EndFunc ;==> _FileMissing () Func _GetCurrentSong ( $_Host, $_Port=8000, $_TimeOut=1500 ) TCPStartUp () Local $_Timer = TimerInit (), $_Shoutcast = TCPConnect ( $_Host, $_Port ), $_Recv, $_CurrentSong If $_Shoutcast = -1 Then TCPShutdown () Return EndIf TCPSend ( $_Shoutcast, 'GET / HTTP/1.1' & @CRLF & 'Icy-MetaData:1' & @CRLF & @CRLF ) While 1 $_Recv = BinaryToString ( TCPRecv ( $_Shoutcast, 1024, 1 ), 1 ) If $_Recv <> '' Then If StringInStr ( $_Recv, 'StreamTitle=' ) Then $_CurrentSong = StringSplit ( $_Recv, 'StreamTitle=', 1 ) $_CurrentSong = StringSplit ( $_CurrentSong[2], ';StreamUrl=', 1 ) TCPCloseSocket ( $_Shoutcast ) TCPShutdown () Return _StringProper ( StringReplace ( $_CurrentSong[1], "'", "" ) ) EndIf EndIf If TimerDiff ( $_Timer ) > $_TimeOut Then TCPCloseSocket ( $_Shoutcast ) TCPShutdown () Return 'N/A' EndIf WEnd EndFunc ;==> _GetCurrentSong () Func _GetDefaultBrowser () Local $_DefautBrowser = StringRegExp ( RegRead ( 'HKCR\http\shell\open\command', '' ), '(?s)(?i)"(.*?)"', 3 ) If Not @error And FileExists ( $_DefautBrowser[0] ) Then Return $_DefautBrowser[0] Local $_UserChoice = RegRead ( 'HKCU\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice', 'Progid' ) If Not @error Then $_DefautBrowser = StringRegExp ( RegRead ( 'HKLM\Software\Classes\' & $_UserChoice & '\shell\open\command', '' ), '(?s)(?i)"(.*?)"', 3 ) If Not @error And FileExists ( $_DefautBrowser[0] ) Then Return $_DefautBrowser[0] EndIf Return 'iexplore.exe' EndFunc ;==> _GetDefaultBrowser () Func _GetFavorites () ReDim $_FavoritesArrayUrl[1], $_FavoritesArrayName[1] For $_J = 1 To 1000 $_Value = RegEnumVal ( $_RegKey1 & '\Favorites', $_J ) If @error <> 0 Then ExitLoop $_RegRead = RegRead ( $_RegKey1 & '\Favorites', $_Value ) $_StringSplit=StringSplit ( $_RegRead, '|' ) If @error <> 0 Then ExitLoop _ArrayAdd ( $_FavoritesArrayUrl, $_StringSplit[1] ) _ArrayAdd ( $_FavoritesArrayName,$_StringSplit[2] ) Next RegDelete ( $_RegKey1 & '\Favorites' ) For $_J = 1 To UBound ( $_FavoritesArrayName ) -1 RegWrite ( $_RegKey1 & '\Favorites', StringFormat ( '%03i', $_J ), 'REG_SZ', $_FavoritesArrayUrl[$_J] & '|' & $_FavoritesArrayName[$_J] ) Next EndFunc ;==> _GetFavorites () Func _GetGenre () $_Genre = GUICtrlRead ( $_ComboBox2 ) If $_Genre = 'Select Genre' Then $_Genre = '' Else $_Genre = '&genre=' & $_Genre EndIf $_Genre = StringReplace ( $_Genre, ' ', '+' ) EndFunc ;==> _GetGenre () Func _GetKeyWords () $_KeyWords = GUICtrlRead ( $_InPut ) If $_KeyWords = 'Select KeyWords' Then $_KeyWords = '' Else $_KeyWords = '&search=' & StringReplace ( StringStripWS ( $_KeyWords, 7 ), ' ', '+' ) EndIf EndFunc ;==> _GetKeyWords () Func _GetMaxResults () $_MaxResults = GUICtrlRead ( $_ComboBox3 ) If $_MaxResults = 'Max Results' Then $_MaxResults = 30 $_MaxResults = '&limit=' & $_MaxResults EndFunc ;==> _GetMaxResults () Func _GetScriptVersion () Local $_FileVersion If @Compiled Then $_FileVersion = FileGetVersion ( @ScriptFullPath, 'FileVersion' ) Else $_FileVersion = _StringBetween ( FileRead ( @ScriptFullPath ), '#AutoIt3Wrapper_Res_Fileversion=', @CR ) If Not @error Then $_FileVersion = $_FileVersion[0] Else $_FileVersion = '0.0.0.0' EndIf EndIf RegWrite ( $_RegKeySettings, 'Version', 'REG_SZ', $_FileVersion ) Return $_FileVersion EndFunc ;==> _GetScriptVersion () Func _GetShoutcastRadioInfos ( $_Host, $_Port=8000, $_TimeOut=2000 ) TCPStartUp () Local $_Timer = TimerInit (), $_Shoutcast = TCPConnect ( $_Host, $_Port ), $_CurrentSong, $_Info Dim $_ArrayInfo[7] If $_Shoutcast = -1 Then TCPShutdown () Return EndIf TCPSend ( $_Shoutcast, 'GET / HTTP/1.0' & @CRLF & 'Icy-MetaData:1' & @CRLF & @CRLF ) While 1 $_Recv = BinaryToString ( TCPRecv ( $_Shoutcast, 1024 ) ) If $_Recv <> '' Then If StringInStr ( $_Recv, 'icy-name:' ) Then $_Info = _StringBetween ( $_Recv, 'icy-name:', @CR ) If Not @error And Not $_ArrayInfo[1] Then $_ArrayInfo[1]=$_Info[0] EndIf If StringInStr ( $_Recv, 'icy-genre:' ) Then $_Info = _StringBetween ( $_Recv, 'icy-genre:', @CR ) If Not @error And Not $_ArrayInfo[2] Then $_ArrayInfo[2]=$_Info[0] EndIf If StringInStr ( $_Recv, 'icy-url:' ) Then $_Info = _StringBetween ( $_Recv, 'icy-url:', @CR ) If Not @error And Not $_ArrayInfo[3] Then $_ArrayInfo[3]=$_Info[0] EndIf If StringInStr ( $_Recv, 'content-type:' ) Then $_Info = _StringBetween ( $_Recv, 'content-type:', @CR ) If Not @error And Not $_ArrayInfo[4] Then $_ArrayInfo[4]=$_Info[0] EndIf If StringInStr ( $_Recv, 'icy-br:' ) Then $_Info = _StringBetween ( $_Recv, 'icy-br:', @CR ) If Not @error And Not $_ArrayInfo[5] Then $_ArrayInfo[5]=$_Info[0] EndIf If StringInStr ( $_Recv, 'StreamTitle=' ) Then $_CurrentSong = StringSplit ( $_Recv, 'StreamTitle=', 1 ) $_CurrentSong = StringSplit ( $_CurrentSong[2], ';StreamUrl=', 1 ) TCPCloseSocket ( $_Shoutcast ) $_ArrayInfo[6]=StringReplace ( $_CurrentSong[1], "'", "" ) $_ArrayInfo[0]=UBound ( $_ArrayInfo ) -1 TCPShutdown () Return $_ArrayInfo EndIf EndIf If TimerDiff ( $_Timer ) > $_TimeOut Then TCPCloseSocket ( $_Shoutcast ) TCPShutdown () Return EndIf WEnd EndFunc ;==> _GetShoutcastRadioInfos () Func _GetSourceCode ( $_Url ) Local $_InetRead = InetRead ( $_Url ) If Not @Error Then Local $_BinaryToString = BinaryToString ( $_InetRead ) If Not @Error Then Return $_BinaryToString EndIf EndFunc ;==> _GetSourceCode () Func _GetStationBitrate ( $_ArrayItem ) Local $_StationBitrate = _StringBetween ( $_ArrayItem, '" br="', '"' ) If Not @error Then Return $_StationBitrate[0] EndFunc ;==> _GetStationBitrate () Func _GetStationContentType ( $_ArrayItem ) Local $_StationContentType = _StringBetween ( $_ArrayItem, 'mt="', '"' ) If Not @error Then If StringInStr ( $_StationContentType[0], 'aacp' ) Then Return 'aac' If StringInStr ( $_StationContentType[0], 'mpeg' ) Then Return 'mp3' EndIf EndFunc ;==> _GetStationContentType () Func _GetStationGenre ( $_ArrayItem ) Local $_StationGenre = _StringBetween ( $_ArrayItem, 'genre="', '"' ) If Not @error Then Return $_StationGenre[0] EndFunc ;==> _GetStationGenre () Func _GetStationId ( $_ArrayItem ) Local $_Id = _StringBetween ( $_ArrayItem, 'id="', '"' ) If Not @error Then Return $_Id[0] EndFunc ;==> _GetStationId () Func _GetStationListenerPeak ( $_ArrayItem ) Local $_StationListenerPeak = _StringBetween ( $_ArrayItem, 'lc="', '"' ) If Not @error Then Return $_StationListenerPeak[0] EndFunc ;==> _GetStationListenerPeak () Func _GetStationName ( $_ArrayItem ) Local $_StationName = _StringBetween ( $_ArrayItem, '', '"' ) If Not @error Then Return _StringProper ( StringStripWS ( StringRegExpReplace ( StringReplace ( StringReplace ( $_StationName[0], _ ' - a SHOUTcast.com member station' , '' ), '&', '&' ), "(?i)[^a-z0-9]", ' ' ), 7 ) ) EndFunc ;==> _GetStationName () Func _GetStationUrlById ( $_StationId, $_DevIdkey ) Local $_SourceCode = _GetSourceCode ( 'http://yp.shoutcast.com/sbin/tunein-station.pls?id=' & $_StationId & '&k=' & $_DevIdkey ) Local $_StationUrl = _StringBetween ( $_SourceCode, 'File', @LF ), $_StringBetween If Not @error Then For $_J = 0 To UBound ( $_StationUrl ) -1 $_StringBetween = _StringBetween ( $_StationUrl[$_J], '=', '' ) If Not @error Then $_StationUrl[$_J] = $_StringBetween[0] If StringInStr ( $_StationUrl[$_J], '/stream/' ) = 0 Then Return $_StationUrl[$_J] EndIf Next Return EndIf EndFunc ;==> _GetStationUrlById () Func _GetTypeSearch () $_TypeSearch = GUICtrlRead ( $_ComboBox1 ) Select Case $_TypeSearch = 'Top' GUICtrlSetState ( $_ComboBox2, $GUI_HIDE ) GUICtrlSetState ( $_InPut, $GUI_HIDE ) Case $_TypeSearch = 'Genre' GUICtrlSetState ( $_ComboBox2, $GUI_SHOW ) GUICtrlSetState ( $_InPut, $GUI_HIDE ) Case $_TypeSearch = 'KeyWords' GUICtrlSetState ( $_ComboBox2, $GUI_HIDE ) GUICtrlSetState ( $_InPut, $GUI_SHOW ) Case Else $_TypeSearch = '' GUICtrlSetState ( $_ComboBox2, $GUI_HIDE ) GUICtrlSetState ( $_InPut, $GUI_HIDE ) EndSelect EndFunc ;==> _GetTypeSearch () Func _GuiCreate () $_Gui = GUICreate ( ' ' & $_SoftTitle, $_GuiWidth, $_GuiHeight ) _SkinGui ( $_Gui, @TempDir & '\TST\skin\SkinCrafterDll.dll', @TempDir & '\TST\skin\Amazonite.skf' ) GUISetIcon ( @WindowsDir & '\shoutcast.ico' ) GUISetOnEvent ( $GUI_EVENT_CLOSE, '_Terminate' ) $_PlayButton = GUICtrlCreateButton ( 'Play', 15, 288, $_ButtonWidth, $_ButtonHeight ) GUICtrlSetTip ( $_PlayButton, 'Play Selected ShoutCast Station' ) GUICtrlSetOnEvent ( $_PlayButton, '_Play' ) $_StopButton = GUICtrlCreateButton ( 'Stop', 102, 288, $_ButtonWidth, $_ButtonHeight ) GUICtrlSetTip ( $_StopButton, 'Stop Listen' ) GUICtrlSetOnEvent ( $_StopButton, '_Stop' ) $_AddFavButton = GUICtrlCreateButton ( 'Add To Favorites', 378, 288, $_ButtonWidth*1.4, $_ButtonHeight ) GUICtrlSetTip ( $_AddFavButton, 'Add Selected Station To Favorites' ) GUICtrlSetOnEvent ( $_AddFavButton, '_AddToFavorites' ) $_ShowFavButton = GUICtrlCreateButton ( 'Show Favorites list', 378, 318, $_ButtonWidth*1.4, $_ButtonHeight ) GUICtrlSetTip ( $_ShowFavButton, 'Show Favorites list' ) GUICtrlSetOnEvent ( $_ShowFavButton, '_ShowFavorites' ) $_ReMovFavButton = GUICtrlCreateButton ( 'Remove From Favorites', 495, 288, $_ButtonWidth*1.5, $_ButtonHeight ) GUICtrlSetTip ( $_ReMovFavButton, 'Remove Selected Station From Favorites' ) GUICtrlSetOnEvent ( $_ReMovFavButton, '_ReMoveFromFavorites' ) GUICtrlSetState ( $_ReMovFavButton, $GUI_DISABLE ) $_ExitButton = GUICtrlCreateButton ( 'Exit', 495, 318, $_ButtonWidth*1.5, $_ButtonHeight ) GUICtrlSetTip ( $_ExitButton, 'Goodbye...' ) GUICtrlSetOnEvent ( $_ExitButton, '_Terminate' ) $_SearchButton = GUICtrlCreateButton ( 'Search', 15, 318, $_ButtonWidth, $_ButtonHeight ) GUICtrlSetTip ( $_SearchButton, 'Search ShoutCast Stations' ) GUICtrlSetOnEvent ( $_SearchButton, '_Search' ) $_ComboBox1 = GUICtrlCreateCombo ( 'Search by', 102, 318 ) GUICtrlSetData ( $_ComboBox1, 'Top|Genre|KeyWords', '' ) GUICtrlSetOnEvent ( $_ComboBox1, '_GetTypeSearch' ) $_ComboBox2 = GUICtrlCreateCombo ( 'Select Genre', 189, 318 ) GUICtrlSetData ( $_ComboBox2, '60s|70s|80s|90s|Acid House|Acid Jazz|Alternative|Ambient|Best Of|' & _ 'Big Band|Big Beat|Black Metal|Blues|Bossa Nova|Brazilian|Britpop|Celtic|Classic Alternative|' & _ 'Classic Jazz|Classic Metal|Classic R&B|Classic Rock|Classical|Cool Jazz|Country|Dance|Dance Pop|Disco|Electro|Electronic|' & _ 'Extreme Metal|Folk Rock|French|Funk|Garage|Gospel|Grunge|Hair Metal|Hard Rock|Heavy Metal|House|Jazz|Piano|' & _ 'Pop|Punk|Reggae|Rock|Ska|Soft Rock|Soul|Teen Pop|Top 40|Trance', '' ) GUICtrlSetOnEvent ( $_ComboBox2, '_GetGenre' ) GUICtrlSetState ( $_ComboBox2, $GUI_HIDE ) $_InPut = GUICtrlCreateInput ( 'Type KeyWords', 189, 318 ) GUICtrlSetState ( $_InPut, $GUI_HIDE ) $_ComboBox3 = GUICtrlCreateCombo ( 'Max Results', 277, 318, 80 ) GUICtrlSetData ( $_ComboBox3, '10|20|30|40|50|60|70|80|90|100|200', '' ) GUICtrlSetOnEvent ( $_ComboBox3, '_GetMaxResults' ) GUISetBkColor ( 0x000000 ) $_Label = GUICtrlCreateLabel ( '', 390, 45, 216, 225 ) GUICtrlSetColor ( -1, 0xFFFF00 ) GUICtrlSetFont ( -1, 10, 400, 2 ) $_OldTheme = _SetThemeAppProperties ( -1 ) GUICtrlCreateGroup ( 'ShoutCast Station Infos', 379, 20, 239, 256, BitOR ( $BS_RIGHT, $BS_FLAT ) ) GUICtrlSetColor ( -1, 0xFF0000 ) GUICtrlSetFont ( -1, 10, 400, 2 ) _SetThemeAppProperties ( $_OldTheme ) $_StatusBar = _GUICtrlStatusBar_Create ( $_GUI ) $_Icons = _WinAPI_LoadShell32Icon ( 128 ) _GUICtrlStatusBar_SetIcon ( $_StatusBar, 0, $_Icons ) _GUICtrlStatusBar_SetMinHeight ( $_StatusBar, 20 ) _GUICtrlStatusBar_SetParts ( $_StatusBar, $_ArrayParts ) _GUICtrlStatusBar_SetText ( $_StatusBar, 'Waiting...', 0 ) $_Progress = GUICtrlCreateProgress ( 0, 0, -1, -1, $PBS_SMOOTH ) GUICtrlSetState ( $_Progress, $GUI_HIDE ) $_HandleProgress = GUICtrlGetHandle ( $_Progress ) $hVolSlider = GUICtrlCreateSlider ( 189, 288, 170, 20, $TBS_NOTICKS ) GUICtrlSetData ( $hVolSlider, 100 ) GUIRegisterMsg ( $WM_PAINT, '_WM_PAINT' ) GUIRegisterMsg ( $WM_NCPAINT, '_WM_PAINT' ) GUIRegisterMsg ( $WM_NOTIFY, '_WMNotify' ) _GUISetState () EndFunc ;==> _GuiCreate () Func _GUICtrlCreateListViewItems ( $_ListArray ) If $_ListView=0 Then $_ListView = GUICtrlCreateListView ( 'Radio|Name', 15, 20, 346, 259, BitOr ( $LVS_SINGLESEL, $LVS_SHOWSELALWAYS ), BitOr ( $LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES ) ) _GUICtrlListView_SetColumnWidth ( $_ListView, 1, $LVSCW_AUTOSIZE_USEHEADER ) Else _GUICtrlListView_DeleteAllItems ( GUICtrlGetHandle ( $_ListView ) ) ReDim $_ListViewItem[UBound ( $_ListArray )] EndIf For $_I = 1 To UBound ( $_ListArray ) - 1 $_ListViewItem[$_I] = GUICtrlCreateListViewItem ( StringFormat ( '%02i', $_I ) & '|' & $_ListArray[$_I], $_ListView ) Next GUICtrlSetTip ( $_ListView, 'Double click for get infos about this Station' ) $_ListViewItemMax = UBound ( $_ListArray )-1 EndFunc ;==> _GUICtrlCreateListViewItem () Func _GUISetState () GUISetState ( @SW_SHOW, $_Gui ) $_ProcessWindows = _WinAPI_EnumProcessWindows ( @AutoItPID ) For $_I = 1 To UBound ( $_ProcessWindows ) -1 If $_ProcessWindows[$_I][1] = '#32770' Then WinKill ( $_ProcessWindows[$_I][0] ) ExitLoop EndIf Next EndFunc ;==> _GUISetState () Func _InitBuilder ( ByRef $oGraphBuilder, ByRef $oMediaControl, ByRef $oBasicAudio ) Local $sCLSID_FilterGraph = '{E436EBB3-524F-11CE-9F53-0020AF0BA770}' Local $sIID_IGraphBuilder = '{56A868A9-0AD4-11CE-B03A-0020AF0BA770}' Local $tIID_IMediaControl = _AutoItObject_CLSIDFromString ( '{56A868B1-0AD4-11CE-B03A-0020AF0BA770}' ) Local $tIID_IBasicAudio = _AutoItObject_CLSIDFromString ( '{56A868B3-0AD4-11CE-B03A-0020AF0BA770}' ) Local $dtagIGraphBuilder = $dtagIUnknown & _ "AddFilter hresult(ptr;wstr);" & _ "RemoveFilter hresult(ptr);" & _ "EnumFilters hresult(ptr*);" & _ "FindFilterByName hresult(wstr;ptr*);" & _ "ConnectDirect hresult(ptr;ptr;ptr);" & _ "Reconnect hresult(ptr);" & _ "Disconnect hresult(ptr);" & _ "SetDefaultSyncSource hresult();" & _ "Connect hresult(ptr;ptr);" & _ "Render hresult(ptr);" & _ "RenderFile hresult(wstr;ptr);" & _ "AddSourceFilter hresult(wstr;wstr;ptr*);" & _ "SetLogFile hresult(dword_ptr);" & _ "Abort hresult();" & _ "ShouldOperationContinue hresult();" $oGraphBuilder = _AutoItObject_ObjCreate ( $sCLSID_FilterGraph, $sIID_IGraphBuilder, $dtagIGraphBuilder ) If @error Then Return SetError ( 1, 0, False ) Local $aCall = $oGraphBuilder.QueryInterface ( Number ( DllStructGetPtr ( $tIID_IMediaControl ) ), 0 ) If IsArray ( $aCall ) And $aCall[2] Then $oMediaControl = _AutoItObject_PtrToIDispatch ( $aCall[2] ) Else Return SetError ( 2, 0, False ) EndIf Local $pBasicAudio $aCall = $oGraphBuilder.QueryInterface ( Number ( DllStructGetPtr ( $tIID_IBasicAudio ) ), 0 ) If IsArray ( $aCall ) And $aCall[2] Then $pBasicAudio = $aCall[2] Else Return SetError ( 3, 0, False ) EndIf Local $dtagIBasicAudio = $dtagIDispatch & _ "put_Volume hresult(long);" & _ "get_Volume hresult(long*);" & _ "put_Balance hresult(long);" & _ "get_Balance hresult(long*);" $oBasicAudio = _AutoItObject_WrapperCreate ( $pBasicAudio, $dtagIBasicAudio ) If @error Then Return SetError ( 4, 0, False ) Return True EndFunc ;==> _InitBuilder () Func _IsConnected () If Ping ( 'www.bing.com', 1 ) _ Or InetRead ( 'http://www.google.com/humans.txt', 19 ) Then Return True EndFunc ;==> _IsConnected () Func _IsStationUrlReachable ( $_StationUrl ) Local $_Split = StringSplit ( $_StationUrl, ':' ) If Not @error Then Return Ping ( StringReplace ( $_Split[2], '//', '' ), 5000 ) <> 0 EndFunc ;==> _IsStationUrlReachable () Func _IsTrayItemChecked ( $_TrayItem ) Return BitAND ( TrayItemGetState ( $_TrayItem ), $TRAY_CHECKED ) EndFunc ;==> _IsTrayItemChecked () Func _LookForUpdate () Local $__LastVersion, $_UpdateDatText, $_VersionCompare $_UpdateDatText = BinaryToString ( InetRead ( 'http://tinyurl.com/cpey6v8/update.ini' ) ) $__LastVersion = _ReadIni ( $_UpdateDatText ) ConsoleWrite ( @ScriptLineNumber & ' $__LastVersion : ' & $__LastVersion & @Crlf ) Local $_ScriptVersion = _GetScriptVersion () If $_ScriptVersion <> '0.0.0.0' And $__LastVersion <> '0.0.0.0' Then $_VersionCompare = _VersionCompare ( $__LastVersion, $_ScriptVersion ) Switch $_VersionCompare Case 0 Return Case 1 If MsgBox ( 262144+4+4096+64, 'Info', @CRLF & 'An Update is Available' & @CRLF & @CRLF & _ 'TinyShoutCastTuner Version : ' & $__LastVersion & @CRLF & @CRLF & _ 'Do you want to Download it ?' & @CRLF ) = 6 Then Exit _OpenInDefaultBrowser ( $_UpdateLink ) EndSwitch EndIf EndFunc ;==> _LookForUpdate () Func _OnAutoItExit () GuiDelete ( $_Gui ) _AutoItObject_Shutdown () DllCall ( $_Dll, 'int:cdecl', 'DeInitDecoration' ) DllCall ( $_Dll, 'int:cdecl', 'RemoveSkin' ) DllClose ( $_Dll ) EndFunc ;==> _OnAutoItExit () Func _OpenInDefaultBrowser ( $_Url ) Local $_DefaultBrowser = _GetDefaultBrowser () If FileExists ( $_DefaultBrowser ) Then ShellExecute ( $_Url ) Else ShellExecute ( 'iexplore.exe', $_Url ) EndIf EndFunc ;==> _OpenInDefaultBrowser () Func _OpenShoutcast () TrayItemSetState ( $_ShoutcastItem , $TRAY_UNCHECKED ) ShellExecute ( 'http://www.shoutcast.com/' ) EndFunc ;==> _OpenShoutcast () Func _Play () If _IsStationUrlReachable ( $sMediaFile2 ) Then If $iPlaying Then If IsObj ( $oMediaControl ) Then $oMediaControl.Pause () GUICtrlSetData ( $_PlayButton, 'Play' ) $iPlaying = 0 Else If $sMediaFile2Old <> '' And $sMediaFile2 <> $sMediaFile2Old Then $sMediaFile2=$sMediaFile2Old If $_ShowFavorites=0 Then $_DisplayName = $_ArrayName[$_DoubleClick] Else $_DisplayName = $_FavoritesArrayName[$_SimpleClick] EndIf If $sMediaFile2=$sMediaFile2Old Then $_DisplayName=$_DisplayNameOld $_DisplayNameOld=$_DisplayName _GUICtrlStatusBar_SetText ( $_StatusBar, 'Trying to Connect', 0 ) $sMediaFile= $sMediaFile2 $sMediaFile3 = $sMediaFile AdlibRegister ( '_DisplayCurrentSong', 4000 ) $sMediaFile2Old=$sMediaFile2 $_LastStationUrl=$sMediaFile2Old If IsObj ( $oMediaControl ) Then $oMediaControl.Run () If @error <> 0 Then _Stop () $_LastStationUrl = '' $_DisplayName = '' EndIf GUICtrlSetData ( $_PlayButton, 'Pause' ) $iPlaying = 1 EndIf GUICtrlSetTip ( $_PlayButton, StringStripWS ( StringLeft ( GUICtrlRead ( $_PlayButton ), 5 ), 7 ) & ' Selected ShoutCast Station' ) Else _GUICtrlStatusBar_SetText ( $_StatusBar, 'Station is not Reachable !', 0 ) EndIf EndFunc ;==> _Play () Func _PlayLastListenedStation () Local $_RegReadLastStation = RegRead ( $_RegKey1 & '\LastListenedStation', '' ) If $_RegReadLastStation <> '' Then Local $_StringSplit = StringSplit ( $_RegReadLastStation, '|' ) If Not @error Then $sMediaFile2 = $_StringSplit[1] $_DisplayName2 = $_StringSplit[2] _Play () $_StringSplit = StringSplit ( StringReplace ( $_StringSplit[1], 'http://', '' ), ':' ) $_Result = _GetShoutcastRadioInfos ( $_StringSplit[1], $_StringSplit[2], 3000 ) If IsArray ( $_Result ) Then $_Msg = 'Stream Title : ' & $_Result[1] & @CRLF & _ 'Content Type : ' & $_Result[4] & @CRLF & _ 'Bitrate : ' & $_Result[5] & @CRLF & _ 'Stream Genre : ' & $_Result[2] & @CRLF & _ 'Stream URL : ' & $_Result[3] & @CRLF & _ 'Current Song : ' & $_Result[6] & @CRLF GUICtrlSetData ( $_Label, $_Msg ) ClipPut ( $_Result[3] ) Else GUICtrlSetData ( $_Label, 'No Infos Found !' ) EndIf EndIf Else $sMediaFile2 = 'http://174.37.110.72:5090' $_DisplayName2 = 'Big R Radio - 100.5 Classic Rock' If _IsStationUrlReachable ( $sMediaFile2 ) Then _Play () EndIf EndFunc ;==> _PlayLastListenedStation () Func _ReadIni ( $_Ini ) ; Get last version and download link. Local $__LastVersion $_UpdateLink = _StringBetween ( $_Ini, 'UpdateLink=', @CR ) If Not @error Then $_UpdateLink = $_UpdateLink[0] $__LastVersion = _StringBetween ( $_Ini, 'version=', @CR ) If Not @error Then Return $__LastVersion[0] Return '0.0.0.0' EndFunc ;=> _ReadIni () Func _ReleaseBuilder ( ByRef $oGraphBuilder, ByRef $oMediaControl, ByRef $oBasicAudio ) If IsObj ( $oMediaControl ) Then $oMediaControl.Stop () $oBasicAudio = 0 $oMediaControl = 0 If IsObj ( $oGraphBuilder ) Then $oGraphBuilder.Release () $oGraphBuilder = 0 EndFunc ;==> _ReleaseBuilder () Func _ReMoveFromFavorites () If $_ShowFavorites=0 Then Return ;_GetFavorites () For $_J = 1 To 1000 $_Value = RegEnumVal ( $_RegKey1 & '\Favorites', $_J ) If @error <> 0 Then ExitLoop $_RegRead = RegRead ( $_RegKey1 & '\Favorites', $_Value ) $_StringSplit = StringSplit ( $_RegRead, '|' ) If _AlreadyInArray ( $_FavoritesArrayUrl, $_StringSplit[1], 0, 1 ) Then RegDelete ( $_RegKey1 & '\Favorites', StringFormat ( '%03i', $_SimpleClick ) ) $_RemovedStation = $_FavoritesArrayName[$_SimpleClick] _GetFavorites () _GUICtrlCreateListViewItems ( $_FavoritesArrayName ) $_StringLen=StringLen ( $_RemovedStation ) MsgBox ( 262144, 'Success', $_RemovedStation & @Crlf & @Crlf & _StringRepeat ( ' ', Round ( ( $_StringLen-31 )/1.4 ) ) & 'has been removed from Favorites', 2, $_GUI ) ExitLoop EndIf Next EndFunc ;==> _ReMoveFromFavorites () Func _RenderFile ( ByRef $sMediaFile ) _ReleaseBuilder ( $oGraphBuilder, $oMediaControl, $oBasicAudio ) _InitBuilder ( $oGraphBuilder, $oMediaControl, $oBasicAudio ) If Not _WMAsfReaderLoad ( $sMediaFile ) Then $oUSER32DLL.MessageBeep ( 'int', 'dword', 48 ) $sMediaFile = '' Return SetError ( 1, 0, False ) EndIf If IsObj ( $oMediaControl ) Then $oMediaControl.Run () If @error <> 0 Then _Stop () _GUICtrlStatusBar_SetText ( $_StatusBar, 'Streaming failed', 0 ) $iPlaying = 0 $sMediaFile2Old='' $_LastStationUrl = '' $_DisplayName = '' Else _GUICtrlStatusBar_SetText ( $_StatusBar, 'Connected', 0 ) If $_DisplayName = '' Then $_DisplayName = $_DisplayName2 _GUICtrlStatusBar_SetText ( $_StatusBar, StringLeft ( $_DisplayName, 30 ), 2 ) EndIf $sMediaFile = '' Return True EndFunc ;==> _RenderFile () Func _Search () If $_TypeSearch ='' Then Return AdlibUnRegister ( '_DisplayCurrentSong' ) GUICtrlSetState ( $_ReMovFavButton, $GUI_DISABLE ) GUICtrlSetData ( $_ShowFavButton, 'Show Favorites list' ) GUICtrlSetState ( $_ShowFavButton, $GUI_DISABLE ) GUICtrlSetState ( $_AddFavButton, $GUI_DISABLE ) $_ShowFavorites=0 _GetMaxResults () $_Url='' Select Case $_TypeSearch = 'Top' $_Url = 'http://api.shoutcast.com/legacy/Top500?k=' & $_DevIdkey & $_MaxResults Case $_TypeSearch = 'Genre' $_Url = 'http://api.shoutcast.com/legacy/genresearch?k=' & $_DevIdkey & $_Genre & $_MaxResults Case $_TypeSearch = 'KeyWords' _GetKeyWords () $_Url = 'http://api.shoutcast.com/legacy/stationsearch?k=' & $_DevIdkey & $_KeyWords & $_MaxResults Case Else AdlibRegister ( '_DisplayCurrentSong', 4000 ) Return EndSelect GUICtrlSetState ( $_SearchButton, $GUI_DISABLE ) _GUICtrlStatusBar_SetText ( $_StatusBar, 'Searching...', 0 ) $_K=0 Local $_SourceCode Do $_SourceCode = _GetSourceCode ( $_Url ) If StringInStr ( $_SourceCode, 'Invalid parameter k' ) Then MsgBox ( 262144+4096, 'Error', 'You can not use The ShoutCast Search :' & @CRLF & @CRLF & 'The Dev Id key : ' & $_DevIdkey & @CRLF & 'is no longer Valid !' & @CRLF, 5, $_GUI ) AdlibRegister ( '_DisplayCurrentSong', 4000 ) Return EndIf $_ArraySource = _StringBetween ( $_SourceCode, 'station name="', ' /><' ) If @Error Then $_K+=1 If $_K=5 Then Redim $_ArrayName[2] $_ArrayName[1]='Nothing Found !' _GUICtrlCreateListViewItems ( $_ArrayName ) If Not $iPlaying Then _GUICtrlStatusBar_SetText ( $_StatusBar, 'Waiting', 0 ) Else _GUICtrlStatusBar_SetText ( $_StatusBar, 'Connected', 0 ) EndIf GUICtrlSetState ( $_SearchButton, $GUI_ENABLE ) GUICtrlSetState ( $_AddFavButton, $GUI_ENABLE ) AdlibRegister ( '_DisplayCurrentSong', 4000 ) Return EndIf EndIf Sleep ( 500 ) Until IsArray ( $_ArraySource ) GUICtrlSetData ( $_Progress, 1 ) GUICtrlSetState ( $_Progress, $GUI_SHOW ) ReDim $_ArrayId[1], $_ArrayName[1], $_ArrayGenre[1], $_ArrayUrl[1], $_ArrayListenerPeak[1], $_ArrayContentType[1], $_ArrayCurrentSong[1], $_ArrayBitrate[1] $_K=0 Local $_StationUrl, $_StationName, $_StationListenerPeak, $_StationContentType, $_StationBitrate, $_StationGenre _GUICtrlStatusBar_EmbedControl ( $_StatusBar, 1, $_HandleProgress ) For $_I = 0 To UBound ( $_ArraySource ) -1 $_StationName = _GetStationName ( $_ArraySource[$_I] ) $_StationId = _GetStationId ( $_ArraySource[$_I] ) $_StationGenre = _GetStationGenre ( $_ArraySource[$_I] ) $_StationListenerPeak = _GetStationListenerPeak ( $_ArraySource[$_I] ) $_StationContentType = _GetStationContentType ( $_ArraySource[$_I] ) $_StationBitrate = _GetStationBitrate ( $_ArraySource[$_I] ) $_StationUrl = _GetStationUrlById ( $_StationId, $_DevIdkey ) If $_StationName And $_StationUrl And $_StationId Then $_K+=1 ConsoleWrite ( '+->-- ' & StringFormat ( '%03i', $_K ) & ' StationName : ' & $_StationName & @Crlf ) ConsoleWrite ( '>->-- Station Url : ' & $_StationUrl & @Crlf ) _ArrayAdd ( $_ArrayName, $_StationName ) _ArrayAdd ( $_ArrayUrl, $_StationUrl ) _ArrayAdd ( $_ArrayId, $_StationId ) _ArrayAdd ( $_ArrayGenre, $_StationGenre ) _ArrayAdd ( $_ArrayListenerPeak, $_StationListenerPeak ) _ArrayAdd ( $_ArrayContentType, $_StationContentType ) _ArrayAdd ( $_ArrayBitrate, $_StationBitrate ) EndIf GUICtrlSetData ( $_Progress, ( $_I / ( UBound ( $_ArraySource ) -1 ) ) *100 ) Next GUICtrlSetData ( $_Progress, 100 ) _GUICtrlCreateListViewItems ( $_ArrayName ) Sleep ( 500 ) GUICtrlSetState ( $_Progress, $GUI_HIDE ) GUICtrlSetState ( $_SearchButton, $GUI_ENABLE ) GUICtrlSetState ( $_AddFavButton, $GUI_ENABLE ) GUICtrlSetState ( $_ShowFavButton, $GUI_ENABLE ) If Not $iPlaying Then _GUICtrlStatusBar_SetText ( $_StatusBar, 'Waiting', 0 ) Else _GUICtrlStatusBar_SetText ( $_StatusBar, 'Connected', 0 ) EndIf AdlibRegister ( '_DisplayCurrentSong', 4000 ) EndFunc ;==> _Search () Func _SetThemeAppProperties ( $iTheme = -1 ) If Not StringInStr ( @OSTYPE, 'WIN32_NT' ) Then Return Switch $iTheme Case -1 Local $aOld_ThemeAppProperties = DllCall ( 'Uxtheme.dll', 'int', 'GetThemeAppProperties' ) DllCall ( 'Uxtheme.dll', 'none', 'SetThemeAppProperties', 'int', 0 ) Return $aOld_ThemeAppProperties[0] Case Else DllCall ( 'Uxtheme.dll', 'none', 'SetThemeAppProperties', 'int', $iTheme ) EndSwitch EndFunc ;==> _SetThemeAppProperties () Func _ShowFavorites () If GUICtrlRead ( $_ShowFavButton ) = 'Show Favorites list' Then GUICtrlSetState ( $_ReMovFavButton, $GUI_ENABLE ) GUICtrlSetState ( $_AddFavButton, $GUI_DISABLE ) GUICtrlSetData ( $_ShowFavButton, 'Hide Favorites list' ) _GetFavorites () _GUICtrlCreateListViewItems ( $_FavoritesArrayName ) $_ShowFavorites=1 Else GUICtrlSetState ( $_ReMovFavButton, $GUI_DISABLE ) GUICtrlSetState ( $_AddFavButton, $GUI_ENABLE ) GUICtrlSetData ( $_ShowFavButton, 'Show Favorites list' ) _GUICtrlCreateListViewItems ( $_ArrayName ) $_ShowFavorites=0 EndIf EndFunc ;==> _ShowFavorites () Func _ShowInfos ( $_Choice ) Local $_Ip, $_Msg, $_Port $_Ip = _StringBetween ( $_ArrayUrl[$_Choice], 'http://', ':' ) $_Port = _StringBetween ( StringReplace ( $_ArrayUrl[$_Choice], 'http://', '' ), ':', '' ) $_Msg = 'Stream Title : ' & $_ArrayName[$_Choice] & @CRLF & _ 'Id : ' & $_ArrayId[$_Choice] & @CRLF & _ 'Listener Peak : ' & $_ArrayListenerPeak[$_Choice] & @CRLF & _ 'Content Type : ' & $_ArrayContentType[$_Choice] & @CRLF & _ 'Bitrate : ' & $_ArrayBitrate[$_Choice] & @CRLF & _ 'Stream Genre : ' & $_ArrayGenre[$_Choice] & @CRLF & _ 'Stream URL : ' & $_ArrayUrl[$_Choice] & @CRLF & _ 'Current Song : ' & _GetCurrentSong ( $_Ip[0], $_Port[0], 2000 ) & @CRLF GUICtrlSetData ( $_Label, $_Msg ) ClipPut ( $_ArrayUrl[$_Choice] ) EndFunc ;==> _ShowInfos () Func _SkinGui ( $_Hwnd, $_SkinDllPath, $_SkinFilePath ) $_Dll = DllOpen ( $_SkinDllPath ) DllCall ( $_Dll, 'int:cdecl', 'InitLicenKeys', 'wstr', 'SKINCRAFTER', 'wstr', 'SKINCRAFTER.COM', 'wstr', 'support@skincrafter.com', 'wstr', 'DEMOSKINCRAFTERLICENCE' ) DllCall ( $_Dll, 'int:cdecl', 'InitDecoration', 'int', 1 ) DllCall ( $_Dll, 'int:cdecl', 'LoadSkinFromFile', 'wstr', $_SkinFilePath ) DllCall ( $_Dll, 'int:cdecl', 'DecorateAs', 'int', $_Hwnd, 'int', 25 ) DllCall ( $_Dll, 'int:cdecl', 'ApplySkin' ) EndFunc ;==> _SkinGui () Func _StartWithWindows () If @Compiled Then $_ItemGetState = TrayItemGetState ( $_StartItem ) If $_ItemGetState = 64+1 Then RegWrite ( $_RegKey2, $_TitleKey, 'REG_SZ', @ScriptFullPath ) Else RegDelete ( $_RegKey2, $_TitleKey ) EndIf EndIf EndFunc ;==> _StartWithWindows () Func _Stop () AdlibUnRegister ( '_DisplayCurrentSong' ) If IsObj ( $oMediaControl ) Then $oMediaControl.stop () GUICtrlSetData ( $_PlayButton, 'Play' ) GUICtrlSetTip ( $_PlayButton, 'Play Selected ShoutCast Station' ) _ReleaseBuilder ( $oGraphBuilder, $oMediaControl, $oBasicAudio ) $sMediaFile='' $sMediaFile2Old='' $iPlaying = 0 _GUICtrlStatusBar_SetText ( $_StatusBar, 'Not Connected', 0 ) _GUICtrlStatusBar_SetText ( $_StatusBar, '', 1 ) EndFunc ;==> _Stop () Func _Terminate () _ReleaseBuilder ( $oGraphBuilder, $oMediaControl, $oBasicAudio ) $oAudioMeterInformation = 0 If $_LastStationUrl <> '' And $_DisplayName <> '' Then RegWrite ( $_RegKey1 & '\LastListenedStation', '', 'REG_SZ', $_LastStationUrl & '|' & $_DisplayName ) Exit EndFunc ;==> _Terminate () Func _TrayMenu () TraySetIcon ( @WindowsDir & '\shoutcast.ico' ) TraySetToolTip ( 'TinyShoutCastTuner' & @Crlf & '- LeftClick to Set Window On Top' & @Crlf & '- RightClick to TrayMenu' ) TraySetOnEvent ( $TRAY_EVENT_PRIMARYUP, '_WinSetOnTopOneTime' ) $_StartItem = TrayCreateItem ( 'Start With Windows' ) $_RegRead = RegRead ( $_RegKey2, $_TitleKey ) If $_RegRead <> '' Then TrayItemSetState ( $_StartItem, $TRAY_CHECKED ) TrayItemSetOnEvent ( $_StartItem, '_StartWithWindows' ) TrayCreateItem ( '' ) $_UpdateItem = TrayCreateItem ( 'Enable Check for Updates at Start' ) TrayItemSetOnEvent ( -1, '_EnableCheckForUpdates' ) $_RegRead = RegRead ( $_RegKeySettings, 'EnableCheckForUpdates' ) If $_RegRead = '' Or $_RegRead = 1 Then $_EnableCheckForUpdates = 1 TrayItemSetState ( $_UpdateItem, $TRAY_CHECKED ) _EnableCheckForUpdates () Else $_EnableCheckForUpdates = 0 TrayItemSetState ( $_UpdateItem, $TRAY_UNCHECKED ) EndIf TrayCreateItem ( '' ) $_AboutItem = TrayCreateItem ( 'About' ) TrayItemSetOnEvent ( $_AboutItem, '_About' ) TrayCreateItem ( '' ) $_ShoutcastItem = TrayCreateItem ( 'Open Shoutcast.com' ) TrayItemSetOnEvent ( $_ShoutcastItem, '_OpenShoutcast' ) TrayCreateItem ( '' ) $_AddRadioToFavoritesItem = TrayCreateItem ( 'Add Manually Radio to Favorites' ) TrayItemSetOnEvent ( $_AddRadioToFavoritesItem, '_AddManuallyRadioToFavorites' ) TrayCreateItem ( '' ) $_ExitItem = TrayCreateItem ( 'Exit' ) TrayItemSetOnEvent ( $_ExitItem, '_Terminate' ) TraySetClick ( 16 ) TraySetState ( 4 ) EndFunc ;==> _TrayMenu () Func _WinSetOnTopOneTime () WinWait ( $_Gui, '', 2 ) WinSetOnTop ( $_Gui, '', 1 ) Sleep ( 250 ) WinSetOnTop ( $_Gui, '', 0 ) WinActivate ( $_Gui, '' ) EndFunc ;==> _WinSetOnTopOneTime () Func _WM_PAINT ( $hWnd, $Msg, $wParam, $lParam ) Switch $hWnd Case $_Gui _WinAPI_RedrawWindow ( $_Gui, 0, 0, $RDW_UPDATENOW ) $_value = _GUICtrlListView_RedrawItems ( $_ListView, 0, _GUICtrlListView_GetItemCount ( $_ListView )-1 ) _WinAPI_RedrawWindow ( $_Gui, 0, 0, $RDW_VALIDATE ) EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==> _WM_PAINT () Func _WMAsfReaderLoad ( $sFile ) Local Const $sCLSID_WMAsfReader = "{187463A0-5BB7-11d3-ACBE-0080C75E246E}" Local Const $sIID_IBaseFilter = "{56a86895-0ad4-11ce-b03a-0020af0ba770}" Local $dtagIBaseFilter = $dtagIUnknown & _ "GetClassID hresult(ptr*);" & _ "Stop hresult();" & _ "Pause hresult();" & _ "Run hresult(int64);" & _ "GetState hresult(dword;dword*);" & _ "SetSyncSource hresult(ptr);" & _ "GetSyncSource hresult(ptr*);" & _ "EnumPins hresult(ptr*);" & _ "FindPin hresult(wstr;ptr*);" & _ "QueryFilterInfo hresult(ptr*);" & _ "JoinFilterGraph hresult(ptr;wstr);" & _ "QueryVendorInfo hresult(wstr*);" Local $oBaseFilter = _AutoItObject_ObjCreate ( $sCLSID_WMAsfReader, $sIID_IBaseFilter, $dtagIBaseFilter ) If @error Then Return SetError ( 1, 0, False ) $oGraphBuilder.AddFilter ( $oBaseFilter.__ptr__, "anything" ) Local Const $sIID_IFileSourceFilter = "{56a868a6-0ad4-11ce-b03a-0020af0ba770}" Local $dtagIFileSourceFilter = $dtagIUnknown & _ "Load hresult(wstr;ptr);" & _ "GetCurFile hresult(ptr*;ptr);" Local $tIID_IFileSourceFilter = _AutoItObject_CLSIDFromString ( $sIID_IFileSourceFilter ) Local $aCall = $oBaseFilter.QueryInterface ( Number ( DllStructGetPtr ( $tIID_IFileSourceFilter ) ), 0 ) If Not IsArray ( $aCall ) Then Return SetError ( 2, 0, False ) Local $oFileSourceFilter = _AutoItObject_WrapperCreate ( $aCall[2], $dtagIFileSourceFilter ) $oFileSourceFilter.Load ( $sFile, 0 ) $aCall = $oFileSourceFilter.GetCurFile ( 0, 0 ) Local $pFile = $aCall[1] DllStructGetData ( DllStructCreate ( "wchar[" & __Au3Obj_PtrStringLen ( $pFile ) + 1 & "]", $pFile ), 1 ) __Au3Obj_CoTaskMemFree ( $pFile ) $aCall = $oBaseFilter.EnumPins ( 0 ) If Not IsArray ( $aCall ) Or Not $aCall[1] Then Return SetError ( 3, 0, False ) Local $pEnum = $aCall[1] Local $dtagIEnumPins = $dtagIUnknown & _ "Next hresult(dword;ptr*;dword*);" & _ "Skip hresult(dword);" & _ "Reset hresult();" & _ "Clone hresult(ptr*);" Local $oEnum = _AutoItObject_WrapperCreate ( $pEnum, $dtagIEnumPins ) Local $pPin While 1 $aCall = $oEnum.Next ( 1, 0, 0 ) If Not IsArray ( $aCall ) Then Return SetError ( 4, 0, False ) $pPin = $aCall[2] If $pPin Then $oGraphBuilder.Render ( $pPin ) _AutoItObject_IUnknownRelease ( $pPin ) EndIf If $aCall[0] Then ExitLoop WEnd Return True EndFunc ;==> _WMAsfReaderLoad () Func _WMNotify ( $hWnd, $hMsg, $hWParam, $hLParam ) Local $_Code, $_Index $_Code = DllStructGetData ( DllStructCreate ( $tagNMTVDISPINFO, $hLParam ), 'Code' ) $_Index = _GUICtrlListView_GetSelectedIndices ( $_ListView ) If $_Code = $NM_DBLCLK And StringLen ( $_Index ) <> 0 Then $_DoubleClick = _GUICtrlListView_GetItemText ( $_ListView, Number ( $_Index ) ) If $_ShowFavorites = 0 Then If $_DoubleClick > UBound ( $_ArrayUrl ) -1 Then Return _ShowInfos ( $_DoubleClick ) GUICtrlSetState ( $_ListView, @SW_SHOW ) $sMediaFile2 = $_ArrayUrl[$_DoubleClick] Else If $_DoubleClick > UBound ( $_FavoritesArrayUrl ) -1 Then Return $_SearchInfos = 1 EndIf EndIf If $_Code = $NM_CLICK And StringLen ( $_Index ) <> 0 Then $_SimpleClick = _GUICtrlListView_GetItemText ( $_ListView, Number ( $_Index ) ) If $_ShowFavorites=1 Then $_DoubleClick='' If $_SimpleClick > UBound ( $_FavoritesArrayUrl ) -1 Then Return $sMediaFile2= $_FavoritesArrayUrl[$_SimpleClick] Else $_DoubleClick=$_SimpleClick If $_SimpleClick > UBound ( $_ArrayUrl ) -1 Then Return $sMediaFile2= $_ArrayUrl[$_SimpleClick] EndIf EndIf EndFunc ;==> _WMNotify ()