Jump to content

AutoIt Radio Player v0.0.0.8 Update of 30 apr 2016


Recommended Posts

AutoIt Radio Player
Last : v0.0.0.8
Tested only on W7X64

Screenshot.jpg.6f20062c096ab558c90d37d66

Changelog :

Spoiler

v0.0.0.8 - last version

v0.0.0.7 - first public version

==========>  AutoIt Radio Player v0.0.0.8.zip <==========

Personal Message :

     This is my first script posted. Any comment are welcome. Give me your best web radio i will try add them !

Install/Use :

Spoiler

-Unzip
-Run "AutoIt Radio Player.au3"
-Use MouseWheel for change volume
          Note : On first start : volume = 4%
-Use MouseLeft for drag gui
-Use RightClick for change station

Add a station :

Spoiler

How add a station :

-Go to config.ini

-Add : [Station Name]

-Possible optional label start key :
CurrentArtist
CurrentAlbum
CurrentTitle
NextArtist
NextAlbum
NextTitle
ListenersCount

-Possible optional label end key :
Link=URL
Start=StringBefore
End=StringAfter
BetweenNum=TargetOccurence (def=0)
Split=StringForSplit
NumSplit=TargetSplitNumber

-Necessary
SoundLink=URL

-Optional
CoverLink=URL
CoverLinkStart=StringBefore
CoverLinkEnd=StringAfter
CoverLinkBetweenNum=TargetOccurence (def=0)
CoverLinkBefore=PathBefore

Unsolved problem :

      When the coverGUI go outside the monitor and comeback inside, a part of current cover disapear : I have no idea how fix that
    
TODO :

     Make coverGUI mouse resizable (while script running) : any idea are welcome
     Crop some pixel of cover : any idea are welcome

Related Posts/Bin :

Main Code :

;#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7;All Warning
;-w 5 = local var declared but not used : Removed for Curl.au3
;-d = as Opt("MustDeclareVars", 1) : Removed for Bass.au3
#AutoIt3Wrapper_Au3Check_Parameters=-w 1 -w 2 -w 3 -w- 4 -w 6 -w- 7

#Region ;==> #include

    #include <Array.au3>;_ArrayAdd
    #include <GuiButton.au3>;_GUICtrlButton_SetImage()
    #include <GuiMenu.au3>;$MNS_MODELESS
    #include <GUIConstants.au3>;$WS_POPUP
    #include <GDIplus.au3>;_GDIPlus_BitmapCreateFromStream()
    #include <Memory.au3>;$GMEM_MOVEABLE
    #include <String.au3>;_StringBetween()

    #include <AutoIt Radio Player\include\Bass.au3>;_BASS_ChannelPlay()
    #include <AutoIt Radio Player\include\BassConstants.au3>;$BASS_CONFIG_NET_PLAYLIST
    #include <AutoIt Radio Player\include\Curl.au3>;Curl_Data_Get()

#EndRegion ;==> #include

#Region ;==> Func for Bass.au3

Local $MusicHandle

Func _Audio_play($MusicHandle)
    _BASS_ChannelPlay($MusicHandle, 1)
EndFunc

Func _Audio_stop($MusicHandle)
    _BASS_ChannelStop($MusicHandle)
EndFunc

Func _Audio_init_stop($MusicHandle)
    _BASS_StreamFree($MusicHandle)
    _BASS_Free()
EndFunc

Func _Audio_init_start()
    If _BASS_STARTUP(@ScriptDir & "\AutoIt Radio Player\include\bass.dll") Then
        If _BASS_Init(0, -1, 44100, 0) Then
            If _BASS_SetConfig($BASS_CONFIG_NET_PLAYLIST, 1) = 0 Then
                SetError(3)
            EndIf
        Else
            SetError(2)
        EndIf
    Else
        SetError(@error)
    EndIf
EndFunc

Func _Set_volume($volume)
    _BASS_SetConfig($BASS_CONFIG_GVOL_STREAM, $volume * 100)
EndFunc

Func _Set_url($file)
    If FileExists($file) Then
        $MusicHandle = _BASS_StreamCreateFile(False, $file, 0, 0, 0)
    Else
        $MusicHandle = _BASS_StreamCreateURL($file, 0, 1)
    EndIf
    If @error Then
        Return SetError(1)
    EndIf
    Return $MusicHandle
EndFunc

#EndRegion ;==> Func for Bass.au3

Global Const $SC_DRAGMOVE = 0xF012;Global

#Region ;==> Func from AutoIt Forum

; #FUNCTION# ====================================================================================================================
; Name...........: _ArrayMultiColSort
; Description ...: Sort 2D arrays on several columns
; Syntax.........: _ArrayMultiColSort(ByRef $aArray, $aSortData[, $iStart = 0[, $iEnd = 0]])
; Parameters ....: $aArray    - The 2D array to be sorted
;                  $aSortData - 2D array holding details of the sort format
;                               Format: [Column to be sorted, Sort order]
;                                   Sort order can be either numeric (0/1 = ascending/descending) or a ordered string of items
;                                   Any elements not matched in string are left unsorted after all sorted elements
;                  $iStart    - Element of array at which sort starts (default = 0)
;                  $iEnd      - Element of array at which sort endd (default = 0 - converted to end of array)
; Requirement(s).: v3.3.8.1 or higher
; Return values .: Success: No error
;                  Failure: @error set as follows
;                            @error = 1 with @extended set as follows (all refer to $sIn_Date):
;                                1 = Array to be sorted not 2D
;                                2 = Sort data array not 2D
;                                3 = More data rows in $aSortData than columns in $aArray
;                                4 = Start beyond end of array
;                                5 = Start beyond End
;                            @error = 2 with @extended set as follows:
;                                1 = Invalid string parameter in $aSortData
;                                2 = Invalid sort direction parameter in $aSortData
; Author ........: Melba23
; Remarks .......: Columns can be sorted in any order
; Example .......; Yes
; ===============================================================================================================================
Func _ArrayMultiColSort(ByRef $aArray, $aSortData, $iStart = 0, $iEnd = 0)

    ; Errorchecking
    ; 2D array to be sorted
    If UBound($aArray, 2) = 0 Then
        Return SetError(1, 1, "")
    EndIf
    ; 2D sort data
    If UBound($aSortData, 2) <> 2 Then
        Return SetError(1, 2, "")
    EndIf
    If UBound($aSortData) > UBound($aArray) Then
        Return SetError(1, 3)
    EndIf
    ; Start element
    If $iStart < 0 Then
        $iStart = 0
    EndIf
    If $iStart >= UBound($aArray) - 1 Then
        Return SetError(1, 4, "")
    EndIf
    ; End element
    If $iEnd <= 0 Or $iEnd >= UBound($aArray) - 1 Then
        $iEnd = UBound($aArray) - 1
    EndIf
    ; Sanity check
    If $iEnd <= $iStart Then
        Return SetError(1, 5, "")
    EndIf

    Local $iCurrCol, $iChunk_Start, $iMatchCol

    ; Sort first column
    __AMCS_SortChunk($aArray, $aSortData, 0, $aSortData[0][0], $iStart, $iEnd)
    If @error Then
        Return SetError(2, @extended, "")
    EndIf
    ; Now sort within other columns
    For $iSortData_Row = 1 To UBound($aSortData) - 1
        ; Determine column to sort
        $iCurrCol = $aSortData[$iSortData_Row][0]
        ; Create arrays to hold data from previous columns
        Local $aBaseValue[$iSortData_Row]
        ; Set base values
        For $i = 0 To $iSortData_Row - 1
            $aBaseValue[$i] = $aArray[$iStart][$aSortData[$i][0]]
        Next
        ; Set start of this chunk
        $iChunk_Start = $iStart
        ; Now work down through array
        For $iRow = $iStart + 1 To $iEnd
            ; Match each column
            For $k = 0 To $iSortData_Row - 1
                $iMatchCol = $aSortData[$k][0]
                ; See if value in each has changed
                If $aArray[$iRow][$iMatchCol] <> $aBaseValue[$k] Then
                    ; If so and row has advanced
                    If $iChunk_Start < $iRow - 1 Then
                        ; Sort this chunk
                        __AMCS_SortChunk($aArray, $aSortData, $iSortData_Row, $iCurrCol, $iChunk_Start, $iRow - 1)
                        If @error Then
                            Return SetError(2, @extended, "")
                        EndIf
                    EndIf
                    ; Set new base value
                    $aBaseValue[$k] = $aArray[$iRow][$iMatchCol]
                    ; Set new chunk start
                    $iChunk_Start = $iRow
                EndIf
            Next
        Next
        ; Sort final section
        If $iChunk_Start < $iRow - 1 Then
            __AMCS_SortChunk($aArray, $aSortData, $iSortData_Row, $iCurrCol, $iChunk_Start, $iRow - 1)
            If @error Then
                Return SetError(2, @extended, "")
            EndIf
        EndIf
    Next

EndFunc   ;==>_ArrayMultiColSort

; #FUNCTION# ====================================================================================================================
; Name...........: __AMCS_SortChunk
; Description ...: Sorts array section
; Author ........: Melba23
; Remarks .......:
; ===============================================================================================================================
Func __AMCS_SortChunk(ByRef $aArray, $aSortData, $iRow, $iColumn, $iChunkStart, $iChunkEnd)

    Local $aSortOrder

    ; Set default sort direction
    Local $iSortDirn = 1
    ; Need to prefix elements?
    If IsString($aSortData[$iRow][1]) Then
        ; Split elements
        $aSortOrder = StringSplit($aSortData[$iRow][1], ",")
        If @error Then
            Return SetError(1, 1, "")
        EndIf
        ; Add prefix to each element
        For $i = $iChunkStart To $iChunkEnd
            For $j = 1 To $aSortOrder[0]
                If $aArray[$i][$iColumn] = $aSortOrder[$j] Then
                    $aArray[$i][$iColumn] = StringFormat("%02i-", $j) & $aArray[$i][$iColumn]
                    ExitLoop
                EndIf
            Next
            ; Deal with anything that does not match
            If $j > $aSortOrder[0] Then
                $aArray[$i][$iColumn] = StringFormat("%02i-", $j) & $aArray[$i][$iColumn]
            EndIf
        Next
    Else
        Switch $aSortData[$iRow][1]
            Case 0, 1
                ; Set required sort direction if no list
                If $aSortData[$iRow][1] Then
                    $iSortDirn = -1
                Else
                    $iSortDirn = 1
                EndIf
            Case Else
                Return SetError(1, 2, "")
        EndSwitch
    EndIf

    ; Sort the chunk
    Local $iSubMax = UBound($aArray, 2) - 1
    __ArrayQuickSort2D($aArray, $iSortDirn, $iChunkStart, $iChunkEnd, $iColumn, $iSubMax)

    ; Remove any prefixes
    If IsString($aSortData[$iRow][1]) Then
        For $i = $iChunkStart To $iChunkEnd
            $aArray[$i][$iColumn] = StringTrimLeft($aArray[$i][$iColumn], 3)
        Next
    EndIf

EndFunc   ;==>__AMCS_SortChunk

Func _ReduceMemory()
    Local $aReturn = DllCall("psapi.dll", "int", "EmptyWorkingSet", "long", -1)
    If @error = 1 Then
        Return SetError(1, 0, 0)
    EndIf
    Return $aReturn[0]
EndFunc   ;==>_ReduceMemory

; #FUNCTION# ====================================================================================================================
; Name...........: _GDIPlus_ImageLoadFromHGlobal
; Description ...: Creates an Image object based on movable HGlobal memory block
; Syntax.........: _GDIPlus_ImageLoadFromHGlobal($hGlobal)
; Parameters ....: $hGlobal - Handle of a movable HGlobal memory block
; Return values .: Success    - Pointer to a new Image object
;                 Failure     - 0 and either:
;                 |@error and @extended are set if DllCall failed:
;                 | -@error = 1 if could not create IStream
;                 | -@error = 2 if DLLCall to create image failed
;                 |$GDIP_STATUS contains a non zero value specifying the error code
; Author ........: ProgAndy
; Modified.......:
; Remarks .......: After you are done with the object, call _GDIPlus_ImageDispose to release the object resources.
;                 The HGLOBAL will be owned by the image and freed automatically when the image is disposed.
; Related .......: _GDIPlus_ImageLoadFromStream, _GDIPlus_ImageDispose
; Link ..........:
; Example .......:
; ===============================================================================================================================
Func _GDIPlus_ImageLoadFromHGlobal($hGlobal)
    Local $aResult = DllCall("ole32.dll", "int", "CreateStreamOnHGlobal", "handle", $hGlobal, "bool", True, "ptr*", 0)
    If @error Or $aResult[0] <> 0 Or $aResult[3] = 0 Then Return SetError(1, @error, 0)
    Local $hImage = DllCall($__g_hGDIPDll, "uint", "GdipLoadImageFromStream", "ptr", $aResult[3], "int*", 0)
    Local $error = @error
    Local $tVARIANT = DllStructCreate("word vt;word r1;word r2;word r3;ptr data; ptr")
    Local $aCall = DllCall("oleaut32.dll", "long", "DispCallFunc", "ptr", $aResult[3], "dword", 8 + 8 * @AutoItX64, "dword", 4, "dword", 23, "dword", 0, "ptr", 0, "ptr", 0, "ptr", DllStructGetPtr($tVARIANT))
    If $error Then Return SetError(2, $error, 0)
    If $hImage[2] = 0 Then Return SetError(3, 0, $hImage[2])
    Return $hImage[2]
EndFunc   ;==>_GDIPlus_ImageLoadFromHGlobal

; #FUNCTION# ====================================================================================================================
; Name...........: _MemGlobalAllocFromBinary
; Description ...: Greates a movable HGLOBAL memory block from binary data
; Syntax.........: _MemGlobalAllocFromBinary($bBinary)
; Parameters ....: $bBinary - Binary data
; Return values .: Success    - Handle of a new movable HGLOBAL
;                 Failure     - 0 and set @error:
;                 |1  - no data
;                 |2  - could not allocate memory
;                 |3  - could not set data to memory
; Author ........: ProgAndy
; Modified.......:
; Remarks .......:
; Related .......: _MemGlobalAlloc, _MemGlobalFree, _MemGlobalLock
; Link ..........:
; Example .......:
; ===============================================================================================================================
Func _MemGlobalAllocFromBinary(Const $bBinary)
    Local $iLen = BinaryLen($bBinary)
    If $iLen = 0 Then Return SetError(1, 0, 0)
    Local $hMem = _MemGlobalAlloc($iLen, $GMEM_MOVEABLE)
    If @error Or Not $hMem Then Return SetError(2, 0, 0)
    DllStructSetData(DllStructCreate("byte[" & $iLen & "]", _MemGlobalLock($hMem)), 1, $bBinary)
    If @error Then
        _MemGlobalUnlock($hMem)
        _MemGlobalFree($hMem)
        Return SetError(3, 0, 0)
    EndIf
    _MemGlobalUnlock($hMem)
    Return $hMem
EndFunc   ;==>_MemGlobalAllocFromBinary

#EndRegion ;==> Func from AutoIt Forum

;INI Location
Local $Config_INI = "AutoIt Radio Player\Config.ini"
Local $Save_INI = "AutoIt Radio Player\Save.ini"

;Get $aRadio and $aLabel <===========================================That part need improve
Local $aINISections = IniReadSectionNames($Config_INI)
Local $aRadio[0][8]
Local $aLabel[0][11]
For $i = 1 To UBound($aINISections) - 1
    If $aINISections[$i] <> "GUI" Then

        ;For $aRadio
        Local $SoundLink = "", $CoverLink = "", $CoverLinkStart = "", $CoverLinkEnd = "", $CoverLinkBetweenNum = "", $CoverLinkBefore = "", $Default = 0

        ;For $aLabel
        Local $CurrentArtistLink = "", $CurrentArtistStart = "", $CurrentArtistEnd = "", $CurrentArtistBetweenNum = 0, $CurrentArtistSplit = "", $CurrentArtistNumSplit = ""
        Local $CurrentAlbumLink = "", $CurrentAlbumStart = "", $CurrentAlbumEnd = "", $CurrentAlbumBetweenNum = 0, $CurrentAlbumSplit = "", $CurrentAlbumNumSplit = ""
        Local $CurrentTitleLink = "", $CurrentTitleStart = "", $CurrentTitleEnd = "", $CurrentTitleBetweenNum = 0, $CurrentTitleSplit = "", $CurrentTitleNumSplit = ""
        Local $NextArtistLink = "", $NextArtistStart = "", $NextArtistEnd = "", $NextArtistBetweenNum = 0, $NextArtistSplit = "", $NextArtistNumSplit = ""
        Local $NextAlbumLink = "", $NextAlbumStart = "", $NextAlbumEnd = "", $NextAlbumBetweenNum = 0, $NextAlbumSplit = "", $NextAlbumNumSplit = ""
        Local $NextTitleLink = "", $NextTitleStart = "", $NextTitleEnd = "", $NextTitleBetweenNum = 0, $NextTitleSplit = "", $NextTitleNumSplit = ""
        Local $ListenersCountLink = "", $ListenersCountStart = "", $ListenersCountEnd = "", $ListenersCountBetweenNum = 0, $ListenersCountSplit = "", $ListenersCountNumSplit = ""
        Local $controlID1 = "", $controlID2 = ""

        Local $Sec = IniReadSection($Config_INI, $aINISections[$i])
        For $y = 1 To UBound($Sec) - 1
            Assign($Sec[$y][0], $Sec[$y][1])
        Next

        ;$aRadio
        _ArrayAdd($aRadio, $aINISections[$i] & "|" & $SoundLink & "|" & $CoverLink & "|" & $CoverLinkStart & "|" & $CoverLinkEnd & "|" & $CoverLinkBetweenNum & "|" & $CoverLinkBefore & "|" & $Default)

        ;$aLabel
        _ArrayAdd($aLabel, $aINISections[$i] & "|" & "Current" & "|" & "Artist" & "|" & $CurrentArtistLink & "|" & $CurrentArtistStart & "|" & $CurrentArtistEnd & "|" & $CurrentArtistBetweenNum & "|" & $CurrentArtistSplit & "|" & $CurrentArtistNumSplit & "|" & $controlID1 & "|" & $controlID2)
        _ArrayAdd($aLabel, $aINISections[$i] & "|" & "Current" & "|" & "Album" & "|" & $CurrentAlbumLink & "|" & $CurrentAlbumStart & "|" & $CurrentAlbumEnd & "|" & $CurrentAlbumBetweenNum & "|" & $CurrentAlbumSplit & "|" & $CurrentAlbumNumSplit & "|" & $controlID1 & "|" & $controlID2)
        _ArrayAdd($aLabel, $aINISections[$i] & "|" & "Current" & "|" & "Title" & "|" & $CurrentTitleLink & "|" & $CurrentTitleStart & "|" & $CurrentTitleEnd & "|" & $CurrentTitleBetweenNum & "|" & $CurrentTitleSplit & "|" & $CurrentTitleNumSplit & "|" & $controlID1 & "|" & $controlID2)
        _ArrayAdd($aLabel, $aINISections[$i] & "|" & "Next" & "|" & "Artist" & "|" & $NextArtistLink & "|" & $NextArtistStart & "|" & $NextArtistEnd & "|" & $NextArtistBetweenNum & "|" & $NextArtistSplit & "|" & $NextArtistNumSplit & "|" & $controlID1 & "|" & $controlID2)
        _ArrayAdd($aLabel, $aINISections[$i] & "|" & "Next" & "|" & "Album" & "|" & $NextAlbumLink & "|" & $NextAlbumStart & "|" & $NextAlbumEnd & "|" & $NextAlbumBetweenNum & "|" & $NextAlbumSplit & "|" & $NextAlbumNumSplit & "|" & $controlID1 & "|" & $controlID2)
        _ArrayAdd($aLabel, $aINISections[$i] & "|" & "Next" & "|" & "Title" & "|" & $NextTitleLink & "|" & $NextTitleStart & "|" & $NextTitleEnd & "|" & $NextTitleBetweenNum & "|" & $NextTitleSplit & "|" & $NextTitleNumSplit & "|" & $controlID1 & "|" & $controlID2)
        _ArrayAdd($aLabel, $aINISections[$i] & "|" & "Listeners" & "|" & "Count" & "|" & $ListenersCountLink & "|" & $ListenersCountStart & "|" & $ListenersCountEnd & "|" & $ListenersCountBetweenNum & "|" & $ListenersCountSplit & "|" & $ListenersCountNumSplit & "|" & $controlID1 & "|" & $controlID2)

    EndIf
Next
Global $aRadio_Sort[][] = [[0, 0], [1, 0]]
_ArrayMultiColSort($aRadio, $aRadio_Sort)
Local $aLabel2[0][11]
For $i = 0 To UBound($aLabel) - 1
    If $aLabel[$i][3] <> "" Then
        Local $fill = $aLabel[$i][0]
        For $y = 1 To UBound($aLabel, 2) - 1
            $fill = $fill & "|" & $aLabel[$i][$y]
        Next
        _ArrayAdd($aLabel2, $fill)
    EndIf
Next
$aLabel = $aLabel2
;_ArrayDisplay($aRadio)
;_ArrayDisplay($aLabel)

;Init/Opt
Opt("GUIOnEventMode", 1)
_Audio_init_start()
_GDIPlus_Startup()

;Icon
Local $IcoFile = @ScriptDir & "\AutoIt Radio Player\img\icon.ico"
Local $IcoNumber = -1
TraySetIcon($IcoFile, $IcoNumber)

;Get Default Station
Local $def_selected = 0
For $r = 0 To UBound($aRadio) - 1
    If $aRadio[$r][0] = IniRead($Save_INI, @ComputerName, "Default_Radio", "default") Then
        $def_selected = 1
        $aRadio[$r][7] = 1
    EndIf
Next
If $def_selected = 0 Then
    $aRadio[0][7] = 1
EndIf

;ConsoleWrite("Start" & @CRLF)

;Get $Radio_Name, $Radio_SoundLink, $Radio_CoverLink, $Radio_CoverLink_Start, $Radio_CoverLink_End, $Radio_CoverLink_BetweenNum, $Radio_CoverLink_Before
Local  $Radio_Name, $Radio_SoundLink, $Radio_CoverLink
Local  $Radio_CoverLink_Start, $Radio_CoverLink_End, $Radio_CoverLink_BetweenNum, $Radio_CoverLink_Before
For $r = 0 To UBound($aRadio) - 1
    If $aRadio[$r][7] = 1 Then
        $Radio_Name = $aRadio[$r][0]
        $Radio_SoundLink = $aRadio[$r][1]
        $Radio_CoverLink = $aRadio[$r][2]
        $Radio_CoverLink_Start = $aRadio[$r][3]
        $Radio_CoverLink_End = $aRadio[$r][4]
        $Radio_CoverLink_BetweenNum = $aRadio[$r][5]
        $Radio_CoverLink_Before = $aRadio[$r][6]
    EndIf
Next

;Declare
Local $PlayerGUI, $CoverGUI;GUI
Local $PlayPause, $Close;Button
Local $Play = 1;PlayStatus ($Play = 1 = Autoplay)
Local $Volume_Label, $VolumePercent, $Previous_VolumePercent;Volume
Local $Previous_Cover_Read;PreviousRead
Local $BASS_ErrorGetCode

;$Config_INI\GUI
Local $CoverSize = IniRead($Config_INI, "GUI", "CoverSize", 150)
Local $PlayerBorder = IniRead($Config_INI, "GUI", "PlayerBorder", 10)

;ConsoleWrite("Build GUI" & @CRLF)

;Build GUI
_Build_PlayerGUI()
_Build_CoverGUI()

;ConsoleWrite("Show GUI" & @CRLF)

GUISetState(@SW_SHOW, $PlayerGUI)
If $Radio_CoverLink <> "" Then
    GUISetState(@SW_SHOW, $CoverGUI)
EndIf

_Set_volume(0)

;GetPlayerDATA() - GetCoverDATA() - Start Sound
GetPlayerDATA();Start Sound too with resume on disconnect
AdlibRegister("GetPlayerDATA", 8000)
If $Radio_CoverLink <> "" Then
    GetCoverDATA()
    AdlibRegister("GetCoverDATA", 8000)
EndIf

;ConsoleWrite("GUIRegisterMsg" & @CRLF)
GUIRegisterMsg($WM_MOUSEWHEEL, "_WM_MOUSEWHEEL");for set volume
GUIRegisterMsg($WM_LBUTTONDOWN, "_WM_LBUTTONDOWN");for drag gui

#Region ;==> Internal Func

Func _Build_CoverGUI()

    ;ConsoleWrite("Build CoverGUI" & @CRLF)

    If $Radio_CoverLink <> "" Then
        $CoverGUI = GUICreate("AutoIt Radio Cover", _;Title
                $CoverSize, _ ;X
                $CoverSize, _ ;Y
                IniRead($Save_INI, @ComputerName, "Cover_X", -1), _;Left
                IniRead($Save_INI, @ComputerName, "Cover_Y", -1), _;Top
                $WS_POPUP, $WS_EX_TOPMOST);Style
        GUISetBkColor(0x000000, $CoverGUI);Black BkColor
        GUISetIcon($IcoFile, $IcoNumber, $CoverGUI)
    Else
        $CoverGUI = ""
    EndIf

EndFunc ;==>_Build_CoverGUI

Func _Build_PlayerGUI()

    ;ConsoleWrite("Build PlayerGUI" & @CRLF)

    ;Clean previous stored ControlID
    For $r = 0 To UBound($aLabel) - 1
        $aLabel[$r][9] = ""
        $aLabel[$r][10] = ""
    Next

    ;$LabelCount
    Local $LabelCount = 0
    For $r = 0 To UBound($aLabel) - 1
        If $Radio_Name = $aLabel[$r][0] Then
            $LabelCount = $LabelCount + 1
        EndIf
    Next

    ;$LabelY
    If $LabelCount * 13 + $PlayerBorder * 2 < 50 Then
        Local $LabelY = 10 * 3
    Else
        $LabelY = $LabelCount * 13
    EndIf

    ;$PlayerGUI
    $PlayerGUI = GUICreate("AutoIt Radio Player", _
            $PlayerBorder + 260 + 50 + 10 + $PlayerBorder * 2, _;X
            $PlayerBorder + $LabelY + $PlayerBorder, _;Y
            IniRead($Save_INI, @ComputerName, "Title_X", -1), _;Left
            IniRead($Save_INI, @ComputerName, "Title_Y", -1), _;Top
            $WS_POPUP, $WS_EX_TOPMOST);Style
    GUISetBkColor(0x000000, $PlayerGUI);Black BkColor
    GUISetIcon($IcoFile, $IcoNumber, $PlayerGUI)

    ;$Contextmenu
    Local $ContextMenu = GUICtrlCreateContextMenu(-1)
    Local $hCM = GUICtrlGetHandle($ContextMenu)
    _GUICtrlMenu_SetMenuStyle($hCM, BitXOR(_GUICtrlMenu_GetMenuStyle($hCM), $MNS_MODELESS))
    Local $ContextMenu_Item1 = GUICtrlCreateMenuItem($Radio_Name, $ContextMenu)
    GUICtrlSetOnEvent($ContextMenu_Item1, "ContextMenu_ChangeRadio")
    GUICtrlCreateMenuItem("", $ContextMenu);Add separator
    For $r = 0 To UBound($aRadio) - 1
        If $aRadio[$r][7] = 0 Then
            GUICtrlCreateMenuItem($aRadio[$r][0], $ContextMenu)
            GUICtrlSetOnEvent(-1, "ContextMenu_ChangeRadio")
        EndIf
    Next

    ;GUICtrlCreateLabel
    $LabelCount = 0
    Local $Previous_Type = ""
    For $r = 0 To UBound($aLabel) - 1
        If $Radio_Name = $aLabel[$r][0] Then
            If $Previous_Type <> $aLabel[$r][1] Then
                $Previous_Type = $aLabel[$r][1]
                $aLabel[$r][10] = GUICtrlCreateLabel($aLabel[$r][1], $PlayerBorder, 13 * $LabelCount + $PlayerBorder, 50, 13, $SS_CENTERIMAGE)
                GUICtrlSetColor($aLabel[$r][10], 0xFFFFFF);White TextColor
                GUICtrlSetOnEvent($aLabel[$r][10], "_WM_LBUTTONDOWN")
                $ContextMenu = GUICtrlCreateContextMenu($aLabel[$r][10])
                $hCM = GUICtrlGetHandle($ContextMenu)
                _GUICtrlMenu_SetMenuStyle($hCM, BitXOR(_GUICtrlMenu_GetMenuStyle($hCM), $MNS_MODELESS))
                $ContextMenu_Item1 = GUICtrlCreateMenuItem($Radio_Name, $ContextMenu)
                GUICtrlSetOnEvent(-1, "ContextMenu_ChangeRadio")
                GUICtrlCreateMenuItem("", $ContextMenu);Add separator
                For $r2 = 0 To UBound($aRadio) - 1
                    If $aRadio[$r2][7] = 0 Then
                        GUICtrlCreateMenuItem($aRadio[$r2][0], $ContextMenu)
                        GUICtrlSetOnEvent(-1, "ContextMenu_ChangeRadio")
                    EndIf
                Next
            EndIf
            $aLabel[$r][9] = GUICtrlCreateLabel("", $PlayerBorder + 50, 13 * $LabelCount + $PlayerBorder, 260, 13, $SS_CENTERIMAGE)
            $LabelCount = $LabelCount + 1
            GUICtrlSetColor($aLabel[$r][9], 0xFFFFFF);White TextColor
            GUICtrlSetOnEvent($aLabel[$r][9], "_WM_LBUTTONDOWN")
            $ContextMenu = GUICtrlCreateContextMenu($aLabel[$r][9])
            $hCM = GUICtrlGetHandle($ContextMenu)
            _GUICtrlMenu_SetMenuStyle($hCM, BitXOR(_GUICtrlMenu_GetMenuStyle($hCM), $MNS_MODELESS))
            $ContextMenu_Item1 = GUICtrlCreateMenuItem($Radio_Name, $ContextMenu)
            GUICtrlSetOnEvent(-1, "ContextMenu_ChangeRadio")
            GUICtrlCreateMenuItem("", $ContextMenu);Add separator
            For $r2 = 0 To UBound($aRadio) - 1
                If $aRadio[$r2][7] = 0 Then
                    GUICtrlCreateMenuItem($aRadio[$r2][0], $ContextMenu)
                    GUICtrlSetOnEvent(-1, "ContextMenu_ChangeRadio")
                EndIf
            Next
        EndIf
    Next

    ;GUICtrlCreateLabel Volume
    $Volume_Label = GUICtrlCreateLabel("0", $PlayerBorder, $PlayerBorder, 260 + 50, $LabelY, "")
    GUICtrlSetColor($Volume_Label, 0xFFFFFF);White TextColor
    GUICtrlSetOnEvent($Volume_Label, "_WM_LBUTTONDOWN")
    GUICtrlSetState($Volume_Label, $GUI_HIDE)

    ;$Volume_Label Contextmenu
    $ContextMenu = GUICtrlCreateContextMenu($Volume_Label)
    $hCM = GUICtrlGetHandle($ContextMenu)
    _GUICtrlMenu_SetMenuStyle($hCM, BitXOR(_GUICtrlMenu_GetMenuStyle($hCM), $MNS_MODELESS))
    $ContextMenu_Item1 = GUICtrlCreateMenuItem($Radio_Name, $ContextMenu)
    GUICtrlSetOnEvent(-1, "ContextMenu_ChangeRadio")
    GUICtrlCreateMenuItem("", $ContextMenu);Add separator
    For $r = 0 To UBound($aRadio) - 1
        If $aRadio[$r][7] = 0 Then
            Local $Item = GUICtrlCreateMenuItem($aRadio[$r][0], $ContextMenu)
            GUICtrlSetOnEvent(-1, "ContextMenu_ChangeRadio")
        EndIf
    Next

    ;$Close
    $Close = GUICtrlCreateButton("Close", _
            $PlayerBorder * 2 + 260 + 50, _;Left
            $PlayerBorder, _;Top
            10, _;X
            10, _;Y
            $BS_BITMAP);Style
    _GUICtrlButton_SetImage($Close, @ScriptDir & "\AutoIt Radio Player\Img\Close.bmp")
    GUICtrlSetOnEvent($Close, "_Close")
    GUICtrlSetOnEvent($GUI_EVENT_CLOSE, "_Close")

    ;$PlayPause
    $PlayPause = GUICtrlCreateButton("Play/Pause", _
            $PlayerBorder * 2 + 260 + 50, _;Left
            $PlayerBorder + 10 + 10, _;Top
            10, _;X
            10, _;Y
            $BS_BITMAP);Style
    _GUICtrlButton_SetImage($PlayPause, @ScriptDir & "\AutoIt Radio Player\Img\Stop.bmp")
    GUICtrlSetOnEvent($PlayPause, "_PlayPause")

EndFunc ;==>_Build_PlayerGUI

Func _Close()
    _Audio_init_stop($MusicHandle)
    _GDIPlus_Shutdown()
    Exit
EndFunc ;==>_Close

Func _PlayPause()

    ;Change $Play
    If $Play = 1 Then
        $Play = 0
    Else
        $Play = 1
    EndIf

    Local $Msg = GUIGetCursorInfo($PlayerGUI)

    ;Change Button Image
    If $Play = 1 Then
        If $Msg[4] = $PlayPause Then
            If $Msg[2] = 1 Then
                _GUICtrlButton_SetImage($PlayPause, @ScriptDir & "\AutoIt Radio Player\Img\stopp.bmp");Mouse Pressed
            Else
                _GUICtrlButton_SetImage($PlayPause, @ScriptDir & "\AutoIt Radio Player\Img\stopo.bmp");Mouse Over
            EndIf
        Else
            _GUICtrlButton_SetImage($PlayPause, @ScriptDir & "\AutoIt Radio Player\Img\stop.bmp");Nothing
        EndIf
    Else
        If $Msg[4] = $PlayPause Then
            If $Msg[2] = 1 Then
                _GUICtrlButton_SetImage($PlayPause, @ScriptDir & "\AutoIt Radio Player\Img\playp.bmp");Mouse Pressed
            Else
                _GUICtrlButton_SetImage($PlayPause, @ScriptDir & "\AutoIt Radio Player\Img\playo.bmp");Mouse Over
            EndIf
        Else
            _GUICtrlButton_SetImage($PlayPause, @ScriptDir & "\AutoIt Radio Player\Img\play.bmp");Nothing
        EndIf
    EndIf

    ;Play Sound
    If $Play = 0 Then
        _Audio_stop($MusicHandle)
    Else
        $MusicHandle = _Set_url($Radio_SoundLink)
        _Audio_play($MusicHandle)
    EndIf

EndFunc ;==>_PlayPause

Func _RemoveVolumeLabel()

    AdlibUnRegister("_RemoveVolumeLabel")

    ;Show Others Label
    For $i = 0 To UBound($aLabel) - 1
        If $Radio_Name = $aLabel[$i][0] Then
            GUICtrlSetState($aLabel[$i][9], $GUI_SHOW)
        EndIf
    Next
    Local $Previous_Type = ""
    For $i = 0 To UBound($aLabel) - 1
        If $Radio_Name = $aLabel[$i][0] Then
            If $Previous_Type <> $aLabel[$i][1] Then
                $Previous_Type = $aLabel[$i][1]
                GUICtrlSetState($aLabel[$i][10], $GUI_SHOW)
            EndIf
            GUICtrlSetState($aLabel[$i][9], $GUI_SHOW)
        EndIf
    Next

    ;Hide Volume Label
    GUICtrlSetState($Volume_Label, $GUI_HIDE)

EndFunc ;==>_RemoveVolumeLabel

Func _Save_Change_Volume()

    AdlibUnRegister("_Save_Change_Volume")

    _Set_volume($VolumePercent);Set

    IniWrite($Save_INI, @ComputerName, "Volume", $VolumePercent);Save

EndFunc ;==>_Save_Change_Volume

Func _WM_LBUTTONDOWN()

    ;Move GUI
    If WinActive("AutoIt Radio Cover") Then
        _SendMessage($CoverGUI, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0)
    Else
        _SendMessage($PlayerGUI, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0)
    EndIf

    ;Save GUI pos
    Local $Player_pos = WinGetPos("AutoIt Radio Player")
    Local $Cover_pos = WinGetPos("AutoIt Radio Cover")
    IniWrite($Save_INI, @ComputerName, "Title_X", $Player_pos[0])
    IniWrite($Save_INI, @ComputerName, "Title_Y", $Player_pos[1])
    If $Radio_CoverLink <> "" Then
        IniWrite($Save_INI, @ComputerName, "Cover_X", $Cover_pos[0])
        IniWrite($Save_INI, @ComputerName, "Cover_Y", $Cover_pos[1])
    EndIf

EndFunc   ;==>_WM_LBUTTONDOWN

Func _WM_MOUSEWHEEL($hWnd, $iMsg, $wParam, $lParam)

    AdlibUnRegister("_RemoveVolumeLabel")

    If GUICtrlGetState($Volume_Label) <> 80 Then

        ;Show $Volume_Label
        GUICtrlSetState($Volume_Label, $GUI_SHOW)

        ;Hide Others Label
        Local $Previous_Type = ""
        For $i = 0 To UBound($aLabel) - 1
            If $Radio_Name = $aLabel[$r][0] Then
                If $Previous_Type <> $aLabel[$i][1] Then
                    $Previous_Type = $aLabel[$i][1]
                    GUICtrlSetState($aLabel[$i][10], $GUI_HIDE)
                EndIf
                GUICtrlSetState($aLabel[$i][9], $GUI_HIDE)
            EndIf
        Next

    EndIf

    ;Change $VolumePercent
    Local $WheelDelta = BitShift($wParam, 16) / 120
    $VolumePercent = $VolumePercent + 4 * $WheelDelta
    If $WheelDelta > 0 Then
        If $VolumePercent > 100 Then $VolumePercent = 100
    Else
        If $VolumePercent < 0 Then $VolumePercent = 0
    EndIf
    If $Previous_VolumePercent <> $VolumePercent Then
        $Previous_VolumePercent = $VolumePercent
        GUICtrlSetData($Volume_Label, $VolumePercent)
    EndIf

    ;Change\Save Sound
    AdlibRegister("_Save_Change_Volume", 50)

    ;Hide $Volume_Label in 3s
    AdlibRegister("_RemoveVolumeLabel", 3000)

    Return $GUI_RUNDEFMSG

EndFunc   ;==>_WM_MOUSEWHEEL

Func ContextMenu_ChangeRadio()

    $Previous_Cover_Read = ""

    Local $NewRadioName = GUICtrlRead(@GUI_CtrlId, 1)

    ;Maybe the next radio have no cover so delete it
    If $Radio_CoverLink <> "" Then
        GUIDelete($CoverGUI)
        AdlibUnRegister("GetCoverDATA")
    EndIf

    ;Maybe the $PlayerGUI need resize so delete it
    GUIDelete($PlayerGUI)
    AdlibUnRegister("GetPlayerDATA")

    _Audio_stop($MusicHandle)

    ;Remove Default Radio Tag
    For $r = 0 To UBound($aRadio) - 1
        $aRadio[$r][7] = 0
    Next

    ;Set $NewRadioName to Default
    For $r = 0 To UBound($aRadio) - 1
        If $aRadio[$r][0] = $NewRadioName Then
            $aRadio[$r][7] = 1
            IniWrite($Save_INI, @ComputerName, "Default_Radio", $aRadio[$r][0])
        EndIf
    Next

    ;Get $Radio_Name, $Radio_SoundLink, $Radio_CoverLink, $Radio_CoverLink_Start, $Radio_CoverLink_End, $Radio_CoverLink_BetweenNum, $Radio_CoverLink_Before
    For $r = 0 To UBound($aRadio) - 1
        If $aRadio[$r][7] = 1 Then
            $Radio_Name = $aRadio[$r][0]
            $Radio_SoundLink = $aRadio[$r][1]
            $Radio_CoverLink = $aRadio[$r][2]
            $Radio_CoverLink_Start = $aRadio[$r][3]
            $Radio_CoverLink_End = $aRadio[$r][4]
            $Radio_CoverLink_BetweenNum = $aRadio[$r][5]
            $Radio_CoverLink_Before = $aRadio[$r][6]
        EndIf
    Next

    ;ConsoleWrite("Build GUI" & @CRLF)

    ;Build GUI
    _Build_PlayerGUI()
    _Build_CoverGUI()

    ;ConsoleWrite("Show GUI" & @CRLF)

    GUISetState(@SW_SHOW, $PlayerGUI)
    If $Radio_CoverLink <> "" Then
        GUISetState(@SW_SHOW, $CoverGUI)
    EndIf

    ;GetPlayerDATA() - GetCoverDATA()
    GetPlayerDATA()
    AdlibRegister("GetPlayerDATA", 8000)
    If $Radio_CoverLink <> "" Then
        GetCoverDATA()
        AdlibRegister("GetCoverDATA", 8000)
    EndIf

EndFunc ;==>ContextMenu_ChangeRadio

Func UseCurl($Link, $Timeout, $binary = 0, $write = 0, $file = "")

    Local $Error = ""
    Local $Data = ""
    Local $Curl = Curl_Easy_Init()
    If Not $Curl Then Return

    If $write = 0 Then

        ;Read Mode

        ; How to get html or header data?
        ;   1. Set $CURLOPT_WRITEFUNCTION and $CURLOPT_HEADERFUNCTION to Curl_DataWriteCallback()
        ;   2. Set $CURLOPT_WRITEDATA or $CURLOPT_HEADERDATA to any number as identify
        ;   3. Use Curl_Data_Get() to read the returned data in binary format
        ;   4. Use Curl_Data_Cleanup() to remove the data

        Local $Html = $Curl ; any number as identify
        Local $Header = $Curl + 1 ; any number as identify

        Curl_Easy_Setopt($Curl, $CURLOPT_URL, $Link)
        Curl_Easy_Setopt($Curl, $CURLOPT_USERAGENT, 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.75.14 (KHTML, like Gecko) Version/7.0.3 Safari/7046A194A')
        Curl_Easy_Setopt($Curl, $CURLOPT_FOLLOWLOCATION, 1)
        Curl_Easy_Setopt($Curl, $CURLOPT_ACCEPT_ENCODING, "")
        Curl_Easy_Setopt($Curl, $CURLOPT_WRITEFUNCTION, Curl_DataWriteCallback())
        Curl_Easy_Setopt($Curl, $CURLOPT_WRITEDATA, $Html)
        Curl_Easy_Setopt($Curl, $CURLOPT_HEADERFUNCTION, Curl_DataWriteCallback())
        Curl_Easy_Setopt($Curl, $CURLOPT_HEADERDATA, $Header)
        Curl_Easy_Setopt($Curl, $CURLOPT_COOKIE, "tool=curl; script=autoit; fun=yes;")
        Curl_Easy_Setopt($Curl, $CURLOPT_TIMEOUT, $Timeout)
        Curl_Easy_Setopt($Curl, $CURLOPT_SSL_VERIFYPEER, 0)

        Local $Code = Curl_Easy_Perform($Curl)
        If $Code = $CURLE_OK Then
            ;ConsoleWrite("Content Type: " & Curl_Easy_GetInfo($Curl, $CURLINFO_CONTENT_TYPE) & @LF)
            ;ConsoleWrite("Download Size: " & Curl_Easy_GetInfo($Curl, $CURLINFO_SIZE_DOWNLOAD) & @LF)

            $Data = BinaryToString(Curl_Data_Get($Html))
            $Error = ""

            ;MsgBox(0, 'Header', BinaryToString(Curl_Data_Get($Header)))
            ;MsgBox(0, 'Html', BinaryToString(Curl_Data_Get($Html)))
        Else
            ;ConsoleWrite(Curl_Easy_StrError($Code) & @LF)

            $Data = ""
            $Error = Curl_Easy_StrError($Code)

        EndIf

        Curl_Easy_Cleanup($Curl)
        Curl_Data_Cleanup($Header)
        Curl_Data_Cleanup($Html)

    Else

        ;Write Mode

    EndIf

    Local  $aray[2] = [$Data,$Error]
    return $aray

EndFunc

Func GetCoverDATA()

    ;ConsoleWrite("GetCoverDATA (Start)" & @CRLF)

    ;Get $RealCoverLink
    If $Radio_CoverLink_Start = "" Then
        ;ConsoleWrite("$RealCoverLink = $Radio_CoverLink" & @CRLF)
        Local $RealCoverLink = $Radio_CoverLink
    Else
        ;ConsoleWrite("$RealCoverLink <> $Radio_CoverLink" & @CRLF)
        ;UseCurl($Link, $Timeout, $binary = 0, $write = 0, $file = "")
        Local $aray = UseCurl($Radio_CoverLink, 5)
        Local $Data = $aray[0]
        Local $Error = $aray[1]
        If $Error <> "" then
            ;ConsoleWrite("$Error = " & $Error & @CRLF)
        EndIf
        Local $Between = _StringBetween($Data, $Radio_CoverLink_Start, $Radio_CoverLink_End)
        If @error <> 0 Then
            $Between = ""
        Else
            $Between = $Between[$Radio_CoverLink_BetweenNum]
        EndIf
        $RealCoverLink = $Radio_CoverLink_Before & $Between
        $RealCoverLink = StringReplace($RealCoverLink, " ","%20")
    EndIf
    ;ConsoleWrite("$RealCoverLink = " & $RealCoverLink & @CRLF)

    ;UseCurl($Link, $Timeout, $binary = 0, $write = 0, $file = "")
    Local $Cover_Read = UseCurl($RealCoverLink, 5, 1)

    $Cover_Read = $Cover_Read[0]

    If $Cover_Read <> $Previous_Cover_Read and $Cover_Read <> "" Then

        $Previous_Cover_Read = $Cover_Read

        Local $hMem = _MemGlobalAllocFromBinary($Cover_Read)
        Local $hImage = _GDIPlus_ImageLoadFromHGlobal($hMem)
        Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($CoverGUI)
        _GDIPlus_GraphicsDrawImageRect($hGraphics, $hImage, 0, 0, $CoverSize, $CoverSize)
        _GDIPlus_GraphicsDispose($hGraphics)
        _GDIPlus_ImageDispose($hImage)

    EndIf

    ;ConsoleWrite("GetCoverDATA (End)" & @CRLF)

EndFunc ;==>GetCoverDATA()

Func GetPlayerDATA()

    _ReduceMemory()

    ;ConsoleWrite("GetPlayerDATA (Start)" & @CRLF)

    ;Assign
    Local  $Previous_Data, $Previous_DataLink
    For $i = 0 To UBound($aLabel) - 1
        If $Radio_Name = $aLabel[$i][0] Then

            If $Previous_DataLink <> $aLabel[$i][3] Then

                Local $aray = UseCurl($aLabel[$i][3], 5)
                Local $Data = $aray[0]
                Local $Error = $aray[1]

                $Previous_Data = $Data
                $Previous_DataLink = $aLabel[$i][3]

            Else

                $Data = $Previous_Data
                $Previous_DataLink = $aLabel[$i][3]

            EndIf

            Local $Between = _StringBetween($Data, $aLabel[$i][4], $aLabel[$i][5])
            If @error <> 0 Then
                $Between = ""
            Else
                If Not ($aLabel[$i][6] > Ubound($Between)-1) Then
                    $Between = $Between[$aLabel[$i][6]]
                Else
                    $Between = ""
                EndIf
            EndIf
            If $aLabel[$i][7] <> "" Then
                Local $Split = StringSplit($Between, $aLabel[$i][7], 1)
                If $Split[0] < $aLabel[$i][8] Then
                    Local $Info = ""
                Else
                    $Info = $Split[$aLabel[$i][8]]
                EndIf
            Else
                $Info = $Between
            EndIf

            If $Data = "" Then
                $Info = $Error
            EndIf

            $Info = StringReplace($Info, "â·", "·")
            $Info = StringReplace($Info, "apos;", "'")
            Assign($aLabel[$i][1] & $aLabel[$i][2], $Info)

        EndIf
    Next

    If _BASS_ChannelIsActive($MusicHandle) <> 1 and $Play = 1 Then

        _Audio_stop($MusicHandle)

        ;ConsoleWrite("Start playing sound" & @CRLF)
        $Play = 1
        $MusicHandle = _Set_url($Radio_SoundLink)
        _Audio_play($MusicHandle)

        ;ConsoleWrite("Set Volume" & @CRLF)
        $VolumePercent = IniRead($Save_INI, @ComputerName, "Volume", 4)
        $Previous_VolumePercent = $VolumePercent
        _Set_volume($VolumePercent)

    EndIf

    ;Update Ctrl
    For $i = 0 To UBound($aLabel) - 1
        If $Radio_Name = $aLabel[$i][0] Then
            If Eval($aLabel[$i][1] & $aLabel[$i][2]) <> GUICtrlRead($aLabel[$i][9]) Then
                GUICtrlSetData($aLabel[$i][9], Eval($aLabel[$i][1] & $aLabel[$i][2]))
            EndIf
        EndIf
    Next

    ;ConsoleWrite("GetPlayerDATA (End)" & @CRLF)

EndFunc ;==>GetPlayerDATA()

#EndRegion ;==> Internal Func

While 1

    Local $Msg = GUIGetCursorInfo($PlayerGUI)

    If $Msg[4] = $Close Then
        If $Msg[2] = 1 Then
            _GUICtrlButton_SetImage($Close, @ScriptDir & "\AutoIt Radio Player\Img\Closep.bmp");MousePressed
        Else
            _GUICtrlButton_SetImage($Close, @ScriptDir & "\AutoIt Radio Player\Img\Closeo.bmp");MouseOver
        EndIf
    Else
        _GUICtrlButton_SetImage($Close, @ScriptDir & "\AutoIt Radio Player\Img\Close.bmp");Nothing
    EndIf

    If $Play = 1 Then
        If $Msg[4] = $PlayPause Then
            If $Msg[2] = 1 Then
                _GUICtrlButton_SetImage($PlayPause, @ScriptDir & "\AutoIt Radio Player\Img\stopp.bmp");MousePressed
            Else
                _GUICtrlButton_SetImage($PlayPause, @ScriptDir & "\AutoIt Radio Player\Img\stopo.bmp");MouseOver
            EndIf
        Else
            _GUICtrlButton_SetImage($PlayPause, @ScriptDir & "\AutoIt Radio Player\Img\stop.bmp");Nothing
        EndIf
    Else
        If $Msg[4] = $PlayPause Then
            If $Msg[2] = 1 Then
                _GUICtrlButton_SetImage($PlayPause, @ScriptDir & "\AutoIt Radio Player\Img\playp.bmp");MousePressed
            Else
                _GUICtrlButton_SetImage($PlayPause, @ScriptDir & "\AutoIt Radio Player\Img\playo.bmp");MouseOver
            EndIf
        Else
            _GUICtrlButton_SetImage($PlayPause, @ScriptDir & "\AutoIt Radio Player\Img\play.bmp");Nothing
        EndIf
    EndIf

    Sleep(100)

WEnd


;1075 v0.0.0.8 30/04/2016 01:55

 

Edited by Synapsee
Link to post
Share on other sites

I've tryd it but it won't play anything (no sound).

But (since I ran your program) now every program I use that uses bass.dll won't give any sound when not compiled on my pc.

When I compile the script everything works ok but not when I started from the code, everything than works ok but no sound,

So how can I fixed this!!!!

 

EDIT

I've fixed this to run this small script

$VolumeTarget = "autoit3.exe"

ShellExecute("nircmdc.exe", 'setappvolume "' & $VolumeTarget & '" ' & 10, @ScriptDir & "\AutoIt Radio Player\dep", "", @SW_HIDE)

I don't think this is the right way to make a program!!!

Edited by nend
Link to post
Share on other sites

Hi nend and thx for spend time on my script but i can't understand.

Have u try mousewheel up/down ? This don't change the volume ?

Quote

Install/Use :

-Use MouseWheel for change volume
          Note : On first start : volume = 4%

When u use that :

Quote
$VolumeTarget = "autoit3.exe"

ShellExecute("nircmdc.exe", 'setappvolume "' & $VolumeTarget & '" ' & 10, @ScriptDir & "\AutoIt Radio Player\dep", "", @SW_HIDE)

 

This set your volume @ 100% or 10% ?

Set the volume @ 50% should be :

ShellExecute("nircmdc.exe", 'setappvolume "' & $VolumeTarget & '" ' & 50/100, @ScriptDir & "\AutoIt Radio Player\dep", "", @SW_HIDE)

Edit :

Quote

But (since I ran your program) now every program I use that uses bass.dll won't give any sound when not compiled on my pc.

ok, i understand better, sorry for this problem, i will look arround use bass.dll instead of change the "autoit3.exe" volume lvl.

Edited by Synapsee
Link to post
Share on other sites

The problem is that the nircmdc.exe set al the audio volume for all autoit scripts.

If u use Bass.dll for your project it will work a lot better.

When I started this script all my scripts didn't work properly anymore, but by exmanine your script I realized that the command niccmdc take over every au3 script audio.

I will check your script again (with the mouse wheel) and come back on it.

EDIT:

I've try'd it again but the same issue, program won't react and no sound (even with mousewheel)

But now I didn't get the sound back and needed a system recovery to get it work again.

For now I won't test it again until you get rid of nircmdc.

Edited by nend
Link to post
Share on other sites

Hey, thx for reply <3

This is strange, the script is probably stuck somewhere on spacetime

Can u see gui ? gui is feeded with cover/data ? can u see close button ? can u drag gui ? can u rightclic ? the gui hang ? when u mousewheel u see current volume % appear ?

I work on a new version with more console return, this will help a lot for this case.

Actually i progress on curl stuff, because i can't set timeout for the iniread($coverlink) but with curl i can : )

Edited by Synapsee
Link to post
Share on other sites

Here the same problem program hangs and kills the audio I have to kill it in the taskmanager to stop the program (windows 10 64 bits).

I see the gui but the I can do anything, did you see the pm I send you?

It's very simpel to rebuild this app with bass.dll and than you don't have this problem.

Edited by nend
Link to post
Share on other sites
Quote

did you see the pm I send you?

No, i don't know how i can see it. I see u posted on my profile but where ? this is the ask ^^ Can't find

Quote

It's very simpel to rebuild this app with bass.dll and than you don't have this problem.

It's sure i need use bass.dll but the program hangs for another reason i think. And I have no hang on start on my computer.

I think the best is wait for another version with more debug stuff for find where the script stuck.

Link to post
Share on other sites
1 hour ago, Synapsee said:

Can u see gui ? yes

gui is feeded with cover/data ? yes

can u see close button ? yes, but when i click nothing appens 

can u drag gui ?  no

can u rightclic ? yes

the gui hang ?  no i don't think

when u mousewheel u see current volume % appear ? no

 

20160428151121e6jte.png

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to post
Share on other sites

Last ver : v0.0.0.8

AutoIt Radio Player v0.0.0.8.zip

Changelog :

Spoiler

-Better code practice
          Replace dim with local
          Use #AutoIt3Wrapper_Au3Check_Parameters=-w 1 -w 2 -w 3 -w- 4 -w 6 -w- 7
          Improve some comment

-Replace SoundPlay\nircmd with Bass.dll usage
          SoundPlay\nircmd is a novice usage, Bass.dll usage is better
          Now if an event like disconnect appear the sound resume.
          Thx to nend, ..., No ! Big Thx to nend ;)

-Replace InetRead/_InetGetSource with Curl.au3 usage
          InetRead/_InetGetSource seems limited with timeout management
          Both replaced with Curl_Easy_Perform()
          Set all timeout to 5s
          If timeout is reached about tracktitle for sample you will see now "timeout was reached" (curl error return)

TODO :

Spoiler

-Update first post

-About Timeout/ GUI-blocking
          Curl_Easy_Perform() seems better but not the best for GUI Hang while timeout is not reached.
          I need study about Curl.au3 for use Curl_Multi_Perform() (study the non-GUI-blocking technique sample).
                    This is done. Curl.au3\Curl_Example_Multi.au3 rocks ;)

-Add right clic functionnality for a Website Station shorcut.
          This is done with _WinAPI_AssocQueryString(".html", $ASSOCSTR_EXECUTABLE)

-Add right clic functionnality for a gui for add/del station or any other label.
          i will probably use _FileReadToArray, _FileWriteFromArray for save the gui data.
                    In progress...

 

or any other label explain :

          Current : TrackTiTle
          Coffee Ready : Yes/No
          Weather : 26 Degres

Current RightClic :

          Current Station (onclic station switch)
          Separator
          Station A (onclic station switch)
          Station B (onclic station switch)

Next Target RightClic :

          Current Station
                    Website (open the station url)
                    Load (change to this station)
          Separator
          Station A
                     Website (open the station url)
                     Load (change to this station)
          Station B
                    Website (open the station url)
                    Load (change to this station)
          Separator
          Config (load a nice gui for manage the list station)

Console return :

Spoiler

Console should return :

Start
Build GUI
Build PlayerGUI
Build CoverGUI
Show GUI
GetPlayerDATA (Start)
Start playing sound
Set Volume
GetPlayerDATA (End)
GetCoverDATA (Start)
$RealCoverLink = http://imglink.jpg
GetCoverDATA (End)
GUIRegisterMsg

And a while with :

GetPlayerDATA (Start)
GetPlayerDATA (End)

GetCoverDATA (Start)
$RealCoverLink = http://imglink.jpg
GetCoverDATA (End)

Related link :

bass.dll source : http://www.un4seen.com/bass.html (v2.4.12.1)

bass.au3 source : bass related forum post (patch 9.2/Constant from 9.0)

nice autoit program for help with Curl.au3 usage by wakillon : Mp3SearchEngine

nice autoit program "radio related" by nend : http://trayradio.com/

Edited by Synapsee
Link to post
Share on other sites
10 hours ago, wakillon said:

Now i can drag gui and volume is displayed but i have no sound...

It's probably related to v0.0.0.7 (nircmd.exe use).

Try up sound on the windows mixer panel (While Player running).

%windir%\System32\SndVol.exe

57265693366f6_mixerfix.jpg.ec133a7364418

Link to post
Share on other sites

hi argumentum,

Quote

every second ?

for the moment it's all 8s :

...
AdlibRegister("GetCoverDATA", 8000)
...
AdlibRegister("GetPlayerDATA", 8000)
...

i will add a config GUI where u can config this timing for each downloaded DATA.

Quote

Opt("TrayAutoPause", 0)

Not a bad idea, just discover that, seems a good improve for make autoit trayicon more easy to use. Thx u for sharing and testing : )

Link to post
Share on other sites
  • 2 weeks later...

I'm trying some Bass Plugin scripts since yesterday and note that i have no sound !

So, intriged by this problem, I made the connection with your script where i have no sound too.

After having verified my sound card drivers, uninstall and reinstall, there is no changes...

In the meantime i have used my Mp3SearchEngine who use bass.dll and i have sound...

So a bit lost, i did not understand why some scripts "works" and others not !

And i realize that Mp3SearchEngine was compiled and other not.

So i compile my script and run it and...i get sound ! and same for yours too !

So be reassured your last version works well ;)

 

Now, I have to find why i have a sound problem running "Bass" script not compiled...:sweating:

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to post
Share on other sites

Start a not compiled script, start play a sound (you should have no sound). and do that :

 

Edit ; nircmd.exe have set "autoit3.exe" sound to 0%

when u compile a script "yourscript.exe" the sound is at 100% but if not compiled windows see him like "autoit3.exe"  and sound is at 0%

Edited by Synapsee
Link to post
Share on other sites

C:\Windows\WinSxS\x86_microsoft-windows-audio-volumecontrol_31bf3856ad364e35_6.3.9600.17415_none_5b14d0ca22da016a\SndVol.exe

good job !

 

Not really, u start my v0.0.0.7, nircmd set autoit3.exe @ 0%, after a error appear, you close the script, the sound is always at 0%

set the autoit3.exe volume directly is just a bad idea because this affect all not compiled script.

But nircmd.exe have do the good job, its more a bad use of him. Bass seems set volume only for the current script so it's clearly better.

I'm really sorry for that problem, im happy see you resolve it ; )

 

I'm continue dev my script, i learn a lot every day, i have add some functionnality with a gui for config, etc...

My dream now it's add something like that : https://autoit.de/index.php/Thread/23204-Audio-Visualization-Collection/ while playing radio ; )

Link to post
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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Mr_Microphone
      Alright, I may be an idiot.
      Three years ago, I wrote a program that pushed component information to a secure site via their API. I went back to add some attributes and (here's the idiot part) ended up losing the  source code and my modified code does not quite work. I have the compiled version that works minus the new attributes, so I know that their system has not changed. I stripped the larger program down from 3,000 lines to the part that is broken, but I am stumped. This was one of my first scripts, so it heavily leverages examples and isn't as pretty as I'd like it to be.
      Be gentle. 
      The program / script creates a new records as expected, but for some reason, I cannot access information in the response, which I need for a later step.
      I use Charles, a web debugging proxy tool so I can see the request and the response and both are as expected. Also, when I write to log file, the JSON reply is exactly what I expect and need, but when I try to do anything with the http body, it seems to be blank. 
      Here is the script minus  the URL and token:
      #include <Array.au3> #include <Curl.au3> #include <MsgBoxConstants.au3> #include <json.au3>  ; this was added as an alternate way to read the data Global $WM_serial_number = "WM20745001" Global $wm_component_status_id = "10" Global $wm_manufacturer ="Multi-Tech" Global $wm_model = "MTR-LAT1-B07" Global $cellular_carrier_id = "3" Global $iccid_esn = "89010303300012345678" Global $ip_address = "192.168.2.11" Global $NewIDNumber     Local $Curl = Curl_Easy_Init()     Local $Html = $Curl ; any number as identify     Local $Header = $Curl + 1 ; any number as identify     Local $HtmlFile = "cURL_Request.html"     Local $File = FileOpen($HtmlFile, 2 + 16)     Local $Slist = Curl_Slist_Append(0, "content-type: multipart/form-data; boundary=---011000010111000001101001")     $Slist = Curl_Slist_Append($Slist, "authorization: Token token=" & $Token)     Curl_Easy_Setopt($Curl, $CURLOPT_PROXY, "127.0.0.1") ; needed to use Charles web debugging proxy     Curl_Easy_Setopt($Curl, $CURLOPT_PROXYPORT, 8888) ; needed to use Charles     Curl_Easy_Setopt($Curl, $CURLOPT_HTTPHEADER, $Slist) ;     Curl_Easy_Setopt($Curl, $CURLOPT_URL, $Server & "wireless_module" & "s")     Curl_Easy_Setopt($Curl, $CURLOPT_SSL_VERIFYPEER, 0)     Curl_Easy_Setopt($Curl, $CURLOPT_TIMEOUT, 30)     Curl_Easy_Setopt($Curl, $CURLOPT_WRITEDATA, $Html)     Curl_Easy_Setopt($Curl, $CURLOPT_WRITEFUNCTION, Curl_FileWriteCallback())     Curl_Easy_Setopt($Curl, $CURLOPT_WRITEDATA, $File)     Local $HttpPost = ""     Local $LastItem = ""         Curl_FormAdd($HttpPost, $LastItem, $CURLFORM_COPYNAME, "wireless_module" & "[serial_number]", $CURLFORM_COPYCONTENTS, $WM_serial_number, $CURLFORM_END)         Curl_FormAdd($HttpPost, $LastItem, $CURLFORM_COPYNAME, "wireless_module" & "[component_status_id]", $CURLFORM_COPYCONTENTS, $wm_component_status_id, $CURLFORM_END)         Curl_FormAdd($HttpPost, $LastItem, $CURLFORM_COPYNAME, "wireless_module" & "[manufacturer]", $CURLFORM_COPYCONTENTS, $wm_manufacturer, $CURLFORM_END)         Curl_FormAdd($HttpPost, $LastItem, $CURLFORM_COPYNAME, "wireless_module" & "[model]", $CURLFORM_COPYCONTENTS, $wm_model, $CURLFORM_END)         Curl_FormAdd($HttpPost, $LastItem, $CURLFORM_COPYNAME, "wireless_module" & "[cellular_carrier_id]", $CURLFORM_COPYCONTENTS, $cellular_carrier_id, $CURLFORM_END)         Curl_FormAdd($HttpPost, $LastItem, $CURLFORM_COPYNAME, "wireless_module" & "[iccid_esn]", $CURLFORM_COPYCONTENTS, $iccid_esn, $CURLFORM_END)         Curl_FormAdd($HttpPost, $LastItem, $CURLFORM_COPYNAME, "wireless_module" & "[ip_address]", $CURLFORM_COPYCONTENTS, $ip_address, $CURLFORM_END)         ; submit         Curl_Easy_Setopt($Curl, $CURLOPT_HTTPPOST, $HttpPost)         Local $Code = Curl_Easy_Perform($Curl)         If $Code = $CURLE_OK Then         ConsoleWrite("Content Type: " & Curl_Easy_GetInfo($Curl, $CURLINFO_CONTENT_TYPE) & @LF)         ConsoleWrite("Download Size: " & Curl_Easy_GetInfo($Curl, $CURLINFO_SIZE_DOWNLOAD) & @LF)         MsgBox(0, 'Html', BinaryToString(Curl_Data_Get($Html))) ; this is something I threw in for debugging, expecting to see SOMETHING. Returns nothing         MsgBox(0, 'Header', BinaryToString(Curl_Data_Get($Header))) ; this is something I threw in for debugging, expecting to see SOMETHING. Returns nothing         Local $response = Curl_Easy_GetInfo($Curl, $CURLINFO_RESPONSE_CODE)             If $response = "409" Then $response = "Failed due to a conflict."             If $response = "200" Then $response = "Was NOT created."             If $response = "201" Then $response = "Was created."             ; read the ID that was assigned and store it         $NewIDNumber = StringRight(StringLeft(BinaryToString(Curl_Data_Get($Html)), 10), 4) ; this DID work, but now it doesn't. An old compiled version still works ;~         Global $JsonObject = json_decode($Html); another debugging attempt. Did not use json functions previously and the program worked without it. ;~         Global $NewIDNumber = json_get($JsonObject, '.id')         ConsoleWrite(@CRLF &'! id:' & $NewIDNumber & @CRLF & @CRLF)    ; debugging feedback         MsgBox(0, $response, $wm_serial_number & " new ID = " & $NewIDNumber); debugging feedback         If $Code <> $CURLE_OK Then ConsoleWrite(Curl_Easy_StrError($Code) & @LF)             Local $Data = BinaryToString(Curl_Data_Get($Curl))             Curl_Easy_Cleanup($Curl)             Curl_Data_Cleanup($Curl)             Curl_Data_Cleanup($Header)             Curl_Data_Cleanup($Html)             Curl_FormFree($HttpPost)             Curl_slist_free_all($Slist)             curl_easy_reset($Curl)             FileClose($File)             ConsoleWrite(@LF)         EndIf  This is the captured request (minus the host and token)
      POST /api/v2/wireless_modules HTTP/1.1 Host: api. Accept: */* authorization: Token token= Content-Length: 942 Expect: 100-continue content-type: multipart/form-data; boundary=---011000010111000001101001; boundary=------------------------9adb0d87c7ea5061 --------------------------9adb0d87c7ea5061 Content-Disposition: form-data; name="wireless_module[serial_number]" WM20745001 --------------------------9adb0d87c7ea5061 Content-Disposition: form-data; name="wireless_module[component_status_id]" 10 --------------------------9adb0d87c7ea5061 Content-Disposition: form-data; name="wireless_module[manufacturer]" Multi-Tech --------------------------9adb0d87c7ea5061 Content-Disposition: form-data; name="wireless_module[model]" MTR-LAT1-B07 --------------------------9adb0d87c7ea5061 Content-Disposition: form-data; name="wireless_module[cellular_carrier_id]" 3 --------------------------9adb0d87c7ea5061 Content-Disposition: form-data; name="wireless_module[iccid_esn]" 89010303300012345678 --------------------------9adb0d87c7ea5061 Content-Disposition: form-data; name="wireless_module[ip_address]" 192.168.2.11 --------------------------9adb0d87c7ea5061-- and the captured response
      HTTP/1.1 201 Created Date: Sun, 04 Apr 2021 00:12:18 GMT Server: Apache Cache-Control: max-age=0, private, must-revalidate Access-Control-Allow-Origin: not-allowed Vary: Accept-Encoding Access-Control-Max-Age: 1728000 X-XSS-Protection: 1; mode=block X-Request-Id: 71cfcf36-6020-48a6-a822-d2b393a27b69 Access-Control-Allow-Credentials: true Access-Control-Allow-Methods: PUT, OPTIONS, GET, POST ETag: W/"25d97fe8a9387cb4b9029a9e62b0bfa2" X-Frame-Options: SAMEORIGIN, SAMEORIGIN X-Runtime: 0.344005 X-Content-Type-Options: nosniff Access-Control-Request-Method: * X-Powered-By: Phusion Passenger 5.2.1 Strict-Transport-Security: max-age=63072000; includeSubDomains; preload Location: /wireless_modules/3195 Status: 201 Created Connection: close Transfer-Encoding: chunked Content-Type: application/json; charset=utf-8 X-Charles-Received-Continue: HTTP/1.1 100 Continue {"id":3195,"model":"MTR-LAT1-B07","serial_number":"WM20745001","manufacturer":"Multi-Tech","mfg_date":null,"iccid_esn":"89010303300012345678","ip_address":"192.168.2.11","purchase_order":null,"supplier":null,"cellular_carrier_id":3,"component_status_id":10,"component_status":{"id":10,"name":"Hold","description":"Available- Held for specific use"},"custom_attributes":[{"name":"Deactivated","type":"Boolean","value":false},{"name":"Port 3001","type":"Boolean","value":false}],"comments":[]}  
      Also attached is the log file. I need to read the id value. Clearly, it is arriving back to cURL, since it is being written out to the log, but I cannot seem to get to it within the code. 
      It is established that I may be an idiot, but this idiot has wasted days in non-billable hours trying to figure out what should be a simple glitch.
      Help???
       
      cURL_Request.html
    • By CYCho
      zPlayer is the name I used when I introduced the early version of this player in my blog back in early 2009 and, therefore, has nothing to do with the mobile media player of the same name which started marketing in 2015.
      After I retired from active duty in 2002 I spent much time listening to music. First I started with CD's and LP's, then quickly moved on to mp3 files. I converted many of my CD's to mp3 and I collected many more from various sources which were freely available at the time. As the number of my mp3 files grew, I put them in folders according to their genres and my favorite classifications. I mainly used Windows Media Player to listen to them and I slowly began to dislike wmp because it had massive user interface while I just wanted to listen to music in the background while I was doing other work in the foreground, hopping between folders from time to time. It was the time I was beginning to learn AutoIt and I thought I should make my own player with AutoIt. Coming from a sales career with no experience in programming, it was not an easy task. Somehow, after about 2 years of learning and trying, I had my own audio player which worked with only hotkeys without any graphical interface. I gave it to some of my friends who were not as computer-savvy as I. They liked it but definitely wanted something to clcik with mouse. So I came up with very rude gui which took a form similar to what it is now.
      The attached source files include one au3 file, one icon file and 14 jpg files. The jpg files are used for drawing a graphical player and are fileinstalled in @DocumentsCommonDir folder. This player uses WMPlayer.OCX as its engine and supports all audio file formats supported by wmp and additional codecs installed. I would like to thank @Bilgus for kind answers to my questions and would appreciate it if anyone could review the code and give me any suggestion. This player works for me, but I don't know whether the code is presentable as an example. I am posting this here with a hope to learn much from AutoIt community.
      PS: 1. An error (Variable used before declaration) was reported and corrected - 02:00 hours GMT,  March 14, 2019
            2. An error in tray menu was corrected -10:00 hours GMT, March14, 2019
            3. AutoIt3Wrapper_Au3Check_Parameters definition was added at the top of the code and all ensuing errors were corrected. - 00:10 hours GMT, March 16 2019
            4. Some features were added. - 10:30 hours GMT, March 18, 2019
                a. Jumping to new play-back position in a file
                b. Support for a manually made playlist
                c. Ctrl+Alt+h hotkey to trigger a help message box
            5. The minimum resizing width of playlist window was set at 450. - 01:10 hours GMT, March 23, 2019
            6. Problems associated with actions taken while in 'paused' status was addressed. - 07:40 GMT, April 12, 2019
            7. An error was found and corrected in restoring previous play-back environment when the mode was 'Shuffled.' - 11:00 GMT, April 17, 2019


      Please see Downloads section of this forum for source code files.
       
    • By Roy_
      Ciao,
      This example reproduces the problem I encounter when sending a post request to an echo server.
      Instead of being sent as text utf8, the data is transmitted base64 encoded.
      Example:
      - json String: '{"firstName":"Jonathan","lastName":"Freeman","loginCount":4,"active": "yes","text":"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi vel volutpat nunc. Maecenas id tempus mi. Morbi ipsum enim, ultricies ac augue sit amet, ullamcorper finibus ex. Vestibulum vel posuere nibh, nec faucibus eros. Nam malesuada non lacus a suscipit. Nulla rhoncus tempus mi quis placerat. Curabitur commodo tincidunt justo quis sollicitudin."}'
      - server response: "data:application/octet-stream;base64,AAAAALgE6QNYAIAAAgAAANQCAAAAAAAAWF8AAAAAAAD0VQAAAAAAAD9APQAAAAAAAwAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAABBAAAAAAABRUAAAAmIZwcAbRt8/LMa9UAAAAAAAAAAGFzIGlkIHRlbXB1cyBtaS4gTW9yYmkgaXBzdW0gZW5pbSwgdWx0cmljaWVzIGFjIGF1Z3VlIHNpdCBhbWV0LCB1bGxhbWNvcnBlciBmaW5pYnVzIGV4LiBWZXN0aWJ1bHVtIHZlbCBwb3N1ZXJlIG5pYmgsIG5lYyBmYXVjaWJ1cyBlcm9zLiBOYW0gbWFsZXN1YWRhIG5vbiBsYWN1cyBhIHN1c2NpcGl0LiBOdWxsYSByaG9uY3VzIHRlbXB1cyBtaSBxdWlzIHBsYWNlcmF0LiBDdXJhYml0dXIgY29tbW9kbyB0aW5jaWR1bnQganVzdG8gcXVpcyBzb2xsaWNpdHVkaW4uIn0="
       
      How can I go about transmitting data in text format utf8?
      Thanks in advance for the help.
      In the zip file:
      - CurlJsonPost.au3: this script
      - Curl.au3: UDF by Ward (thank you!)
      - data.json: json srting for command line test
       
      Note: using Curl.exe with json string saved in a file (utf8 encoded) named data.json, works perfectly
      To try with the command line tool:
      - save data.json in curl\bin directory
      - open cmd.exe and cd to curl\bin directory
      - Enter the following command:
      curl -H "Content-Type: application/json" --data @data.json https://httpbin.org/post
       
      #Include "Curl.au3" Global $_cURL_OutputBuffer Local $sJson = '{"firstName":"Jonathan","lastName":"Freeman","loginCount":4,"active": "yes","text":"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi vel volutpat nunc. Maecenas id tempus mi. Morbi ipsum enim, ultricies ac augue sit amet, ullamcorper finibus ex. Vestibulum vel posuere nibh, nec faucibus eros. Nam malesuada non lacus a suscipit. Nulla rhoncus tempus mi quis placerat. Curabitur commodo tincidunt justo quis sollicitudin."}' Local $iRetCode, $sServerResponse ConsoleWrite("=== Json post test ===" & @LF) ConsoleWrite(StringFormat("Retcode: %s - %s", $iRetCode, Curl_Easy_strerror($iRetCode)) & @LF) ConsoleWrite("Data returned from server" & @LF & @LF) $sServerResponse = JsonPost_Test($sJson, $iRetCode) ConsoleWrite($sServerResponse & @LF) Func JsonPost_Test($sJson, ByRef $iRetCode) ; Init Easy Curl Interface e set url (echo service) Local $oCurl = Curl_Easy_Init() curl_easy_setopt($oCurl, $CURLOPT_URL, "https://httpbin.org/post") ; Set content type header Local $headers = curl_slist_append(0, "Content-Type: application/json") curl_easy_setopt($oCurl, $CURLOPT_HTTPHEADER, $headers) ; Post fields & size curl_easy_setopt($oCurl, $CURLOPT_POSTFIELDS, $sJson) curl_easy_setopt($oCurl, $CURLOPT_POSTFIELDSIZE, StringLen($sJson)) ; Set callbac function to get server response back (see global var $_cURL_OutputBuffer) $hWriteFunc = DllCallbackRegister("WriteFunc_CallBack", "uint:cdecl", "ptr;uint;uint;ptr") curl_easy_setopt($oCurl, $CURLOPT_WRITEFUNCTION, DllCallbackGetPtr($hWriteFunc)) ; Ignore ssl certificates check curl_easy_setopt($oCurl, $CURLOPT_SSL_VERIFYPEER, 0) curl_easy_setopt($oCurl, $CURLOPT_SSL_VERIFYHOST, 0) ; Execute the post request $iRetCode = curl_easy_perform($oCurl) ; Set return trasfer & clear output buffer global var Local $sReturnTransfer = $_cURL_OutputBuffer $_cURL_OutputBuffer = "" Return SetError(0, 0, $sReturnTransfer) EndFunc Func WriteFunc_CallBack($ptr,$nSize,$nMemb,$pStream) Local $vData = DllStructCreate ("byte[" & $nSize*$nMemb & "]",$ptr) $_cURL_OutputBuffer &= BinaryToString(DllStructGetData($vData,1)) Return $nSize*$nMemb EndFunc  
      curlJsonPost.zip
    • By UEZ
      Hi,
      I created a FMOD UDF (x86 / x64 compatible) whereas the DLL calls are done from memory directly!
      Credits to trancexx for the Subrogation functions!
       
      Supported formats:
      - .MOD (protracker/fasttracker modules) - .S3M (screamtracker 3 modules) - .XM (fasttracker 2 modules) - .IT (impulse tracker modules) - .MID (MIDI files) - .RMI (MIDI files) - .SGT (DirectMusic segment files) - .FSB (FMOD Sample Bank files) - .MP3 - .OGG - .WAV - .MP2 - .RAW  
      Current added function list (sum = 70):
      FMUSICMEM_FreeSong FMUSICMEM_GetBPM FMUSICMEM_GetGlobalVolume FMUSICMEM_GetMasterVolume FMUSICMEM_GetName FMUSICMEM_GetNumChannels FMUSICMEM_GetNumInstruments FMUSICMEM_GetNumOrders FMUSICMEM_GetNumPatterns FMUSICMEM_GetNumSamples FMUSICMEM_GetOrder FMUSICMEM_GetPaused FMUSICMEM_GetRow FMUSICMEM_GetSpeed FMUSICMEM_GetTime FMUSICMEM_GetType FMUSICMEM_IsFinished FMUSICMEM_LoadSong FMUSICMEM_LoadSongEx FMUSICMEM_OptimizeChannels FMUSICMEM_PlaySong FMUSICMEM_SetMasterVolume FMUSICMEM_SetOrder FMUSICMEM_SetPaused FMUSICMEM_StopAllSongs FMUSICMEM_StopSong FSOUNDMEM_Close FSOUNDMEM_DSP_Create FSOUNDMEM_DSP_Free FSOUNDMEM_DSP_GetActive FSOUNDMEM_DSP_GetFFTUnit FSOUNDMEM_DSP_GetSpectrum FSOUNDMEM_DSP_SetActive FSOUNDMEM_DSP_SetPriority FSOUNDMEM_GetAmplitude FSOUNDMEM_GetChannelsPlaying FSOUNDMEM_GetCPUUsage FSOUNDMEM_GetCurrentLevels FSOUNDMEM_GetError FSOUNDMEM_GetFrequency FSOUNDMEM_GetGetSurround FSOUNDMEM_GetMaxChannels FSOUNDMEM_GetPan FSOUNDMEM_GetPaused FSOUNDMEM_GetVolume FSOUNDMEM_Init FSOUNDMEM_SetPaused FSOUNDMEM_SetSpeakerMode FSOUNDMEM_SetSurround FSOUNDMEM_SetVolume FSOUNDMEM_SetVolumeAbsolute FSOUNDMEM_Stream_Close FSOUNDMEM_Stream_FindTagField FSOUNDMEM_Stream_GetLength FSOUNDMEM_Stream_GetLengthMs FSOUNDMEM_Stream_GetNumTagFields FSOUNDMEM_Stream_GetOpenState FSOUNDMEM_Stream_GetPosition FSOUNDMEM_Stream_GetTagField FSOUNDMEM_Stream_GetTime FSOUNDMEM_Stream_Net_GetStatus FSOUNDMEM_Stream_Net_SetMetadataCallback FSOUNDMEM_Stream_Net_SetProxy FSOUNDMEM_Stream_Open FSOUNDMEM_Stream_Play FSOUNDMEM_Stream_PlayEx FSOUNDMEM_Stream_SetLoopCount FSOUNDMEM_Stream_SetPosition FSOUNDMEM_Stream_SetTime FSOUNDMEM_Stream_Stop  
      In the zip archive you can find 6 examples.
       
      Download:  FModMem UDF build 2019-11-24.zip
       
      If you have created additional examples, feel free to post it here.
    • By panlatv
      Hello everybody (and sorry for my bad english)

      I try to get the position of a contextmenu (GUICtrlCreateContextMenu) on a TreeView, with ControlGetPos, but i can't.
      Someone can help me ? Thank you :)

      PS: I need the position to select item wtih rightclick before read the text of the item, because rightclick don't select item (only leftclick).
       
×
×
  • Create New...