_Radio UDF

  • Hallo Leute,

    hier meine erste UDF, die _Radio UDF.

    Funktionen
    [autoit]

    _Radio_ReadTitleFromASX($hFile)
    _Radio_ReadBitrateFromASX($hFile)
    _Radio_ReadSourceURLFromASX($hFile)
    _Radio_ReadGenreFromASX($hFile)
    _Radio_ReadEntrieFromPLS($hFile)
    _Radio_ReadTitleFromPLS($hFile)
    _Radio_ReadSourceURLFromPLS($hFile)
    _Radio_ReadLengthFromPLS($hFile)
    _Radio_Create($sName, $hGUI, $bLeft, $bTop)
    _Radio_Action_SetItem($hPlayer, $sPathOrURL)
    _Radio_Action_Play($hPlayer)
    _Radio_Action_Pause($hPlayer)
    _Radio_Action_Stop($hPlayer)
    _Radio_Action_Next($hPlayer)
    _Radio_Action_Previous($hPlayer)
    _Radio_Action_FastForward($hPlayer)
    _Radio_Action_FastReverse($hPlayer)

    [/autoit]

    _Radio.au3 und die anderen benötigten Includes mit Examples im Anhang bereitgestellt.

    Mit Freundlichen Grüßen,
    BurakSZ

  • Was macht deine UDF nur mal so?

    Zitat

    [Heute, 11:39] Raupi: Soll ich es dir machen?
    [Heute, 11:47] BugFix: "Soll ich es dir machen? " - also Raupi !! bitte nicht so öffentlich :rofl:

    Zitat

    [Heute, 11:51] BugFix: und ich werde es mir jetzt machen - das Mittagessen :P

    AMsg UDF v1.00.00 IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII 100%
    OwnStyle UDF Version 1.10.00 IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII 100%

  • Guck dir mal die Examples an und downlaode dir das mal bevor du unnötig fragst...

  • Warum gleich so aufgebracht?

    Ich hab dich höflich gefragt, oder?

    Bevor ich was downlode will ich wissen, was es macht und was mir das bringt.

    Zitat

    [Heute, 11:39] Raupi: Soll ich es dir machen?
    [Heute, 11:47] BugFix: "Soll ich es dir machen? " - also Raupi !! bitte nicht so öffentlich :rofl:

    Zitat

    [Heute, 11:51] BugFix: und ich werde es mir jetzt machen - das Mittagessen :P

    AMsg UDF v1.00.00 IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII 100%
    OwnStyle UDF Version 1.10.00 IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII 100%

  • Bist du dir zu schade den Quellcode von oben zu downloaden (der übrigens in der .rar enthalten ist)? Da sind tausende von Beispielen drinne, mit Beschreibungen :!: die du dir angucken kannst. In dem Archiv kannst du auch nachlesen was sie bringen, sogar detailliert. Spätestens dann weißt du was es dir bringt. Da du dir zu schade bist um einen Klick auszuführen, poste ich den Quellcode gleich hier damit du nicht mit viel mühe nach oben scrollen musst:

    _Radio.au3
    [autoit]

    #include-once
    #include <String.au3>
    #include <Array.au3>
    #include <WindowsConstants.au3>
    ; ------------------------------------------------------------------------------
    ;
    ; AutoIt Version: 3.3.6.1
    ; Language: English
    ; Description: Radio functions
    ; Author(s): Burak Kavak
    ; Requirement(s): String.au3, Array.au3 and WindowsConstants.au3
    ; ------------------------------------------------------------------------------

    [/autoit] [autoit][/autoit] [autoit]

    ;===============================================================================
    ;
    ; Description: Reads title(s) from a ASX file (Version 3.0)
    ; Syntax: _Radio_ReadTitleFromASX
    ; Parameter(s):
    ; $hFile - The path to the file which you want to read
    ;
    ; Return Value(s):
    ; Success - Returns a $var with array (First $array[0] is the first title which was found, $array[1] is the second, $array[n] ...
    ; Failure - If the file path is wrong @error will be set to 2 and 2 will be returned
    ; Failure - If no title(s) will be found @error will be set to 3 and 3 will be returned
    ; Failure - If the file can't be read @error will be set to 4 and 4 will be returned
    ;
    ;===============================================================================
    Func _Radio_ReadTitleFromASX($hFile)
    If $hFile <> "" Then
    $vRead = FileRead($hFile)
    If @error = 1 Then
    Return 4
    SetError(4)
    Exit
    EndIf
    $vTitle = _StringBetween($vRead, "<Title >", "</Title>")
    If $vTitle = 0 Then
    Return 3
    SetError(3)
    Exit
    Else
    $vTitleResult = _ArrayUnique($vTitle)
    _ArrayDelete($vTitleResult, 0)
    Return $vTitleResult
    EndIf
    Else
    Return 2
    SetError(2)
    Exit
    EndIf
    EndFunc ;==>_Radio_ReadTitleFromASX
    ;===============================================================================
    ;
    ; Description: Reads bitrate(s) from a ASX file (Version 3.0)
    ; Syntax: _Radio_ReadBitrateFromASX
    ; Parameter(s):
    ; $hFile - The path to the file which you want to read
    ;
    ; Return Value(s):
    ; Success - Returns a $var with array (First $array[0] is the first bitrate which was found, $array[1] is the second, $array[n] ...
    ; Failure - If the file path is wrong @error will be set to 2 and 2 will be returned
    ; Failure - If no bitrate(s) will be found @error will be set to 3 and 3 will be returned
    ; Failure - If the file can't be read @error will be set to 4 and 4 will be returned
    ;
    ;===============================================================================
    Func _Radio_ReadBitrateFromASX($hFile)
    If $hFile <> "" Then
    $vRead = FileRead($hFile)
    If @error = 1 Then
    Return 4
    SetError(4)
    Exit
    EndIf
    $vBitrate = _StringBetween($vRead, '<Param Name = "Bitrate" Value = "', '" />')
    If $vBitrate = 0 Then
    Return 3
    SetError(3)
    Exit
    Else
    $vBitrateResult = _ArrayUnique($vBitrate)
    _ArrayDelete($vBitrateResult, 0)
    Return $vBitrateResult
    EndIf
    Else
    Return 2
    SetError(2)
    Exit
    EndIf
    EndFunc ;==>_Radio_ReadBitrateFromASX
    ;===============================================================================
    ;
    ; Description: Reads source URL(s) from a ASX file (Version 3.0)
    ; Syntax: _Radio_ReadSourceURLFromASX
    ; Parameter(s):
    ; $hFile - The path to the file which you want to read
    ;
    ; Return Value(s):
    ; Success - Returns a $var with array (First $array[0] is the first source URL which was found, $array[1] is the second, $array[n] ...
    ; Failure - If the file path is wrong @error will be set to 2 and 2 will be returned
    ; Failure - If no source URL(s) will be found @error will be set to 3 and 3 will be returned
    ; Failure - If the file can't be read @error will be set to 4 and 4 will be returned
    ;
    ;===============================================================================
    Func _Radio_ReadSourceURLFromASX($hFile)
    If $hFile <> "" Then
    $vRead = FileRead($hFile)
    If @error = 1 Then
    Return 4
    SetError(4)
    Exit
    EndIf
    $vSourceURL = _StringBetween($vRead, '<Param Name = "SourceURL" Value = "', '" />')
    If $vSourceURL = 0 Then
    Return 3
    SetError(3)
    Exit
    Else
    $vSourceURLResult = _ArrayUnique($vSourceURL)
    _ArrayDelete($vSourceURLResult, 0)
    Return $vSourceURLResult
    EndIf
    Else
    Return 2
    SetError(2)
    Exit
    EndIf
    EndFunc ;==>_Radio_ReadSourceURLFromASX
    ;===============================================================================
    ;
    ; Description: Reads Genre(s) from a ASX file (Version 3.0)
    ; Syntax: _Radio_ReadGenreFromASX
    ; Parameter(s):
    ; $hFile - The path to the file which you want to read
    ;
    ; Return Value(s):
    ; Success - Returns a $var with array (First $array[0] is the first genre which was found, $array[1] is the second, $array[n] ...
    ; Failure - If the file path is wrong @error will be set to 2 and 2 will be returned
    ; Failure - If no genre(s) will be found @error will be set to 3 and 3 will be returned
    ; Failure - If the file can't be read @error will be set to 4 and 4 will be returned
    ;
    ;===============================================================================
    Func _Radio_ReadGenreFromASX($hFile)
    If $hFile <> "" Then
    $vRead = FileRead($hFile)
    If @error = 1 Then
    Return 4
    SetError(4)
    Exit
    EndIf
    $vGenre = _StringBetween($vRead, '<Param Name = "WM/Genre" Value = "', '" />')
    If $vGenre = 0 Then
    Return 3
    SetError(3)
    Exit
    Else
    $vGenreResult = _ArrayUnique($vGenre)
    _ArrayDelete($vGenreResult, 0)
    Return $vGenreResult
    EndIf
    Else
    Return 2
    SetError(2)
    Exit
    EndIf
    EndFunc ;==>_Radio_ReadGenreFromASX
    ;===============================================================================
    ;
    ; Description: Reads number of entrie(s) from a PLS File (Version 2)
    ; Syntax: _Radio_ReadEntrieFromPLS
    ; Parameter(s):
    ; $hFile - The path to the file which you want to read
    ;
    ; Return Value(s):
    ; Success - Returns the number of entries in the .ini
    ; Failure - If the file path is wrong @error will be set to 2 and 2 will be returned
    ; Failure - If no number of entrie(s) will be found @error will be set to 3 and 3 will be returned
    ; Failure - If the file can't be read @error will be set to 4 and 4 will be returned
    ;
    ;===============================================================================
    Func _Radio_ReadEntrieFromPLS($hFile)
    If $hFile <> "" Then
    $vRead = FileRead($hFile)
    If @error = 1 Then
    Return 4
    SetError(4)
    Exit
    EndIf
    $vEntrie = IniRead($hFile, "playlist", "NumberOfEntries", "")
    If $vEntrie = "" Then
    Return 3
    SetError(3)
    Exit
    Else
    Return $vEntrie
    EndIf
    Else
    Return 2
    SetError(2)
    Exit
    EndIf
    EndFunc ;==>_Radio_ReadEntrieFromPLS
    ;===============================================================================
    ;
    ; Description: Reads title(s) from a PLS File (Version 2)
    ; Syntax: _Radio_ReadTitleFromPLS
    ; Parameter(s):
    ; $hFile - The path to the file which you want to read
    ;
    ; Return Value(s):
    ; Success - Returns a $var with array (First $array[0] is the first title which was found, $array[1] is the second, $array[n] ...
    ; Failure - If the file path is wrong @error will be set to 2 and 2 will be returned
    ; Failure - If no title(s) will be found @error will be set to 3 and 3 will be returned
    ; Failure - If the file can't be read @error will be set to 4 and 4 will be returned
    ;
    ;===============================================================================
    Func _Radio_ReadTitleFromPLS($hFile)
    If $hFile <> "" Then
    $vEntrie = IniReadSection($hFile, "playlist")
    If @error = 1 Then
    Return 3
    SetError(3)
    Exit
    EndIf
    $sSection = "playlist"
    $sArray = ""
    $sSuche = "Title"
    $aReturn = IniReadSection($hFile, $sSection)
    For $i = 0 To UBound($aReturn) - 1
    If StringInStr($aReturn[$i][0], $sSuche) Then $sArray &= "|" & $aReturn[$i][1]
    Next
    $aArray = StringSplit(StringTrimLeft($sArray, 1), "|")
    _ArrayDelete($aArray, 0)
    Return $aArray
    Else
    Return 2
    SetError(2)
    Exit
    EndIf
    EndFunc ;==>_Radio_ReadTitleFromPLS
    ;===============================================================================
    ;
    ; Description: Reads source URL(s) from a PLS File (Version 2)
    ; Syntax: _Radio_ReadSourceURLFromPLS
    ; Parameter(s):
    ; $hFile - The path to the file which you want to read
    ;
    ; Return Value(s):
    ; Success - Returns a $var with array (First $array[0] is the first source URL which was found, $array[1] is the second, $array[n] ...
    ; Failure - If the file path is wrong @error will be set to 2 and 2 will be returned
    ; Failure - If no source URL(s) will be found @error will be set to 3 and 3 will be returned
    ; Failure - If the file can't be read @error will be set to 4 and 4 will be returned
    ;
    ;===============================================================================
    Func _Radio_ReadSourceURLFromPLS($hFile)
    If $hFile <> "" Then
    $vEntrie = IniReadSection($hFile, "playlist")
    If @error = 1 Then
    Return 3
    SetError(3)
    Exit
    EndIf
    $sSection = "playlist"
    $sArray = ""
    $sSuche = "File"
    $aReturn = IniReadSection($hFile, $sSection)
    For $i = 0 To UBound($aReturn) - 1
    If StringInStr($aReturn[$i][0], $sSuche) Then $sArray &= "|" & $aReturn[$i][1]
    Next
    $aArray = StringSplit(StringTrimLeft($sArray, 1), "|")
    _ArrayDelete($aArray, 0)
    Return $aArray
    Else
    Return 2
    SetError(2)
    Exit
    EndIf
    EndFunc ;==>_Radio_ReadSourceURLFromPLS
    ;===============================================================================
    ;
    ; Description: Reads length(s) from a PLS File (Version 2)
    ; Syntax: _Radio_ReadLengthFromPLS
    ; Parameter(s):
    ; $hFile - The path to the file which you want to read
    ;
    ; Return Value(s):
    ; Success - Returns a $var with array (First $array[0] is the first lenght which was found, $array[1] is the second, $array[n] ...
    ; Failure - If the file path is wrong @error will be set to 2 and 2 will be returned
    ; Failure - If no lenght(s) will be found @error will be set to 3 and 3 will be returned
    ; Failure - If the file can't be read @error will be set to 4 and 4 will be returned
    ;
    ;===============================================================================
    Func _Radio_ReadLengthFromPLS($hFile)
    If $hFile <> "" Then
    $vEntrie = IniReadSection($hFile, "playlist")
    If @error = 1 Then
    Return 3
    SetError(3)
    Exit
    EndIf
    $sSection = "playlist"
    $sArray = ""
    $sSuche = "Length"
    $aReturn = IniReadSection($hFile, $sSection)
    For $i = 0 To UBound($aReturn) - 1
    If StringInStr($aReturn[$i][0], $sSuche) Then $sArray &= "|" & $aReturn[$i][1]
    Next
    $aArray = StringSplit(StringTrimLeft($sArray, 1), "|")
    _ArrayDelete($aArray, 0)
    Return $aArray
    Else
    Return 2
    SetError(2)
    Exit
    EndIf
    EndFunc ;==>_Radio_ReadLengthFromPLS
    ;===============================================================================
    ;
    ; Description: Creates a Windows Media Player as a child GUI to the existing GUI
    ; Syntax: _Radio_Create
    ; Parameter(s):
    ; $sName - The name of the Windows Media Player (will not be shown in GUI)
    ; $hGUI - The $var from the first GUI which have been created before the function
    ; $bLeft - The left side of the Windows Media Player
    ; $bTop - The top of the Windows Media Player
    ;
    ; Return Value(s):
    ; Success - Shows the child GUI (Windows Media Player) to the existing GUI. Returns the $var for the object
    ; Failure - If the $sName is empty @error will be set to 2 and 2 will be returned
    ; Failure - If the $hGUI is empty @error will be set to 3 and 3 will be returned
    ; Failure - If the $bLeft is empty @error will be set to 4 and 4 will be returned
    ; Failure - If the $bTop is empty @error will be set to 5 and 5 will be returned
    ;
    ;===============================================================================
    Func _Radio_Create($sName, $hGUI, $bLeft, $bTop)
    If $sName = "" Then
    Return 2
    SetError(2)
    Exit
    ElseIf $hGUI = "" Then
    Return 3
    SetError(3)
    Exit
    ElseIf $bLeft = "" Then
    Return 4
    SetError(4)
    Exit
    ElseIf $bTop = "" Then
    Return 5
    SetError(5)
    Exit
    EndIf
    GUISwitch($hGUI)
    $hPlayerGUI = GUICreate($sName, 242, 41, $bLeft, $bTop, $WS_CHILD, "", $hGUI)
    $vCreatePlayer = ObjCreate("WMPlayer.OCX")
    $hPlayer = GUICtrlCreateObj($vCreatePlayer, 0, -200, 600, 385)
    With $vCreatePlayer
    .fullScreen = True
    .windowlessVideo = False
    .enableContextMenu = True
    .enabled = True
    .uiMode = "full"
    .settings.autostart = True
    .settings.mute = False
    .settings.volume = 100
    .settings.Balance = 0
    EndWith
    GUISetState(@SW_SHOW, $hPlayerGUI)
    GUISetState(@SW_SHOW, $hGUI)
    Return $vCreatePlayer
    EndFunc ;==>_Radio_Create
    ;===============================================================================
    ;
    ; Description: Sets a new item to a existing player
    ; Syntax: _Radio_Action_SetItem
    ; Parameter(s):
    ; $hPlayer - The $var of the player which have to be controlled
    ; $sPathOrURL - The path to the file or URL which have to be set to the player
    ;
    ; Return Value(s):
    ; Success - Sets the new item to the player
    ; Failure - If the $sPlayer is empty @error will be set to 2 and 2 will be returned
    ; Failure - If the $sPathOrURL is empty @error will be set to 3 and 3 will be returned
    ;
    ;===============================================================================
    Func _Radio_Action_SetItem($hPlayer, $sPathOrURL)
    If $hPlayer = "" Then
    Return 2
    SetError(2)
    Exit
    ElseIf $sPathOrURL = "" Then
    Return 3
    SetError(3)
    Exit
    EndIf
    $hPlayer.URL = $sPathOrURL
    EndFunc ;==>_Radio_Action_SetItem
    ;===============================================================================
    ;
    ; Description: Plays the current item
    ; Syntax: _Radio_Action_Play
    ; Parameter(s):
    ; $hPlayer - The $var of the player which have to be controlled
    ;
    ; Return Value(s):
    ; Success - Play the current item of the player
    ; Failure - If the $sPlayer is empty @error will be set to 2 and 2 will be returned
    ;
    ;===============================================================================
    Func _Radio_Action_Play($hPlayer)
    If $hPlayer = "" Then
    Return 2
    SetError(2)
    Exit
    EndIf
    $hPlayer.controls.play()
    EndFunc ;==>_Radio_Action_Play
    ;===============================================================================
    ;
    ; Description: Pauses the current item
    ; Syntax: _Radio_Action_Pause
    ; Parameter(s):
    ; $hPlayer - The $var of the player which have to be controlled
    ;
    ; Return Value(s):
    ; Success - Pauses the current item of the player
    ; Failure - If the $sPlayer is empty @error will be set to 2 and 2 will be returned
    ;
    ;===============================================================================
    Func _Radio_Action_Pause($hPlayer)
    If $hPlayer = "" Then
    Return 2
    SetError(2)
    Exit
    EndIf
    $hPlayer.controls.pause()
    EndFunc ;==>_Radio_Action_Pause
    ;===============================================================================
    ;
    ; Description: Stops the current item
    ; Syntax: _Radio_Action_Stop
    ; Parameter(s):
    ; $hPlayer - The $var of the player which have to be controlled
    ;
    ; Return Value(s):
    ; Success - Stops the current item of the player
    ; Failure - If the $sPlayer is empty @error will be set to 2 and 2 will be returned
    ;
    ;===============================================================================
    Func _Radio_Action_Stop($hPlayer)
    If $hPlayer = "" Then
    Return 2
    SetError(2)
    Exit
    EndIf
    $hPlayer.controls.stop()
    EndFunc ;==>_Radio_Action_Stop
    ;===============================================================================
    ;
    ; Description: Plays the next item
    ; Syntax: _Radio_Action_Next
    ; Parameter(s):
    ; $hPlayer - The $var of the player which have to be controlled
    ;
    ; Return Value(s):
    ; Success - Plays the next item
    ; Failure - If the $sPlayer is empty @error will be set to 2 and 2 will be returned
    ;
    ;===============================================================================
    Func _Radio_Action_Next($hPlayer)
    If $hPlayer = "" Then
    Return 2
    SetError(2)
    Exit
    EndIf
    $hPlayer.controls.next()
    EndFunc ;==>_Radio_Action_Stop
    ;===============================================================================
    ;
    ; Description: Plays the previous item
    ; Syntax: _Radio_Action_Previous
    ; Parameter(s):
    ; $hPlayer - The $var of the player which have to be controlled
    ;
    ; Return Value(s):
    ; Success - Plays the previous item
    ; Failure - If the $sPlayer is empty @error will be set to 2 and 2 will be returned
    ;
    ;===============================================================================
    Func _Radio_Action_Previous($hPlayer)
    If $hPlayer = "" Then
    Return 2
    SetError(2)
    Exit
    EndIf
    $hPlayer.controls.previous()
    EndFunc ;==>_Radio_Action_Stop
    ;===============================================================================
    ;
    ; Description: Starts fast play in forward direction of the current item
    ; Syntax: _Radio_Action_FastForward
    ; Parameter(s):
    ; $hPlayer - The $var of the player which have to be controlled
    ;
    ; Return Value(s):
    ; Success - Plays the previous item
    ; Failure - If the $sPlayer is empty @error will be set to 2 and 2 will be returned
    ;
    ;===============================================================================
    Func _Radio_Action_FastForward($hPlayer)
    If $hPlayer = "" Then
    Return 2
    SetError(2)
    Exit
    EndIf
    $hPlayer.controls.fastForward()
    EndFunc ;==>_Radio_Action_Stop
    ;===============================================================================
    ;
    ; Description: Starts fast play in reverse direction of the current item
    ; Syntax: _Radio_Action_FastReverse
    ; Parameter(s):
    ; $hPlayer - The $var of the player which have to be controlled
    ;
    ; Return Value(s):
    ; Success - Plays the previous item
    ; Failure - If the $sPlayer is empty @error will be set to 2 and 2 will be returned
    ;
    ;===============================================================================
    Func _Radio_Action_FastReverse($hPlayer)
    If $hPlayer = "" Then
    Return 2
    SetError(2)
    Exit
    EndIf
    $hPlayer.controls.fastReverse()
    EndFunc ;==>_Radio_Action_Stop

    [/autoit]
  • Ich habs getestet, wenn ich eine Funktion in meinem eigenen Script benutze, die UDF einen Fehler hat wird mein eigenes Script nicht beendet...

  • Wie soll ich das Return 2 nach dem SetError(2) setzen?


  • Das war ein Feedback (z.B.)

    Ich denke nicht das das seine Meinung über die UDF ist, wo siehst du in dem Satz denn ein Feedback? Das war eher eine Hilfe bzw. Verbesserung...

  • Soll _Radio_ReadTitleFromASX bedeuten, dass er den Titel und/oder den Sendernamen rausfindet?
    Wenn ja, klappt das nicht ;)

    Meine fertigen Projekte:
    VirtualCash
    Monopoly Digital

    Daran arbeite ich gerade:
    Einem Skript, womit man ohne Programmierkentisse eigene Programme machen kann (habe ich selber früher gesucht :D ) Stand: ||||||||||||||||||||||||| 6%

  • Soll _Radio_ReadTitleFromASX bedeuten, dass er den Titel und/oder den Sendernamen rausfindet?
    Wenn ja, klappt das nicht ;)

    Sollte schon den Sendernamen herausfinden... Ich gucke mal

    Edit:// Funktioniert doch einwandfrei?

  • Die funktionert garnicht. Wenn ich auf SetItem klicke bekomme ich den folgenden Fehler:

    [autoit]

    C:\Program Files (x86)\AutoIt3\Include\_Radio.au3 (395) : ==> The requested action with this object has failed.:
    $hPlayer.URL = $sPathOrURL
    $hPlayer.URL = $sPathOrURL^ ERROR
    ->19:08:37 AutoIT3.exe ended.rc:1

    [/autoit]