get trackname und artist über wmp.ocx

  • hi ich habe probiert den currenttrack von WMP zu bekommen über die scriptingstelle nur irgendwie versteh ich das nicht hier mal die doku

    http://msdn2.microsoft.com/en-us/library/bb249259.aspx

    [autoit]


    $cn = "^3"
    $ca = "^3"
    $cm = "^7"
    $ct = "^7"
    Func _getcurrenttrack_wmp()
    $oWMP = ObjCreate("WMPlayer.OCX" )
    $curtrackWMP = $oWMP.currentMedia
    $TracknameWMP = $cn&$oWMP.currentMedia.name
    $ArtistnameWMP = $ca&$curtrackWMP.Artist
    $TitleWMP = $ArtistnameWMP&" "&$cm&"-"&" "&$TracknameWMP
    $musicWMP = $ct&"I am listening to "&$TitleWMP
    ClipPut ($TrackName)
    send ("^v")
    EndFunc

    [/autoit]

    "^blub" sind Farbcodes also nicht verwirren lassen

  • immer noch keine Antwort; wehe ein gewisser Vorposter hat meine Retter aus dem Forum vertrieben

    • Offizieller Beitrag

    Hallo!

    Wie man nun den artist auslesen kann konnt ich auf die schnelle nicht finden, aber ich hab es dir mal etwas so umgeschrieben das es eigentlich funktioniern sollten ;)

    Spoiler anzeigen
    [autoit]

    $cn = "^3"
    $ca = "^3"
    $cm = "^7"
    $ct = "^7"
    _getcurrenttrack_wmp()
    Func _getcurrenttrack_wmp()
    $oWMP = ObjCreate("WMPlayer.OCX")
    $oWMP.currentMedia = $oWMP.mediaCollection.getAll ().item (0)
    $TracknameWMP = $oWMP.currentmedia.name
    ;~ $ArtistnameWMP = $oWMP.currentmedia.Artist; ?
    $TitleWMP = "artist unknow " & $cm & "-" & " " & $TracknameWMP
    $musicWMP = $ct & "I am listening to " & $TitleWMP
    ClipPut($musicWMP)
    Send("^v")
    EndFunc ;==>_getcurrenttrack_wmp

    [/autoit]

    Mfg Spider

    p.s.: sry das ich nicht geantwortet hab, ich war auf klo :schild4:

  • ja schon einmal danke nur bräucht ich auf jedenfall den Artisten :(

    und ich hab noch ein Problem mit StringRegExpReplace:

    von foobar mit Wingettitle ausgelesen und das foobar zeuch wegeschnitten mit StringTrimRight hab ich noch diesen String übrig

    [autoit]


    $Titlefoo = "Basshunter - [LOL #02] Boten Anna"
    $Titlefoo = StringRegExpReplace ($Titlefoo, "[[]].[[]]", "")

    [/autoit]

    ich möchte das Album draußen haben und die Nummer also das was in [] steht samt den "[" und "]"

    nur irgendwie veränder der gar nichts, bei Winamp bin ich gut mit StringRegExpReplace zu Rande gekommen, aber diese [ und ] sind komisch

    • Offizieller Beitrag

    Hi!

    Minimale Korrektur, th.meger:

    [autoit]

    $Titlefoo = "Basshunter - [LOL #02] Boten] Anna"
    MsgBox(64, 'Replaced', StringRegExpReplace($Titlefoo, '\[.*?\]', ''))

    [/autoit]

    peethebee

    • Offizieller Beitrag
    Zitat

    Original von peethebee
    Hi!

    Minimale Korrektur, th.meger:

    [autoit]

    $Titlefoo = "Basshunter - [LOL #02] Boten] Anna"
    MsgBox(64, 'Replaced', StringRegExpReplace($Titlefoo, '\[.*?\]', ''))

    [/autoit]

    peethebee

    Hi,

    okay wenn man das "gierig sein" ausschalten will. :musik2:

    So long,

    Mega

  • naja die Bindestriche hab ich so mit StringTrimRight/Left weggemacht und nochmal gesplittet da ich den Artisten und den Songnamen einzeln brauche

  • mh also ich fände es persönlich besser wenn mir vllt. noch jemand beim Artisten vom WMP hilft XD

    • Offizieller Beitrag

    HI,

    okay :)

    Check dies:

    Spoiler anzeigen
    [autoit]


    $sFilename = "c:\Downloads\Musik\The Police - De Do Do Do, De Da Da Da.mp3"
    $pObj = ObjCreate("WMPlayer.OCX")
    $sObj = WMOpenFile ($pObj, $sFilename)
    WMPlay ($pObj, $sFilename)

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

    For $i = 0 To 100
    WmSetVolume ($pObj, 100 - $i)
    Sleep(100)
    Next
    For $i = 0 To 100
    WmSetVolume ($pObj, $i)
    Sleep(100)
    Next

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

    WMFastForward ($pObj)
    ConsoleWrite(" : FF")
    Sleep(3000)
    WMReverse ($pObj)
    ConsoleWrite(" : RR")
    Sleep(3000)
    WMPause ($pObj)
    ConsoleWrite(" : Pause")
    Sleep(3000)
    WMResume ($pObj)
    ConsoleWrite(" : Resume")
    Sleep(3000)
    WMStop ($pObj)
    ConsoleWrite(" : Stop")
    Sleep(3000)
    WMResume ($pObj)
    ConsoleWrite(" : Resume")
    Sleep(3000)
    WMSetPosition ($pObj, 100)
    ConsoleWrite(" : Set Pos")

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

    MsgBox(0, "Song Data", "Duration - " & WMGetDuration ($sObj) & @LF & _
    "Artist - " & WmGetArtist ($sObj) & @LF & _
    "Album - " & WmGetAlbum ($sObj) & @LF & _
    "Title - " & WmGetTitle ($sObj) & @LF & _
    "Bitrate - " & WmGetBitrate ($sObj) & @LF & _
    "MediaType - " & WmGetMediaType ($sObj) & @LF & _
    "FileSize - " & WmGetFileSize ($sObj) & @LF & _
    "FileType - " & WmGetFileType ($sObj) & @LF & _
    "Category - " & WMGetCategory ($sObj) & @LF & _
    "Genre - " & WMGetGenre ($sObj) & @LF & _
    "Year - " & WMGetYear ($sObj) & @LF & _
    "State - " & WMGetState ($pObj))

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

    #include-once

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

    ; ------------------------------------------------------------------------------
    ;
    ; AutoIt Version: 3.0
    ; Language: English
    ; Description: Functions that assist with Media Manipulation.
    ;
    ; Notes: To create the Player Object - $pObj = ObjCreate("WMPlayer.OCX" )
    ; ------------------------------------------------------------------------------

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

    ; ====================================================================================================
    ; Description ..: Opens The Media file in The Player Object
    ; Parameters ...: $pObj - The Player Object to open the file in.
    ; $sFilename - Filename of the Media to Open
    ; Return values : Song Object to be used in other functions
    ; Author .......: CFire
    ; Notes ........:
    ; ====================================================================================================
    Func WMOpenFile($pObj, $sFilename)
    Return $pObj.newMedia($sFilename)
    EndFunc

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

    ; ====================================================================================================
    ; Description ..: Sets the Volume of the Player.
    ; Parameters ...: $pObj - The Player Object
    ; $iVol - New Volume ( 0 - 100 )
    ; Return values :
    ; Author .......: CFire
    ; Notes ........: Does Not Affect System/Wave Volumes!!
    ; ====================================================================================================
    Func WMSetVolume($pObj, $iVol)
    $pObj.settings.volume = $iVol
    EndFunc

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

    ; ====================================================================================================
    ; Description ..: Returns the Current Volume of The Player
    ; Parameters ...: $pObj - The Player Object
    ; Return values : Current Volume ( 0 - 100 )
    ; Author .......: CFire
    ; Notes ........:
    ; ====================================================================================================
    Func WMGetVolume($pObj)
    Return $pObj.settings.volume
    EndFunc

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

    ; ====================================================================================================
    ; Description ..: Fast Forwards the Current Playing Media
    ; Parameters ...: $pObj - The Player Object
    ; Return values :
    ; Author .......: CFire
    ; Notes ........:
    ; ====================================================================================================
    Func WMFastForward($pObj)
    $pObj.controls.fastForward()
    EndFunc

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

    ; ====================================================================================================
    ; Description ..: Rewinds the Current Playing Media
    ; Parameters ...: $pObj - The Player Object
    ; Return values :
    ; Author .......: CFire
    ; Notes ........:
    ; ====================================================================================================
    Func WMReverse($pObj)
    $pObj.controls.fastReverse()
    EndFunc

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

    ; ====================================================================================================
    ; Description ..: Plays a Media for the first time
    ; Parameters ...: $pObj - The Player Object
    ; $sFilename - Filename of the Media to Play
    ; Return values :
    ; Author .......: CFire
    ; Notes ........: This needs to be called only once during the Duration of any Media
    ; ====================================================================================================
    Func WMPlay($pObj, $sFilename)
    $pObj.url = $sFilename
    while not WMGetState($pObj) = "Playing"
    sleep(100)
    WEnd
    EndFunc

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

    ; ====================================================================================================
    ; Description ..: Pauses the Current Playing Media
    ; Parameters ...: $pObj - The Player Object
    ; Return values :
    ; Author .......: CFire
    ; Notes ........:
    ; ====================================================================================================
    Func WMPause($pObj)
    $pObj.controls.pause()
    EndFunc

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

    ; ====================================================================================================
    ; Description ..: Resumes a Stopped or Paused Media
    ; Parameters ...: $pObj - The Player Object
    ; Return values :
    ; Author .......: CFire
    ; Notes ........:
    ; ====================================================================================================
    Func WMResume($pObj)
    $pObj.controls.play()
    EndFunc

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

    ; ====================================================================================================
    ; Description ..: Stops the Current Playing Media
    ; Parameters ...: $pObj - The Player Object
    ; Return values :
    ; Author .......: CFire
    ; Notes ........:
    ; ====================================================================================================
    Func WMStop($pObj)
    $pObj.controls.stop()
    EndFunc

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

    ; ====================================================================================================
    ; Description ..: Sets the Position of the Media
    ; Parameters ...: $pObj - The Player Object
    ; $iPos - Position in Seconds
    ; Return values :
    ; Author .......: CFire
    ; Notes ........: No need to call a WMPlay(). This will continue play at the new Position
    ; ====================================================================================================
    Func WMSetPosition($pObj, $iPos)
    $pObj.controls.currentPosition = $iPos
    EndFunc

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

    ; ====================================================================================================
    ; Description ..: Returns the Current Position in the Media
    ; Parameters ...: $pObj - The Player Object
    ; Return values : Position in Seconds
    ; Author .......: CFire
    ; Notes ........:
    ; ====================================================================================================
    Func WMGetPosition($pObj)
    Return $pObj.controls.currentPosition
    EndFunc

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

    ; ====================================================================================================
    ; Description ..: Returns the Duration / Length of the Media
    ; Parameters ...: $sObj - The Song Object returned from WMOpenFile()
    ; Return values : Duration in Seconds
    ; Author .......: CFire
    ; Notes ........:
    ; ====================================================================================================
    Func WMGetDuration($sObj)
    Return $sObj.GetItemInfo("Duration")
    EndFunc

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

    ; ====================================================================================================
    ; Description ..: Functions that Get a Property of the Media
    ; Parameters ...: $sObj - The Song Object returned from WMOpenFile()
    ; Return values : Specific Property
    ; Author .......: CFire
    ; Notes ........:
    ; ====================================================================================================
    Func WMGetArtist($sObj)
    Return $sObj.GetItemInfo("Artist")
    EndFunc

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

    Func WMGetTitle($sObj)
    Return $sObj.GetItemInfo("Title")
    EndFunc

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

    Func WMGetAlbum($sObj)
    Return $sObj.GetItemInfo("Album")
    EndFunc

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

    Func WMGetBitrate($sObj)
    Return $sObj.GetItemInfo("Bitrate")
    EndFunc

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

    Func WMGetMediaType($sObj)
    Return $sObj.GetItemInfo("MediaType")
    EndFunc

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

    Func WMGetFileSize($sObj)
    Return $sObj.GetItemInfo("FileSize")
    EndFunc

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

    Func WMGetFileType($sObj)
    Return $sObj.GetItemInfo("FileType")
    EndFunc

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

    Func WMGetCategory($sObj)
    Return $sObj.GetItemInfo("WM/Category")
    EndFunc

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

    Func WMGetGenre($sObj)
    Return $sObj.GetItemInfo("WM/Genre")
    EndFunc

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

    Func WMGetYear($sObj)
    Return $sObj.GetItemInfo("WM/Year")
    EndFunc

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

    Func WMGetState($pObj)
    $sStates = "Undefined,Stopped,Paused,Playing,ScanForward,ScanReverse,Buffering,"
    $sStates &= "Waiting,MediaEnded,Transitioning,Ready,Reconnecting"
    $aStates = StringSplit($sStates,",")
    $iState = $pObj.playState()
    return $aStates[$iState]
    EndFunc

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

    So long,

    Mega

  • also wenn das ausm englischen Forum ist dann versteh ich die Welt nicht mehr hab min eine h lang gesucht und mich durch Mengen von Sourcecode durchgelesen und mit der msdndingsbums zu arbeiten und nun bekomm ich hier einfach die funktionen omg

    danke

    edit:

    $TracknameWMP = $cn&$oWMP.GetItemInfo("Artist")
    $TracknameWMP = $cn&$oWMP.GetItemInfo("Artist")^Error

    Error: The requested action with this object has failed.

    [autoit]


    $oWMP = ObjCreate("WMPlayer.OCX")
    $TracknameWMP = $cn&$oWMP.GetItemInfo("Artist")
    $ArtistnameWMP = $ca&$oWMP.GetItemInfo("Title")
    $TitleWMP = $ArtistnameWMP&" "&$cm& "-"&" "&$TracknameWMP
    $musicWMP = $ct&"I am listening to "&$TitleWMP
    ClipPut($musicWMP)
    Send("^v")
    send ("{ENTER}")

    [/autoit]

    Einmal editiert, zuletzt von leviathan (13. April 2007 um 23:16)